OpenCv Mat to GstBuffer -> appsrc, possible buffer underflow?
borisRobson
brandon.robsonclarke at paxton.co.uk
Fri Feb 3 13:06:19 UTC 2017
Hi all
I have a project which aims to de-warp a fisheye camera, using two gstreamer
pipelines with opencv processing in between:
| input-pipe | OpenCV processing
| output-pipe
| rtsprc -> decodebin -> appsink | gst-buf -> cvMat -> gstbuf | appsrc
-> videoparse -> videoconvert ->
xvimagesink
I can save the image from the cvMat and the result is as I expect, however
the image shown in xvimagesink is grayscale and constantly shifting upwards
and to the left. (Best I could do on description there)
<http://gstreamer-devel.966125.n4.nabble.com/file/n4681701/xvimagesink.png>
<http://gstreamer-devel.966125.n4.nabble.com/file/n4681701/dewarped.png>
The code where I suspect the problem is:
(conv is the Mat shown in the attached image)
//get outputize & allocate mem block
gint outSize = conv.cols * conv.rows * inBpp;
GstMemory *outMem = gst_allocator_alloc(NULL, outSize, NULL);
//assign frame data to mem
GstMapInfo outMap;
if(!gst_memory_map(outMem, &outMap, GST_MAP_WRITE))
{
g_printerr("could not map outMem\n");
return;
}
memcpy(outMap.data, conv.data, outMap.size);
gst_memory_unmap(outMem, &outMap);
GstBuffer *outbuf;
outbuf = gst_buffer_new();
gst_buffer_insert_memory(outbuf, -1,outMem);
GstVideoMeta *outmeta = new GstVideoMeta();
outmeta = gst_buffer_add_video_meta(outbuf,GST_VIDEO_FRAME_FLAG_NONE,
GST_VIDEO_FORMAT_RGB, conv.cols, conv.rows );
//set timestamp values
GST_BUFFER_DURATION(outbuf) = (GstClockTime)40000000;
GST_BUFFER_DTS(outbuf) = GST_CLOCK_TIME_NONE;
GST_BUFFER_PTS(outbuf) = timestamp;
timestamp += GST_BUFFER_DURATION(outbuf);
GST_BUFFER_FLAG_SET(outbuf, GST_BUFFER_FLAG_LIVE);
//ref buffer to give copy to appsrc
gst_buffer_ref(outbuf);
GstFlowReturn ret;
ret = gst_app_src_push_buffer((GstAppSrc*)asrc, outbuf);
if(ret != GST_FLOW_OK)
{
g_printerr("could not push buffer\n");
g_printerr("ret enum: %i\n", ret);
}
//dec. ref count so that we can edit data on next run
gst_buffer_unref(outbuf);
I have tried adding extra conversion stages in my out-pipe but to no effect.
Has anyone had experience with this before or is able to spot some rookie
error I'm making?
Thanks
Brandon
--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/OpenCv-Mat-to-GstBuffer-appsrc-possible-buffer-underflow-tp4681701.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.
More information about the gstreamer-devel
mailing list