GstBuffer着色Mat [英] GstBuffer to color Mat
问题描述
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));
我可以拉缓冲区并转换为OpenCv Mat对象,但是灰度。我想拉缓冲区的颜色。我知道我的流是在终端的颜色创建相同的管道。我搜索了一个解决方案没有成功。我使用gstreamer-0.10和opencv-2.4.10。
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.
推荐答案
最后在这篇文章的帮助下更改cv :: Mat与从缓冲区复制的图片影响原始图片我可以拉颜色的缓冲区。现在的缓冲区的大小是有意义的,640 * 360 * 3。
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.
我不得不链接到一个不同的方式,appink与ffmpegcolorspace元素:
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))
然后拉取缓冲区时:
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);
这篇关于GstBuffer着色Mat的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!