浏览代码

modify camera_obs

zhengke 1 年之前
父节点
当前提交
d544c1cd49
共有 3 个文件被更改,包括 29 次插入14 次删除
  1. 2 1
      src/detection/camera_obs/camera_obs.xml
  2. 26 12
      src/detection/camera_obs/main.cpp
  3. 1 1
      src/detection/vision_yolov8/main.cpp

+ 2 - 1
src/detection/camera_obs/camera_obs.xml

@@ -1,8 +1,9 @@
 <xml>	
-	<node name="fusion_vision">
+	<node name="camera_obs">
 		<param name="msgname" value="image00" />
 		<param name="width" value = "1280" />
 		<param name="height" value="720" />
 		<param name="show_flag" value="1" />
+		<param name="wait_fake" value="2" />
 	</node>
 </xml>

+ 26 - 12
src/detection/camera_obs/main.cpp

@@ -32,6 +32,7 @@ int gindex = 0;
 
 int gwidth = 1920;
 int gheight = 1080;
+int wait_fake = 2;
 
 
 void * gpcamera;
@@ -209,8 +210,10 @@ void ObsToNormal(iv::fusion::fusionobjectarray& lidar_radar_fusion_object_array)
                     //std::cout<<"nomal_centroid:"<<nomal_centroid.nomal_x()<<","<<nomal_centroid.nomal_y()<<std::endl;
                 }
             }
+        }
     }
-}}
+    std::cout<<"ObsToNormal end:"<<std::endl;
+}
 
 void datafusion(iv::vision::Visionyolov8 yolo_obj){
     iv::fusion::fusionobjectarray out_fusion;
@@ -250,7 +253,6 @@ void datafusion(iv::vision::Visionyolov8 yolo_obj){
     string out;
     if(out_fusion.obj_size() == 0)
     {
-        //        std::cout<<"   fake   obj"<<std::endl;
 
         iv::fusion::fusionobject fake_obj;
         iv::fusion::fusionobject *fake_obj_;
@@ -281,7 +283,7 @@ int main(int argc, char *argv[]) {
     QCoreApplication a(argc, argv);
     QString strpath = QCoreApplication::applicationDirPath();
     if(argc < 2)
-        strpath = strpath + "/fusion_vision.xml";
+        strpath = strpath + "/camera_obs.xml";
     else
         strpath = argv[1];
     std::cout<<strpath.toStdString()<<std::endl;
@@ -291,18 +293,20 @@ int main(int argc, char *argv[]) {
     std::string strwidth = xp.GetParam("width","1280");
     std::string strheight = xp.GetParam("height","720");
     std::string showFlag = xp.GetParam("show_flag","0");
+    std::string waitFake = xp.GetParam("wait_fake","2");
     cameraname = xmlmsgname;
     gwidth = atoi(strwidth.data());
     gheight = atoi(strheight.data());
     show_flag = atoi(showFlag.data());
-
-    if(show_flag)
-        gpcamera= iv::modulecomm::RegisterRecv(&cameraname[0],Listenpic);
+    wait_fake = atoi(waitFake.data());
+    gpcamera= iv::modulecomm::RegisterRecv(&cameraname[0],Listenpic);
 
     double waittime = (double)cv::getTickCount();
+    double fake_time, wait_fake_time, total_fake_time;
+
     while (1)
     {
-        if(yolov8Buffer->isEmpty())
+        if(imageBuffer->isEmpty())
         {
             double waittotal = (double)cv::getTickCount() - waittime;
             double totaltime = waittotal/cv::getTickFrequency();
@@ -320,13 +324,23 @@ int main(int argc, char *argv[]) {
         }
 
         iv::vision::Visionyolov8 res;
-        yolov8Buffer->consume(res);
-        datafusion(res);
+        if(yolov8Buffer->length()>0){
+            yolov8Buffer->consume(res);
+            datafusion(res);
+            fake_time = (double)cv::getTickCount();
+        }
+        else{
+            wait_fake_time = (double)cv::getTickCount() - fake_time;
+            total_fake_time = wait_fake_time/cv::getTickFrequency();
+            if(total_fake_time > wait_fake){
+                datafusion(res);
+            }
+        }
 
-        if(show_flag){
-            cv::Mat mat;
-            imageBuffer->consume(mat);
+        cv::Mat mat;
+        imageBuffer->consume(mat);
 
+        if(show_flag){
             // Draw bounding boxes
             draw_bbox(mat, res);
             cv::namedWindow("camera_obs",cv::WINDOW_NORMAL);

+ 1 - 1
src/detection/vision_yolov8/main.cpp

@@ -46,7 +46,7 @@ float METER_PER_PIXEL_X,METER_PER_PIXEL_Y;
 float BOARD_SIDE_LENGTH_X = 7.5;
 float BOARD_SIDE_LENGTH_Y = 50.0;
 float X = 0.0;
-float Y = 4.0;
+float Y = 3.0;
 
 // string video_path = "v4l2src device=/dev/video0 ! video/x-raw, width=(int)1280, height=(int)720 ! videoconvert ! appsink";
 string video_path = "/home/nvidia/Videos/video.mp4";