#include #include #include #include //#include "opencv2/imgcodecs/legacy/constants_c.h" #include #include "rawpic.pb.h" #include "modulecomm.h" #include #include #include #include "zerobuffer.h" ZeroBuffer * gbuffer; extern char * gstrbuffer; extern QMutex gMutexLock; extern bool gbNewData; extern QWaitCondition gwc; static char * gstrwidth ="1920"; static char * gstrheight = "1080"; int gnwidth,gnheight; void StartNVENC(char * strwidth,char * strheight); extern bool gbNewOut; extern QWaitCondition gwcout; extern char * gstrout; extern QMutex gWaitMutexout; extern QMutex gMutexout; extern int gnoutsize ; void * gpaout; void threadout() { char * strout = new char[10000000]; int nout = 0; while(1) { gWaitMutexout.lock(); gwcout.wait(&gWaitMutexout,10); gWaitMutexout.unlock(); if(gbNewOut) { gMutexout.lock(); memcpy(strout, gstrout,gnoutsize); nout = gnoutsize; gbNewOut = false; gMutexout.unlock(); // std::cout<<"send out. "< buff(pic.picdata().data(),pic.picdata().data()+pic.picdata().size()); mat = cv::imdecode(buff,1); } cv::Mat dstYuvImage; QTime xTime; xTime.start(); cv::cvtColor(mat, dstYuvImage, CV_BGR2YUV_I420); // std::cout<<" cvt time: "<RequireBuffer(&p,1000); if(nrtn < 0) { std::cout<<" Get Zero Buffer Fail."<UpdateDataSize(gnwidth*gnheight*3/2); gbuffer->ReleaseBuffer(); // gMutexLock.lock(); // memcpy(gstrbuffer,(char *)dstYuvImage.data,gnwidth*gnheight*3/2); // gbNewData = true; // gMutexLock.unlock(); // gwc.wakeAll(); // xFileYUV.write((char *)dstYuvImage.data,gwidth*gheight*3/2); } int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); gbuffer = new ZeroBuffer(30000000); gstrbuffer = new char[30000000]; gstrout = new char[10000000]; gnwidth = atoi(gstrwidth); gnheight = atoi(gstrheight); gpaout = iv::modulecomm::RegisterSend("h264frame",1000000,1); void * pthread = new std::thread(threadout); void * pa = iv::modulecomm::RegisterRecv("picfront",Listenpic); StartNVENC(gstrwidth,gstrheight); return a.exec(); }