Commit ba6761f1fc1478f699b660bade0ff800c7007fb9

Authored by Hu Chunming
1 parent e3062370

补充日志

jni/VehicleNativeInterface.cpp
... ... @@ -5,6 +5,7 @@
5 5 #include "map"
6 6 #include <string>
7 7 #include <string.h>
  8 +#include <chrono>
8 9  
9 10 #include "../src/village_pic_interface.h"
10 11  
... ... @@ -13,7 +14,7 @@
13 14 #include <opencv2/opencv.hpp>
14 15 #include "base64.h"
15 16  
16   -#include "curl/curl.h"
  17 +// #include "curl/curl.h"
17 18  
18 19 //dvpp����
19 20 #include "dvpp_process.h"
... ... @@ -21,9 +22,9 @@
21 22 //#include "img_codec.h"
22 23  
23 24 double msecond() {
24   - struct timeval tv;
25   - gettimeofday(&tv, 0);
26   - return (tv.tv_sec * 1000.0 + tv.tv_usec / 1000.0);
  25 + chrono::time_point<chrono::system_clock, chrono::milliseconds> tpMicro
  26 + = chrono::time_point_cast<chrono::milliseconds>(chrono::system_clock::now());
  27 + return tpMicro.time_since_epoch().count();
27 28 }
28 29  
29 30  
... ... @@ -89,9 +90,9 @@ using namespace std;
89 90 * ��������
90 91 * */
91 92 sy_format getImgByteType(int type);
92   -size_t write_data(char *ptr, size_t size, size_t nmemb, void *userdata);
93   -//function to retrieve the image as cv::Mat data type
94   -cv::Mat curlImg(const char *img_url, int timeout);
  93 +// size_t write_data(char *ptr, size_t size, size_t nmemb, void *userdata);
  94 +// //function to retrieve the image as cv::Mat data type
  95 +// cv::Mat curlImg(const char *img_url, int timeout);
