Blame view

src/ai_engine_module/road_seg_statistics.h 3.2 KB
02e5e637   Zhao Shuaihua   增加行人/非机动车占机动车道(50...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
  #pragma once

  #include <string.h>

  #include <vector>

  #include <opencv2/opencv.hpp>

  

  #include "sy_common.h"

  #include "sy_errorinfo.h"

  

  #include <math.h>

  #include "../common/logger.hpp"

  #include "../ai_platform/macro_definition.h"

  #include "road_seg.h"

  

  #include "acl/acl.h"

  #include "acl/ops/acl_dvpp.h"

  #include "../util/vpc_util.h"

  #include "../util/JpegUtil.h"

  

  using namespace std;

  using namespace cv;

  

  class RoadSegProcess {

  

  public:

      RoadSegProcess();

      ~RoadSegProcess();

      /*************************************************************************

      * FUNCTION: Init

      * PURPOSE: 初始化

      * PARAM:

      [in] segparam	参数

      * RETURN:	handle

      * NOTES:

      *************************************************************************/

      int init(int gpu_id, string models_dir);

  

  

      /**

       * @brief 道路分割

       *

       * @param handle [in]

       * @param batch_img [in]

       * @param batchsize [in]

       * @param result [in]

       * @return int -1:图像错误; 其他:检测到的个数

       */

      int process_gpu(sy_img * batch_img, vector<DeviceMemory*> vec_segMem, vector<string>& tasklist, 

                                           vector<vector<vector<int>>>& traffic_region, vector<vector<int>>& labels);

  

      /*************************************************************************

      * FUNCTION: Release

      * PURPOSE: 资源释放

      * PARAM:

      [in] handle		- 处理句柄

      * RETURN:	NULL

      * NOTES:

      *************************************************************************/

      void release();

  

      cv::Mat mask_to_rgb(cv::Mat img, cv::Mat mask);

      float contourArea(std::vector<cv::Point> contour, cv::Point2f& center);

      void lanes_process(const rs_lane* lanes, int lane_count, std::vector<std::pair<std::vector<cv::Point>, int>>& combined, float scale_w = 1.0, float scale_h = 1.0);

      cv::Mat imshow_lanes(cv::Mat img, const rs_lane* lanes, int lane_count);

      int Mask2LanePoints(const cv::Mat& pred, std::vector<std::vector<cv::Point>>&lanes, std::vector<int>& cats);

      cv::Mat seg_post_process(bool large_resolution, unsigned char *seg_array, std::vector<std::pair<std::vector<cv::Point>, int>> combined, std::vector<std::vector<cv::Point>> &poly_masks, std::vector<int> &region_classes, std::vector<std::vector<cv::Point>> &lanes, std::vector<int> &cats, std::map<double, int> &x_sort);

  

  private:

      int m_devId; 

      aclrtContext m_algorthim_ctx;

      JpegUtil jpegUtil;

      void* m_seg_handle{nullptr};

  	float threshold{0.6};

  	int m_max_batchsize;

  	int SEG_IMG_RES_W = 640;

      int SEG_IMG_RES_H = 360;

      int seg_num_cls = 4; //车道线种类(不包含背景)

      int seg_num_seg = 7; //道路分割种类(不包含背景)

      int seg_min_region_area = 512; //1024 

      float seg_min_lane_score = 0.35; //230625

8c495cc9   Zhao Shuaihua   增加实线掉头(515)功能
80
81
      uint8_t seg_colors[13][3] = { {0, 0, 0}, {255, 0, 0}, {0, 255, 0}, {0, 0, 255}, {0, 255, 128}, {128, 255, 255}, {255, 128, 255}, {255, 255, 128}, {60, 180, 0}, {0, 60, 180}, 

      {0, 180, 60},  {60, 0, 180},  {180, 0, 60} };

02e5e637   Zhao Shuaihua   增加行人/非机动车占机动车道(50...
82
83
84
85
      uint8_t lane_colors[9][3] = { {0, 0, 0}, {255, 255, 0}, {255, 0, 255}, {0, 255, 255}, {128, 255, 0}, {255, 128, 0}, {128, 0, 255}, {255, 0, 128}, {0, 128, 255}};

  };