|
@@ -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;
|