|
@@ -12,6 +12,9 @@
|
|
|
#include <opencv2/videoio.hpp>
|
|
|
|
|
|
#include <QTime>
|
|
|
+#include <QFile>
|
|
|
+
|
|
|
+#define TESTYUV 1
|
|
|
|
|
|
#include "modulecomm.h"
|
|
|
#include "rawpic.pb.h"
|
|
@@ -47,12 +50,27 @@ void VideoThread(int n)
|
|
|
{
|
|
|
QTime xT;
|
|
|
xT.start();
|
|
|
+ int ncount = 0;
|
|
|
int nserbufsize = 20000000;
|
|
|
|
|
|
char * strser = new char[nserbufsize];
|
|
|
|
|
|
cv::VideoCapture capture;
|
|
|
|
|
|
+#ifdef TESTYUV
|
|
|
+ QFile xFileYUV;
|
|
|
+ xFileYUV.setFileName("/home/nvidia/testYUV.yuv");
|
|
|
+ bool bTestYUV = false;
|
|
|
+ if(xFileYUV.open(QIODevice::ReadWrite))
|
|
|
+ {
|
|
|
+ bTestYUV = true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ std::cout<<" Open YUV File Fail."<<std::endl;
|
|
|
+ }
|
|
|
+#endif
|
|
|
+
|
|
|
//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";
|
|
@@ -66,8 +84,8 @@ void VideoThread(int n)
|
|
|
{
|
|
|
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;
|
|
|
+// 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
|
|
@@ -85,10 +103,21 @@ void VideoThread(int n)
|
|
|
capture>>mat1;
|
|
|
|
|
|
|
|
|
-
|
|
|
if(!mat1.empty())
|
|
|
{
|
|
|
|
|
|
+#ifdef TESTYUV
|
|
|
+ if(bTestYUV &&(ncount<11))
|
|
|
+ {
|
|
|
+ cv::Mat dstYuvImage;
|
|
|
+ cv::cvtColor(mat1, dstYuvImage, CV_BGR2YUV_I420);
|
|
|
+ xFileYUV.write((char *)dstYuvImage.data,gwidth*gheight*3/2);
|
|
|
+ xFileYUV.flush();
|
|
|
+ }
|
|
|
+#endif
|
|
|
+
|
|
|
+ ncount++;
|
|
|
+ std::cout<<" count "<<ncount<<std::endl;
|
|
|
QTime timex;
|
|
|
timex.start();
|
|
|
// int nlen = 2+3*sizeof(int) + mat1.rows*mat1.cols*mat1.elemSize();
|
|
@@ -214,8 +243,8 @@ int main(int argc, char *argv[])
|
|
|
showversion("driver_camera_usb");
|
|
|
QCoreApplication a(argc, argv);
|
|
|
|
|
|
- std::thread * pthread = new std::thread(testthread);
|
|
|
- return a.exec();
|
|
|
+// std::thread * pthread = new std::thread(testthread);
|
|
|
+// return a.exec();
|
|
|
|
|
|
QString strpath = QCoreApplication::applicationDirPath();
|
|
|
// QString apppath = strpath;
|