95 96  
96 97 /**
97 98 * ȫ�ֱ���
... ... @@ -154,7 +155,12 @@ JNIEXPORT jint JNICALL Java_com_objecteye_nativeinterface_vehicle_VehicleNativeI
154 155 param.log_days = aiEngineParam_logDays;
155 156 param.log_mem = aiEngineParam_logMem;
156 157  
157   - printf("jni dev_id:%d sdk_path:%s_log_level:%d\n", param.dev_id, param.sdk_path.c_str(), param.log_level);
  158 + printf("jni dev_id:%d \n", param.dev_id);
  159 + printf("jni sdk_path:%s_\n", param.sdk_path.c_str());
  160 + printf("jni log_level:%d\n", param.log_level);
  161 + printf("jni log_path:%s\n", param.log_path.c_str());
  162 + printf("jni log_days:%d\n", param.log_days);
  163 + printf("jni log_mem:%ld\n", param.log_mem);
158 164  
159 165 int ret = village_pic_init(&vaHandle, param);
160 166 if (ret != SUCCESS) {
... ... @@ -310,7 +316,7 @@ JNIEXPORT jint JNICALL Java_com_objecteye_nativeinterface_vehicle_VehicleNativeI
310 316 printf("jni info:village_pic_analysis failed.");
311 317 return -1;
312 318 }
313   - //cout << "VAJNI_TEST va_1batch -> end ...." << endl;
  319 + cout << "result size:" << vec_result.size() << endl;
314 320  
315 321 t3 = msecond();
316 322 //printf("va jni info:process time: %.2f\n", (t3 - t2));
... ... @@ -678,29 +684,29 @@ sy_format getImgByteType(int type)
678 684 return syFormat;
679 685 }
680 686  
681   -//curl writefunction to be passed as a parameter
682   -// we can't ever expect to get the whole image in one piece,
683   -// every router / hub is entitled to fragment it into parts
684   -// (like 1-8k at a time),
685   -// so insert the part at the end of our stream.
686   -size_t write_data(char *ptr, size_t size, size_t nmemb, void *userdata)
687   -{
688   - vector<uchar> *stream = (vector<uchar>*)userdata;
689   - size_t count = size * nmemb;
690   - stream->insert(stream->end(), ptr, ptr + count);
691   - return count;
692   -}
693   -
694   -//function to retrieve the image as cv::Mat data type
695   -cv::Mat curlImg(const char *img_url, int timeout = 10)
696   -{
697   - vector<uchar> stream;
698   - CURL *curl = curl_easy_init();
699   - curl_easy_setopt(curl, CURLOPT_URL, img_url); //the img url
700   - curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data); // pass the writefunction
701   - curl_easy_setopt(curl, CURLOPT_WRITEDATA, &stream); // pass the stream ptr to the writefunction
702   - curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout); // timeout if curl_easy hangs,
703   - CURLcode res = curl_easy_perform(curl); // start curl
704   - curl_easy_cleanup(curl); // cleanup
705   - return cv::imdecode(stream, -1); // 'keep-as-is'
706   -}
  687 +// //curl writefunction to be passed as a parameter
  688 +// // we can't ever expect to get the whole image in one piece,
  689 +// // every router / hub is entitled to fragment it into parts
  690 +// // (like 1-8k at a time),
  691 +// // so insert the part at the end of our stream.
  692 +// size_t write_data(char *ptr, size_t size, size_t nmemb, void *userdata)
  693 +// {
  694 +// vector<uchar> *stream = (vector<uchar>*)userdata;
  695 +// size_t count = size * nmemb;
  696 +// stream->insert(stream->end(), ptr, ptr + count);
  697 +// return count;
  698 +// }
  699 +
  700 +// //function to retrieve the image as cv::Mat data type
  701 +// cv::Mat curlImg(const char *img_url, int timeout = 10)
  702 +// {
  703 +// vector<uchar> stream;
  704 +// CURL *curl = curl_easy_init();
  705 +// curl_easy_setopt(curl, CURLOPT_URL, img_url); //the img url
  706 +// curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data); // pass the writefunction
  707 +// curl_easy_setopt(curl, CURLOPT_WRITEDATA, &stream); // pass the stream ptr to the writefunction
  708 +// curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout); // timeout if curl_easy hangs,
  709 +// CURLcode res = curl_easy_perform(curl); // start curl
  710 +// curl_easy_cleanup(curl); // cleanup
  711 +// return cv::imdecode(stream, -1); // 'keep-as-is'
  712 +// }
... ...
src/PicAnalysis.cpp
... ... @@ -9,19 +9,23 @@ PicAnalysis::PicAnalysis(/* args */)
9 9  
10 10 PicAnalysis::~PicAnalysis()
11 11 {
  12 + LOG_INFO("~PicAnalysis()");
12 13 release();
13 14 aclFinalize();
14 15 }
15 16  
16 17 int PicAnalysis::init(VillageParam param) {
17 18  
18   - set_default_logger(LogLevel(param.log_level), "PicAnalysis", param.log_path.c_str(), param.log_mem, param.log_days);
  19 + string log_path = param.log_path + "/main.log";
  20 +
  21 + set_default_logger(LogLevel(param.log_level), "PicAnalysis", log_path.c_str(), param.log_mem, param.log_days);
19 22  
20 23 // 输入参数
21 24 LOG_INFO("dev_id: {}", param.dev_id);
22 25 LOG_INFO("sdk_path: {}", param.sdk_path);
23 26 LOG_INFO("log_level: {}", param.log_level);
24 27 LOG_INFO("log_days: {}", param.log_days);
  28 + LOG_INFO("log_path: {}", log_path);
25 29  
26 30 int dev_id = param.dev_id;
27 31  
... ... @@ -180,13 +184,15 @@ vector&lt;AnalysisResult&gt; PicAnalysis::va_result2AnalysisResult(va_result* result,
180 184  
181 185 vector<AnalysisResult> PicAnalysis::analysis_img(vector<sy_img> vec_img){
182 186  
  187 + LOG_INFO("vec_img size:{}", vec_img.size());
  188 +
183 189 vector<AnalysisResult> vec_result;
184 190  
185 191 const int batch_size = vec_img.size();
186 192  
187 193 int ret = aclrtSetCurrentContext(m_ctx);
188 194 if (SY_SUCCESS != ret) {
189   - printf("aclrtSetCurrentContext failed!");
  195 + LOG_INFO("aclrtSetCurrentContext failed!");
190 196 return vec_result;
191 197 }
192 198  
... ... @@ -196,6 +202,8 @@ vector&lt;AnalysisResult&gt; PicAnalysis::analysis_img(vector&lt;sy_img&gt; vec_img){
196 202 m_vehicle_analysis.release_result(result, vec_img.size());
197 203 }
198 204  
  205 + LOG_INFO("vec_result size:{}", vec_result.size());
  206 +
199 207 bool bConsistent = false;
200 208 std::vector<RoadInfo> vec_road = m_road_seg_algorithm.detect(vec_img);
201 209 if (vec_road.size() == batch_size && vec_result.size() == batch_size) {
... ...
src/ai_engine_module/RoadSegAnalysis.cpp
... ... @@ -80,6 +80,23 @@ std::vector&lt;RoadInfo&gt; RoadSegAnalysis::detect(vector&lt;sy_img&gt; vec_img){
80 80 return vec_road;
81 81 }
82 82  
  83 +// void test(){
  84 +// cv::Mat image(cv::Size(640, 360), CV_8UC3, cv::Scalar(0, 0, 0));
  85 +
  86 +// for (int i = 0; i < poly_masks.size(); ++i) {
  87 +// SegInfo seg_info;
  88 +// seg_info.seg_type = region_classes[i];
  89 +// seg_info.vec_pt = poly_masks[i];
  90 +
  91 +// int k = seg_info.seg_type;
  92 +// const cv::Scalar color(seg_colors[k][0], seg_colors[k][1], seg_colors[k][2]);
  93 +// polylines(image, seg_info.vec_pt, true, color, 3, cv::LINE_AA);
  94 +// }
  95 +
  96 +// cv::imwrite("./road.jpg", image);
  97 +// image.release();
  98 +// }
  99 +
83 100 RoadInfo RoadSegAnalysis::parse_road(rs_result one_result, sy_img src)
84 101 {
85 102 RoadInfo one_road;
... ... @@ -123,7 +140,7 @@ std::vector&lt;SegInfo&gt; RoadSegAnalysis::parse_direct(rs_result one_result, sy_img
123 140 cv::Mat seg_output = seg_post_process(large_resolution, one_result.direct_seg, combined, poly_masks, region_classes, lanes, cats, x_sort); //m_masks:mask前的结果 poly_masks后的结果
124 141  
125 142  
126   - cv::Mat image(cv::Size(640, 360), CV_8UC3, cv::Scalar(0, 0, 0));
  143 + // cv::Mat image(cv::Size(640, 360), CV_8UC3, cv::Scalar(0, 0, 0));
127 144  
128 145 std::vector<SegInfo> vec_road;
129 146 for (int i = 0; i < poly_masks.size(); ++i) {
... ... @@ -131,16 +148,15 @@ std::vector&lt;SegInfo&gt; RoadSegAnalysis::parse_direct(rs_result one_result, sy_img
131 148 seg_info.seg_type = region_classes[i];
132 149 seg_info.vec_pt = poly_masks[i];
133 150  
134   - int k = seg_info.seg_type;
135   - const cv::Scalar color(seg_colors[k][0], seg_colors[k][1], seg_colors[k][2]);
136   -
137   - polylines(image, seg_info.vec_pt, true, color, 3, cv::LINE_AA);
138   -
139 151 vec_road.push_back(seg_info);
  152 +
  153 + // int k = seg_info.seg_type;
  154 + // const cv::Scalar color(seg_colors[k][0], seg_colors[k][1], seg_colors[k][2]);
  155 + // polylines(image, seg_info.vec_pt, true, color, 3, cv::LINE_AA);
140 156 }
141 157  
142   - cv::imwrite("./direct.jpg", image);
143   - image.release();
  158 + // cv::imwrite("./direct.jpg", image);
  159 + // image.release();
144 160  
145 161 return vec_road;
146 162 }
... ...
src/demo/main.cpp
... ... @@ -15,7 +15,7 @@ int main() {
15 15 int ret = village_pic_init(&vaHandle, param);
16 16  
17 17 vector<string> vec_path;
18   - size_t i = 1;
  18 + size_t i = 3;
19 19 // for (i = 1; i < 8; i++)
20 20 {
21 21 string path = "./img/test_phone";
... ...
src/village_inc.h
... ... @@ -21,7 +21,7 @@ struct VillageParam {
21 21 // AI_LOG_LEVEL_ERROR = 4, // 重要日志,如结果和严重错误
22 22 int log_level{2};
23 23 int log_days{30}; //日志保存周期
24   - std::string log_path{"logs/main.log"}; //日志文件路径
  24 + std::string log_path{"logs"}; //日志文件路径
25 25 unsigned long log_mem{64 * 1024 * 1024}; //每个日志最大大小
26 26 };
27 27  
... ...