Browse Source

modified read4usb

liyupeng 8 months ago
parent
commit
ae3d6b66b8

+ 11 - 1
src/detection/sensordata_save_orin/main.cpp

@@ -355,9 +355,19 @@ int main(int argc, char *argv[])
             imageBuffer_left->isEmpty()|| imageBuffer_right->isEmpty() || imageBuffer_middle->isEmpty())
         {
 
-            std::cout<<"Wait data"<<std::endl;
+            std::cout<<"##############Wait data################"<<std::endl;
             if(imageBuffer_middle->isEmpty())
                 std::cout<<"middle senyun image is empty"<<std::endl;
+            if(imageBuffer_front->isEmpty())
+                std::cout<<"front image is empty"<<std::endl;
+            if(imageBuffer_back->isEmpty())
+                std::cout<<"back image is empty"<<std::endl;
+            if(imageBuffer_left->isEmpty())
+                std::cout<<"left image is empty"<<std::endl;
+            if(imageBuffer_right->isEmpty())
+                std::cout<<"right is empty"<<std::endl;
+            if(pcdBuffer_middle->isEmpty())
+                std::cout<<"pointcloud is empty"<<std::endl;
 
             std::this_thread::sleep_for(std::chrono::milliseconds(1));
             continue;

+ 54 - 16
src/driver/read4usb/main_new.cpp

@@ -52,6 +52,12 @@ int gindex_right = 0;
 std::string gio_method_name_, gpixel_format_name_, gcamera_name_, gcamera_info_url_;
 std::string device_front,device_back,device_left,device_right;
 std::string gmsgname_front, gmsgname_back, gmsgname_left, gmsgname_right;
+bool open_front,open_back,open_left,open_right;
+
+std::thread * mthread1;
+std::thread * mthread2;
+std::thread * mthread3;
+std::thread * mthread4;
 //std::string start_service_name_, start_service_name_;
 bool gstreaming_status_;
 int gimage_width_, gimage_height_, gframerate_, gexposure_, gbrightness_, gcontrast_, gsaturation_, gsharpness_, gfocus_,
@@ -206,6 +212,8 @@ void threadcapture(std::string devicename,void * pHandle)
             bool bser = pic.SerializeToArray(strser,nSize);
             qDebug("pac time is %d size is %d",xg.elapsed(),nSize);
 
+            std::cout<<"read "<<devicename<<std::endl;
+
             if(bser)iv::modulecomm::ModuleSendMsg(pHandle,strser,nSize);
             else
             {
@@ -256,6 +264,11 @@ int main(int argc, char *argv[])
     device_left = xp.GetParam("left", std::string("/dev/video4"));
     device_right = xp.GetParam("right", std::string("/dev/video6"));
 
+    open_front = xp.GetParam("open_front", true);
+    open_back = xp.GetParam("open_back", true);
+    open_left = xp.GetParam("open_left", true);
+    open_right = xp.GetParam("open_right", true);
+
 
     gbrightness_ =  xp.GetParam("brightness",  -1); //0-255, -1 "leave alone"
     gcontrast_ = xp.GetParam("contrast",  -1); //0-255, -1 "leave alone"
@@ -283,29 +296,54 @@ int main(int argc, char *argv[])
     gbuserawmjpeg = xp.GetParam("use_rawmjpeg",true);
     gbcompress = xp.GetParam("bcompress",true);
 
-    gpa_front = iv::modulecomm::RegisterSend(gmsgname_front.data(),1000000,1);
-    std::thread * mthread1 =  new  std::thread(threadcapture,device_front,gpa_front);//new std::thread(VideoThread,0);
+    if(open_front)
+    {
+        gpa_front = iv::modulecomm::RegisterSend(gmsgname_front.data(),1000000,1);
+        mthread1 =  new  std::thread(threadcapture,device_front,gpa_front);//new std::thread(VideoThread,0);
+    }
+
+    if(open_back)
+    {
+        gpa_back = iv::modulecomm::RegisterSend(gmsgname_back.data(),1000000,1);
+        mthread2 =  new  std::thread(threadcapture,device_back,gpa_back);//
+    }
+
+
+    if(open_left)
+    {
+        gpa_left = iv::modulecomm::RegisterSend(gmsgname_left.data(),1000000,1);
+        mthread3 =  new  std::thread(threadcapture,device_left,gpa_left);//
+    }
+
 
-    gpa_back = iv::modulecomm::RegisterSend(gmsgname_back.data(),1000000,1);
-    std::thread * mthread2 =  new  std::thread(threadcapture,device_back,gpa_back);//
+    if(open_right)
+    {
+        gpa_right = iv::modulecomm::RegisterSend(gmsgname_right.data(),1000000,1);
+        mthread4 =  new  std::thread(threadcapture,device_right,gpa_right);//
+    }
 
-    gpa_left = iv::modulecomm::RegisterSend(gmsgname_left.data(),1000000,1);
-    std::thread * mthread3 =  new  std::thread(threadcapture,device_left,gpa_left);//
+    if(open_front)
+        (void)mthread1;
+    if(open_back)
+        (void)mthread2;
+    if(open_left)
+        (void)mthread3;
+    if(open_right)
+        (void)mthread4;
 
-    gpa_right = iv::modulecomm::RegisterSend(gmsgname_right.data(),1000000,1);
-    std::thread * mthread4 =  new  std::thread(threadcapture,device_right,gpa_right);//
 
-    (void)mthread1;
-    (void)mthread2;
-    (void)mthread3;
-    (void)mthread4;
     iv::ivexit::RegIVExitCall(ExitFunc);
     signal(SIGINT,signal_handler);
     int nrc = a.exec();
-    iv::modulecomm::Unregister(gpa_front);
-    iv::modulecomm::Unregister(gpa_back);
-    iv::modulecomm::Unregister(gpa_left);
-    iv::modulecomm::Unregister(gpa_right);
+
+    if(open_front)
+        iv::modulecomm::Unregister(gpa_front);
+    if(open_back)
+        iv::modulecomm::Unregister(gpa_back);
+    if(open_left)
+        iv::modulecomm::Unregister(gpa_left);
+    if(open_right)
+        iv::modulecomm::Unregister(gpa_right);
     std::cout<<"driver_camera_ioctl quit."<<nrc<<std::endl;
 
     return nrc;

+ 8 - 4
src/driver/read4usb/read4usb.xml

@@ -8,9 +8,13 @@
 		<param name="image_height" value="720" />
 		<param name="use_rawmjpeg" value = "true" />
 		<param name="framerate" value="30" />
-		<param name="front" value="/dev/video0" />
-		<param name="back" value="/dev/video2" />
-		<param name="left" value="/dev/video4" />
-		<param name="right" value="/dev/video6" />
+		<param name="front" value="/dev/video8" />
+		<param name="back" value="/dev/video10" />
+		<param name="left" value="/dev/video12" />
+		<param name="right" value="/dev/video14" />
+		<param name="open_front" value="true" />
+		<param name="open_back" value="true" />
+		<param name="open_left" value="true" />
+		<param name="open_right" value="true" />
 	</node>
 </xml>