I use gstreamer and nvv4l2decoder to read rtsp stream into opencv,and show it.my code like this:
std::string pipe = "rtspsrc location=rtsp://localhost:8554/001 ! rtph264depay ! h264parse ! nvv4l2decoder ! nvvideoconvert ! appsink";
VideoCapture cap(pipe, CAP_GSTREAMER);
if (!cap.isOpened()) {
cerr <<"VideoCapture not opened!"<<endl;
exit(-1);
}
while (true) {
Mat frame;
Mat out_frame;
cap.read(frame);
cv::imshow("demo test", frame);
if (cv::waitKey(3) > 0)
break;
}
but ,I got a gray image !
I try to modify code like this:
cap.read(frame);
// cv::cvtColor (frame, out_frame, cv::COLOR_RGBA2BGR);
//frame=cv::cvtColor(frame,cv::COLOR_RGBA2BGRA)
#if (CV_MAJOR_VERSION >= 4)
cv::cvtColor (frame, out_frame, cv::COLOR_RGBA2BGR);
#else
cv::cvtColor (frame, out_frame, cv::CV_RGBA2BGR);
#endif
//imwrite("receiver.png", frame);
cv::imshow("demo test", out_frame);
but ,it still gray !(I try difference rtsp source also)
so ,how to change it to normal ?