I have two Yocto builds running on different processors, I am trying to write an OpenCV code with GStreamer, one of which will send the packet and other to receive. The problem I am facing is that in the receiver script the program gets stuck at ‘VideoCapture’ function and does not execute further. The receiver is connected with an HDMI screen, after running the object file there is no change on the monitor. Below I am attaching the code.
#include <iostream>
#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
using namespace std;
using namespace cv;
int main(void)
{
cout<<"in main function"<<endl;
const char* gstrec="udpsrc port=5000 ! application/x-rtp,media=video,encoding-name=H264,payload=96,clock-rate=90000,framerate=30/1 ! \
rtpjitterbuffer latency=10 drop-on-latency=TRUE ! rtph264depay ! video/x-h264 ! h264parse ! decodebin ! video/x-raw,\
format=NV12 ! videoconvert ! video/x-raw,format=BGR ! appsink";
cout<<"Gstreamer script running"<<endl;
VideoCapture cap(gstrec,CAP_GSTREAMER);
cout<<"You are out of VideoCapture function"<<endl;
if(!cap.isOpened())
{
cout<<"VideoCapture not opened"<<endl;
exit(-1);
}
cout<<"The videocapture is opened"<<endl;
Mat frame;
for(;;) {
cap.read(frame);
if(frame.empty())
break;
cout<<"In while loop"<<endl;
imshow("Receiver", frame);
if(waitKey(1) == 'r')
break;
}
destroyWindow("Receiver");
return 0;
}
Here is the output:
in main function
Gstreamer script running
[INFO] bitstreamMode 1, chromaInterleave 0, mapType 0, tiled2LinearEnable 0
Notice that the ‘cout << you are out of videocapture’ statement does not print on the screen and display that is connected to the receiver shows no changes