我正在尝试从UVC相机中提取图像,该相机已翻转并旋转,因此我需要旋转,裁剪和翻转,然后执行以下操作: 1.将编码的jpeg流转发到其他目标 2.通过app-sink使用数据。
我有以下管道:
gst-launch-1.0 v4l2src name=source extra-
controls=\"c,zoom_absolute=100\" device=/dev/video1 ! capsfilter
caps=\"video/x-raw,width=1280,height=720\" name=first_caps !
aspectratiocrop aspect-ratio=3/4 name=ap_crop ! imxipuvideotransform
output-rotation=1 name=rotate ! capsfilter caps=\"video/x-
raw,format=I420,width=640,height=480\" name=second_caps ! videoflip
video-direction=4 name=flip ! tee name=t t. ! queue ! jpegenc !
rtpjpegpay ! udpsink host=192.168.10.107 port=5000 name=udp_sink t.
! queue ! appsink name=app_sink
仅当我进行翻转时此管道才有效,但是如果我在“ flip”元素上使用video-direction = 0,则会得到:
assertion failed: (phys_mem->mapped_virt_addr == NULL)
在appsink中,我仅使用“新样本”回调将数据复制到本地缓冲区。
有人可以理解问题吗?
给我们回调函数:
static GstFlowReturn PullBuffer (GstElement *sink, CustomData *data) {
GstSample *sample;
/* Retrieve the buffer */
g_signal_emit_by_name (sink, "pull-sample", &sample);
if (sample) {
data->isNew = true;
// Actual compressed image is stored inside GstSample.
GstBuffer* buffer = gst_sample_get_buffer (sample);
GstMapInfo map;
gst_buffer_map (buffer, &map, GST_MAP_READ);
// Copy image
memcpy(data->image->data(), map.data, data->size);
gst_buffer_unmap (buffer, &map);
gst_sample_unref (sample);
return GST_FLOW_OK;
}
return GST_FLOW_ERROR;
}
谢谢!