Hi, I have a problem when using the HDMI2CSI module within OpenCV. I test it in the following platform:
(1) Platform: TX2
(2) OpenCV: 3.1 with cap_gstreamer support (gst version: 1.8.3)
(3) HDMI2CSI Driver: Image_28-1_hdmi2csi
(4) HDMI Input: the HDMI output of another PC
Before using OpenCV for testing, the commands used in https://github.com/InES-HPMM/linux-l4t-4.4/wiki/hdmi2csi#examples (using gst-launch-1.0) are test, and I found that these commands work very well. Then I use OpenCV to capture the gst-pipeline-stream. The code is very easy and shown below:
################################################################################
static const string PIPELINE_NAME = "v4l2src device=/dev/video0 ! video/x-raw, width=1920, height=1280, framerate=60/1, format=UYVY ! nvvidconv ! video/x-raw, format=BGRx ! videoconvert ! appsink sync=false";
class HdmiInputStreamer {
public:
static boost::shared_ptr Get() {
static boost::shared_ptr ptr;
if (! ptr) {
ptr.reset(new HdmiInputStreamer());
}
return ptr;
}
// output frame
void pop(cv::Mat* image) {
cap_ >> *image;
}
// show
void show() {
while (1) {
cv::Mat image;
pop(&image);
cv::namedWindow("HdmiInputStreamer", WINDOW_AUTOSIZE);
cv::imshow("HdmiInputStreamer", image);
cv::waitKey(1);
}
}
~HdmiInputStreamer() {
if (cap_.isOpened()) {
cap_.release();
}
}
private:
cv::VideoCapture cap_;
std::string pipeline_;
HdmiInputStreamer() {
pipeline_ = PIPELINE_NAME;
while(! cap_.open(pipeline_)) {
LOG(INFO) << "The hdmi input stream is unreachable, please check and wait ...";
// sleep
sleep(1000);
}
}
};
################################################################################
I use HdmiInputStreamer()::Get()->show() to display the input HDMI Stream, and the ERROR is shown below:
GStreamer Plugin: Embedded video playback halted; module v4l2src0 reported: Internal data flow error.
OpenCV Error: Unspecified error (GStreamer: unable to start pipeline
) in cvCaptureFromCAM_GStreamer, file /home/nvidia/Downloads/opencv_liliang/opencv/modules/videoio/src/cap_gstreamer.cpp, line 818
terminate called after throwing an instance of 'cv::Exception'
what(): /home/nvidia/Downloads/opencv_liliang/opencv/modules/videoio/src/cap_gstreamer.cpp:818: error: (-2) GStreamer: unable to start pipeline
in function cvCaptureFromCAM_GStreamer
Aborted (core dumped)
I have also tested some other pipelines with different names:
(1) "v4l2src device=/dev/video0 ! video/x-raw, width=1920, height=1280, framerate=60/1, format=UYVY ! nvvidconv ! video/x-raw(memory:NVMM), format=BGRx ! videoconvert ! appsink sync=false"
(video.bin:3726): GStreamer-CRITICAL **: gst_mini_object_copy: assertion 'mini_object != NULL' failed
(video.bin:3726): GStreamer-CRITICAL **: gst_caps_get_structure: assertion 'GST_IS_CAPS (caps)' failed
(video.bin:3726): GStreamer-CRITICAL **: gst_structure_copy: assertion 'structure != NULL' failed
(video.bin:3726): GStreamer-CRITICAL **: gst_caps_append_structure_full: assertion 'GST_IS_CAPS (caps)' failed
(video.bin:3726): GStreamer-CRITICAL **: gst_caps_get_structure: assertion 'GST_IS_CAPS (caps)' failed
(video.bin:3726): GStreamer-CRITICAL **: gst_structure_copy: assertion 'structure != NULL' failed
(video.bin:3726): GStreamer-CRITICAL **: gst_caps_append_structure_full: assertion 'GST_IS_CAPS (caps)' failed
(video.bin:3726): GStreamer-CRITICAL **: gst_mini_object_unref: assertion 'mini_object != NULL' failed
(video.bin:3726): GStreamer-CRITICAL **: gst_mini_object_ref: assertion 'mini_object != NULL' failed
GStreamer Plugin: Embedded video playback halted; module v4l2src0 reported: Internal data flow error.
OpenCV Error: Unspecified error (GStreamer: unable to start pipeline
) in cvCaptureFromCAM_GStreamer, file /home/nvidia/Downloads/opencv_liliang/opencv/modules/videoio/src/cap_gstreamer.cpp, line 818
terminate called after throwing an instance of 'cv::Exception'
what(): /home/nvidia/Downloads/opencv_liliang/opencv/modules/videoio/src/cap_gstreamer.cpp:818: error: (-2) GStreamer: unable to start pipeline
in function cvCaptureFromCAM_GStreamer
Aborted (core dumped)
(2) "v4l2src device=/dev/video0 ! video/x-raw, width=1920, height=1280, framerate=60/1, format=I420 ! nvvidconv ! video/x-raw(memory:NVMM), format=BGRx ! videoconvert ! appsink sync=false"
#The same error as (1)#
(3) "v4l2src device=/dev/video0 ! video/x-raw, width=1920, height=1280, framerate=60/1, format=I420 ! nvvidconv ! video/x-raw, format=BGRx ! videoconvert ! appsink sync=false"
./build/tools/video.bin
GStreamer Plugin: Embedded video playback halted; module v4l2src0 reported: Internal data flow error.
OpenCV Error: Unspecified error (GStreamer: unable to start pipeline
) in cvCaptureFromCAM_GStreamer, file /home/nvidia/Downloads/opencv_liliang/opencv/modules/videoio/src/cap_gstreamer.cpp, line 818
terminate called after throwing an instance of 'cv::Exception'
what(): /home/nvidia/Downloads/opencv_liliang/opencv/modules/videoio/src/cap_gstreamer.cpp:818: error: (-2) GStreamer: unable to start pipeline
in function cvCaptureFromCAM_GStreamer
Aborted (core dumped)
#The same error as in main test situation#
(4) "v4l2src device=/dev/video0 ! video/x-raw, width=1920, height=1280, framerate=60/1, format=UYVY ! nvvidconv ! video/x-raw, format=BGRx ! videoconvert ! video/x-raw, format=BGR ! appsink sync=false"
#The same error as in main test situation#
I am not sure what the problem is, and any help are appreciated!