Reputation: 129
GstBuffer *gstImageBuffer = gst_app_sink_pull_buffer((GstAppSink*)app_data.gst_data.sink);
Mat matLeft = Mat(Size(width, height),CV_8U, (char*)GST_BUFFER_DATA(gstImageBuffer));
I can pull the buffer and convert to a OpenCv Mat object, but in grayscale. I want to pull the buffer in color. I know my stream is in color creating the same pipeline in the terminal. I've searched for a solution without success. I am using gstreamer-0.10 and opencv-2.4.10.
Upvotes: 1
Views: 3693
Reputation: 129
Finally with the help of this post Changing cv::Mat with image copied from buffer affects original image I can pull the buffer in color. Now the size of the buffer make sense, 640*360*3.
I had to link in a different way the appsink with the ffmpegcolorspace element:
gst_element_link_filtered(data->gst_data.converter, data->gst_data.sink, gst_caps_new_simple("video/x-raw-rgb", NULL))
And then when pulling the buffer:
gstImageBuffer = gst_app_sink_pull_buffer((GstAppSink*)app_data.gst_data.sink);
matLeft = Mat(Size(width, height), CV_8UC3, (char*)GST_BUFFER_DATA(gstImageBuffer));
cvtColor(matLeft, matLeft, CV_RGB2BGR);
Upvotes: 1