فهرست منبع

change driver_camera_usb, use image/jpeg improve velocity. so driver_camera_usb is ok.

yuchuli 4 سال پیش
والد
کامیت
f87c6bff4f
2فایلهای تغییر یافته به همراه11 افزوده شده و 5 حذف شده
  1. 10 4
      src/driver/driver_camera_usb/main.cpp
  2. 1 1
      src/tool/picview/mainwindow.cpp

+ 10 - 4
src/driver/driver_camera_usb/main.cpp

@@ -5,8 +5,8 @@
 #include <opencv2/core.hpp>
 
 #ifdef USE_OPENCV4
-//#include "opencv2/imgcodecs/legacy/constants_c.h"   //OpenCV4 use this line
-//#include <opencv2/imgproc/types_c.h>   //OpenCV4 use this line
+#include "opencv2/imgcodecs/legacy/constants_c.h"   //OpenCV4 use this line
+#include <opencv2/imgproc/types_c.h>   //OpenCV4 use this line
 #endif
 
 #include <opencv2/videoio.hpp>
@@ -56,12 +56,18 @@ void VideoThread(int n)
 //If OpenCV4 use this
 //    std::string gst_f = "v4l2src device=/dev/video0 ! video/x-raw, width=(int)"+std::to_string(gwidth)+", height=(int)"+std::to_string(gheight)+" ! videoconvert ! appsink";
     std::string gstr_f = "v4l2src device=/dev/video"+std::to_string(gcamindex)+" ! video/x-raw, width=(int)"+std::to_string(gwidth)+", height=(int)"+std::to_string(gheight)+" ! videoconvert ! appsink";
+
+//    std::string gstr_f = "v4l2src device=/dev/video"+std::to_string(gcamindex)+" ! image/jpeg, width=(int)"+std::to_string(gwidth)+", height=(int)"+std::to_string(gheight)+"  framerate=(fraction)30/1 ! jpegdec ! appsink";
+
 //    capture.open(gstr_f);
 
 #ifdef USE_OPENCV4
     if(gstrcamera.length() > 2)
     {
         gstr_f = "v4l2src device=/dev/"+gstrcamera+" ! video/x-raw, width=(int)"+std::to_string(gwidth)+", height=(int)"+std::to_string(gheight)+" ! videoconvert ! appsink";
+        std::cout<<gstr_f<<std::endl;
+        gstr_f = "v4l2src device=/dev/"+gstrcamera+" ! image/jpeg, width=(int)"+std::to_string(gwidth)+", height=(int)"+std::to_string(gheight)+",pixel-aspect-ratio=(fraction)1/1,framerate=(fraction)30/1 ! jpegdec ! videoconvert ! appsink";
+        std::cout<<gstr_f<<std::endl;
         capture.open(gstr_f);
     }
     else
@@ -71,8 +77,8 @@ void VideoThread(int n)
 
         capture.open(gcamindex);
 #endif
-    capture.set(CV_CAP_PROP_FRAME_WIDTH,gwidth);
-    capture.set(CV_CAP_PROP_FRAME_HEIGHT,gheight);
+//    capture.set(CV_CAP_PROP_FRAME_WIDTH,gwidth);
+//    capture.set(CV_CAP_PROP_FRAME_HEIGHT,gheight);
     while(true)
     {
         cv::Mat mat1;

+ 1 - 1
src/tool/picview/mainwindow.cpp

@@ -5,7 +5,7 @@
 
 #include <opencv2/imgproc.hpp>
 
-//#include "opencv2/imgcodecs/legacy/constants_c.h"
+#include "opencv2/imgcodecs/legacy/constants_c.h"
 #include <opencv2/imgproc/types_c.h>
 
 #include "xmlparam.h"