This post was updated on .
Hi all,
I use try to use the procedure “v4l2(V4L2_PIX_FMT_YUYV)->opencv mat->(do something)->gstreamer”. v4l2->gstreamerI think the pipeline is ok, cause i have used it to show v4l2 YUY2 format. Like v4l2 (V4L2_PIX_FMT_YUYV) -> cv::Mat mat = cv::Mat(480,640,CV_8UC2,(void*)fbuffer1); -> wrapped_mem1 = gst_memory_new_wrapped( (GstMemoryFlags)0, (gpointer) fbuffer1, *len* , 0, *len* , NULL, NULL); -> g_object_set(G_OBJECT(gst_handle->src), "caps", gst_caps_new_simple("video/x-raw", "format", G_TYPE_STRING, "YUY2", "width", G_TYPE_INT, cmdline.width, "height", G_TYPE_INT, cmdline.s_height, "framerate", GST_TYPE_FRACTION, 30, 1, NULL), NULL); v4l2->mat->do something -> appsrcwhen i try to do some thing to mat and stream it out. There is the problem... len=640*480*2 ---------------------------------------------------------------------------------------------------------------- memcpy(fbuffer1, (((unsigned char *) (cap_ptr[0])) ), *len*); //fbuffer1 is the unsigned char * reference at v4l2_capture_buffer.ptr cv::Mat mat = cv::Mat(480,640,CV_8UC2,(void*)fbuffer1); cv::Mat rgb_mat; cv::cvtColor(mat,rgb_mat,cv::COLOR_YUV2BGR_YUY2); //***************do something***********************************************// cv::cvtColor(rgb_cv,rgb_cv,CV_BGR2YUV_I420); wrapped_mem1 = gst_memory_new_wrapped( (GstMemoryFlags)0, (gpointer) rgb_cv.data, *len* , 0, *len* , NULL, NULL); gst_buffer_append_memory(buffer1, wrapped_mem1); g_signal_emit_by_name(gst_handle1->src, "push-buffer", buffer1, &ret1); ------------------------------------------------------------------------------------------------------------- #define PIPELINE "appsrc name=mysource !" \ " video/x-raw,width=%d,height=%d ! "\ " videoconvert ! xvimagesink " gst_handle->src = gst_bin_get_by_name (GST_BIN(gst_handle->pipeline), "mysource"); gst_handle->width = cmdline.width; gst_handle->height = cmdline.height; g_object_set(G_OBJECT(gst_handle->src), "caps", gst_caps_new_simple("video/x-raw", "format", G_TYPE_STRING, "I420", "width", G_TYPE_INT, cmdline.width, "height", G_TYPE_INT, cmdline.s_height, "framerate", GST_TYPE_FRACTION, 30, 1, NULL), NULL); ------------------------------------------------------------------------------------------------------------- The process crash at "gst_memory_new_wrapped" so many times but some time it will be OK. Some things beyond the topicIf i just use the mat has been converted to BGR and stream it out. I don't know why the xvimagesink show all GREEN. Thank for you focus. -- Sent from: http://gstreamer-devel.966125.n4.nabble.com/ _______________________________________________ gstreamer-devel mailing list gstreamer-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
v4l2->gstreamer
is OK, nothing is wrong v4l2->mat->do something -> appsrc According to that /The process crash at "gst_memory_new_wrapped" so many times but some time it will be OK./ . The true is that, the process did not crash at "gst_memory_new_wrapped". It crash at "g_signal_emit_by_name". Cause when i send the mat to appsrc buffer. The thread own mat.data destruct himself when the function loop again, it's a fundamental of opencv. So i forget that, when appsrc need the buffer, it can't access it or wrong format. Some things beyond the topic I think the screen is GREEN as of the size of "GstMemory" warped opencv mat is not correct, may there is other reason for that. -- Sent from: http://gstreamer-devel.966125.n4.nabble.com/ _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Free forum by Nabble | Edit this page |