mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 10:11:08 +00:00
opencv: port baseclass to 0.11
This commit is contained in:
parent
b78b980d72
commit
181be8d52b
2 changed files with 37 additions and 22 deletions
|
@ -96,31 +96,31 @@ gst_opencv_parse_iplimage_params_from_caps (GstCaps * caps, gint * width,
|
|||
GstCaps *
|
||||
gst_opencv_caps_from_cv_image_type (int cv_type)
|
||||
{
|
||||
GstCaps *caps = gst_caps_new_empty ();
|
||||
GstCaps *c = gst_caps_new_empty ();
|
||||
switch (cv_type) {
|
||||
case CV_8UC1:
|
||||
gst_caps_append (caps, gst_caps_from_string (GST_VIDEO_CAPS_GRAY8));
|
||||
gst_caps_append (c, gst_caps_from_string (GST_VIDEO_CAPS_MAKE ("GRAY8")));
|
||||
break;
|
||||
case CV_8UC3:
|
||||
gst_caps_append (caps, gst_caps_from_string (GST_VIDEO_CAPS_RGB));
|
||||
gst_caps_append (caps, gst_caps_from_string (GST_VIDEO_CAPS_BGR));
|
||||
gst_caps_append (c, gst_caps_from_string (GST_VIDEO_CAPS_MAKE ("RGB")));
|
||||
gst_caps_append (c, gst_caps_from_string (GST_VIDEO_CAPS_MAKE ("BGR")));
|
||||
break;
|
||||
case CV_8UC4:
|
||||
gst_caps_append (caps, gst_caps_from_string (GST_VIDEO_CAPS_RGBx));
|
||||
gst_caps_append (caps, gst_caps_from_string (GST_VIDEO_CAPS_xRGB));
|
||||
gst_caps_append (caps, gst_caps_from_string (GST_VIDEO_CAPS_BGRx));
|
||||
gst_caps_append (caps, gst_caps_from_string (GST_VIDEO_CAPS_xBGR));
|
||||
gst_caps_append (caps, gst_caps_from_string (GST_VIDEO_CAPS_RGBA));
|
||||
gst_caps_append (caps, gst_caps_from_string (GST_VIDEO_CAPS_ARGB));
|
||||
gst_caps_append (caps, gst_caps_from_string (GST_VIDEO_CAPS_BGRA));
|
||||
gst_caps_append (caps, gst_caps_from_string (GST_VIDEO_CAPS_ABGR));
|
||||
gst_caps_append (c, gst_caps_from_string (GST_VIDEO_CAPS_MAKE ("RGBx")));
|
||||
gst_caps_append (c, gst_caps_from_string (GST_VIDEO_CAPS_MAKE ("xRGB")));
|
||||
gst_caps_append (c, gst_caps_from_string (GST_VIDEO_CAPS_MAKE ("BGRx")));
|
||||
gst_caps_append (c, gst_caps_from_string (GST_VIDEO_CAPS_MAKE ("xBGR")));
|
||||
gst_caps_append (c, gst_caps_from_string (GST_VIDEO_CAPS_MAKE ("RGBA")));
|
||||
gst_caps_append (c, gst_caps_from_string (GST_VIDEO_CAPS_MAKE ("ARGB")));
|
||||
gst_caps_append (c, gst_caps_from_string (GST_VIDEO_CAPS_MAKE ("BGRA")));
|
||||
gst_caps_append (c, gst_caps_from_string (GST_VIDEO_CAPS_MAKE ("ABGR")));
|
||||
break;
|
||||
case CV_16UC1:
|
||||
gst_caps_append (caps,
|
||||
gst_caps_from_string (GST_VIDEO_CAPS_GRAY16 ("1234")));
|
||||
gst_caps_append (caps,
|
||||
gst_caps_from_string (GST_VIDEO_CAPS_GRAY16 ("4321")));
|
||||
gst_caps_append (c,
|
||||
gst_caps_from_string (GST_VIDEO_CAPS_MAKE ("GRAY16_LE")));
|
||||
gst_caps_append (c,
|
||||
gst_caps_from_string (GST_VIDEO_CAPS_MAKE ("GRAY16_BE")));
|
||||
break;
|
||||
}
|
||||
return caps;
|
||||
return c;
|
||||
}
|
||||
|
|
|
@ -167,6 +167,7 @@ gst_opencv_video_filter_transform (GstBaseTransform * trans,
|
|||
{
|
||||
GstOpencvVideoFilter *transform;
|
||||
GstOpencvVideoFilterClass *fclass;
|
||||
GstFlowReturn ret;
|
||||
|
||||
transform = GST_OPENCV_VIDEO_FILTER (trans);
|
||||
fclass = GST_OPENCV_VIDEO_FILTER_GET_CLASS (transform);
|
||||
|
@ -175,10 +176,18 @@ gst_opencv_video_filter_transform (GstBaseTransform * trans,
|
|||
g_return_val_if_fail (transform->cvImage != NULL, GST_FLOW_ERROR);
|
||||
g_return_val_if_fail (transform->out_cvImage != NULL, GST_FLOW_ERROR);
|
||||
|
||||
transform->cvImage->imageData = (char *) GST_BUFFER_DATA (inbuf);
|
||||
transform->out_cvImage->imageData = (char *) GST_BUFFER_DATA (outbuf);
|
||||
return fclass->cv_trans_func (transform, inbuf, transform->cvImage, outbuf,
|
||||
transform->cvImage->imageData = (char *) gst_buffer_map (inbuf,
|
||||
NULL, NULL, GST_MAP_READ);
|
||||
transform->out_cvImage->imageData = (char *) gst_buffer_map (outbuf,
|
||||
NULL, NULL, GST_MAP_WRITE);
|
||||
|
||||
ret = fclass->cv_trans_func (transform, inbuf, transform->cvImage, outbuf,
|
||||
transform->out_cvImage);
|
||||
|
||||
gst_buffer_unmap (inbuf, transform->cvImage->imageData, -1);
|
||||
gst_buffer_unmap (outbuf, transform->out_cvImage->imageData, -1);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static GstFlowReturn
|
||||
|
@ -187,6 +196,7 @@ gst_opencv_video_filter_transform_ip (GstBaseTransform * trans,
|
|||
{
|
||||
GstOpencvVideoFilter *transform;
|
||||
GstOpencvVideoFilterClass *fclass;
|
||||
GstFlowReturn ret;
|
||||
|
||||
transform = GST_OPENCV_VIDEO_FILTER (trans);
|
||||
fclass = GST_OPENCV_VIDEO_FILTER_GET_CLASS (transform);
|
||||
|
@ -198,10 +208,15 @@ gst_opencv_video_filter_transform_ip (GstBaseTransform * trans,
|
|||
* level */
|
||||
buffer = gst_buffer_make_writable (buffer);
|
||||
|
||||
transform->cvImage->imageData = (char *) GST_BUFFER_DATA (buffer);
|
||||
transform->cvImage->imageData = (char *) gst_buffer_map (buffer,
|
||||
NULL, NULL, GST_MAP_READWRITE);
|
||||
|
||||
/* FIXME how to release buffer? */
|
||||
return fclass->cv_trans_ip_func (transform, buffer, transform->cvImage);
|
||||
ret = fclass->cv_trans_ip_func (transform, buffer, transform->cvImage);
|
||||
|
||||
gst_buffer_unmap (buffer, transform->cvImage->imageData, -1);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
Loading…
Reference in a new issue