mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 16:50:47 +00:00
cvsmooth: Add support for video/x-raw-gray
This commit is contained in:
parent
824d69d5ad
commit
971fe3ae0c
4 changed files with 49 additions and 35 deletions
|
@ -55,13 +55,15 @@ GST_DEBUG_CATEGORY_STATIC (gst_cv_smooth_debug);
|
|||
static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
|
||||
GST_PAD_SINK,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS ("video/x-raw-rgb, depth=(int)24, bpp=(int)24")
|
||||
GST_STATIC_CAPS ("video/x-raw-rgb, depth=(int)24, bpp=(int)24;"
|
||||
"video/x-raw-gray, depth=(int)8, bpp=(int)8")
|
||||
);
|
||||
|
||||
static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
|
||||
GST_PAD_SRC,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS ("video/x-raw-rgb, depth=(int)24, bpp=(int)24")
|
||||
GST_STATIC_CAPS ("video/x-raw-rgb, depth=(int)24, bpp=(int)24;"
|
||||
"video/x-raw-gray, depth=(int)8, bpp=(int)8")
|
||||
);
|
||||
|
||||
/* Filter signals and args */
|
||||
|
|
|
@ -212,14 +212,14 @@ gst_opencv_base_transform_set_caps (GstBaseTransform * trans, GstCaps * incaps,
|
|||
{
|
||||
GstOpencvBaseTransform *transform = GST_OPENCV_BASE_TRANSFORM (trans);
|
||||
gint in_width, in_height;
|
||||
gint in_depth, in_type, in_channels;
|
||||
gint in_depth, in_channels;
|
||||
gint out_width, out_height;
|
||||
gint out_depth, out_type, out_channels;
|
||||
gint out_depth, out_channels;
|
||||
GError *in_err = NULL;
|
||||
GError *out_err = NULL;
|
||||
|
||||
if (!gst_opencv_parse_iplimage_params_from_caps (incaps, &in_width,
|
||||
&in_height, &in_depth, &in_type, &in_channels, &in_err)) {
|
||||
&in_height, &in_depth, &in_channels, &in_err)) {
|
||||
GST_WARNING_OBJECT (transform, "Failed to parse input caps: %s",
|
||||
in_err->message);
|
||||
g_error_free (in_err);
|
||||
|
@ -227,7 +227,7 @@ gst_opencv_base_transform_set_caps (GstBaseTransform * trans, GstCaps * incaps,
|
|||
}
|
||||
|
||||
if (!gst_opencv_parse_iplimage_params_from_caps (outcaps, &out_width,
|
||||
&out_height, &out_depth, &out_type, &out_channels, &out_err)) {
|
||||
&out_height, &out_depth, &out_channels, &out_err)) {
|
||||
GST_WARNING_OBJECT (transform, "Failed to parse output caps: %s",
|
||||
out_err->message);
|
||||
g_error_free (out_err);
|
||||
|
|
|
@ -27,9 +27,6 @@ gst_opencv_get_ipl_depth_and_channels (GstStructure * structure,
|
|||
{
|
||||
gint depth, bpp;
|
||||
|
||||
if (gst_structure_has_name (structure, "video/x-raw-rgb")) {
|
||||
*channels = 3;
|
||||
|
||||
if (!gst_structure_get_int (structure, "depth", &depth) ||
|
||||
!gst_structure_get_int (structure, "bpp", &bpp)) {
|
||||
g_set_error (err, GST_CORE_ERROR, GST_CORE_ERROR_NEGOTIATION,
|
||||
|
@ -43,29 +40,33 @@ gst_opencv_get_ipl_depth_and_channels (GstStructure * structure,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (depth == 24) {
|
||||
/* TODO signdness? */
|
||||
*ipldepth = IPL_DEPTH_8U;
|
||||
} else {
|
||||
g_set_error (err, GST_CORE_ERROR, GST_CORE_ERROR_NEGOTIATION,
|
||||
"Unsupported depth: %d", depth);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
if (gst_structure_has_name (structure, "video/x-raw-rgb")) {
|
||||
*channels = 3;
|
||||
} else if (gst_structure_has_name (structure, "video/x-raw-gray")) {
|
||||
*channels = 1;
|
||||
} else {
|
||||
g_set_error (err, GST_CORE_ERROR, GST_CORE_ERROR_NEGOTIATION,
|
||||
"Unsupported caps %s", gst_structure_get_name (structure));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (depth / *channels == 8) {
|
||||
/* TODO signdness? */
|
||||
*ipldepth = IPL_DEPTH_8U;
|
||||
} else {
|
||||
g_set_error (err, GST_CORE_ERROR, GST_CORE_ERROR_NEGOTIATION,
|
||||
"Unsupported depth/channels %d/%d", depth, *channels);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gst_opencv_parse_iplimage_params_from_caps (GstCaps * caps, gint * width,
|
||||
gint * height, gint * ipldepth, gint * type, gint * channels, GError ** err)
|
||||
gst_opencv_parse_iplimage_params_from_structure (GstStructure * structure,
|
||||
gint * width, gint * height, gint * ipldepth, gint * channels,
|
||||
GError ** err)
|
||||
{
|
||||
GstStructure *structure = gst_caps_get_structure (caps, 0);
|
||||
|
||||
if (!gst_opencv_get_ipl_depth_and_channels (structure, ipldepth, channels,
|
||||
err)) {
|
||||
return FALSE;
|
||||
|
@ -80,3 +81,11 @@ gst_opencv_parse_iplimage_params_from_caps (GstCaps * caps, gint * width,
|
|||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gst_opencv_parse_iplimage_params_from_caps (GstCaps * caps, gint * width,
|
||||
gint * height, gint * ipldepth, gint * channels, GError ** err)
|
||||
{
|
||||
return gst_opencv_parse_iplimage_params_from_structure (
|
||||
gst_caps_get_structure (caps, 0), width, height, ipldepth, channels, err);
|
||||
}
|
||||
|
|
|
@ -33,7 +33,10 @@ gboolean
|
|||
gst_opencv_get_ipldepth (gint depth, gint bpp, gint * ipldepth);
|
||||
|
||||
gboolean gst_opencv_parse_iplimage_params_from_caps
|
||||
(GstCaps * caps, gint * width, gint * height, gint * depth, gint * type,
|
||||
(GstCaps * caps, gint * width, gint * height, gint * depth,
|
||||
gint * channels, GError ** err);
|
||||
gboolean gst_opencv_parse_iplimage_params_from_structure
|
||||
(GstStructure * structure, gint * width, gint * height, gint * depth,
|
||||
gint * channels, GError ** err);
|
||||
|
||||
#endif /* __GST_OPENCV_UTILS__ */
|
||||
|
|
Loading…
Reference in a new issue