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 */
{
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);
}
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);
{
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,
- "No depth/bpp in caps");
- return FALSE;
- }
-
- if (depth != bpp) {
- g_set_error (err, GST_CORE_ERROR, GST_CORE_ERROR_NEGOTIATION,
- "Depth and bpp should be equal");
- return FALSE;
- }
+ 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,
+ "No depth/bpp in caps");
+ 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;
- }
+ if (depth != bpp) {
+ g_set_error (err, GST_CORE_ERROR, GST_CORE_ERROR_NEGOTIATION,
+ "Depth and bpp should be equal");
+ 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;
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);
+}
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__ */