mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
opencv templatematch: Set caps to BGR order
templatematch operates on BGR data. In fact, OpenCV's IplImage always stores color image data in BGR order -- this isn't documented at all in the OpenCV source code, but there are hints around the web (see for example http://www.cs.iit.edu/~agam/cs512/lect-notes/opencv-intro/opencv-intro.html#SECTION00041000000000000000 and http://www.comp.leeds.ac.uk/vision/opencv/iplimage.html ). gst_templatematch_load_template loads the template (the image to find) from disk using OpenCV's cvLoadImage, so it is stored in an IplImage in BGR order. But in gst_templatematch_chain, no OpenCV conversion functions are used: the imageData pointer of the IplImage for the video frame (the image to search in) is just set to point to the raw buffer data. Without this fix, that raw data is in RGB order, so the call to cvMatchTemplate ends up comparing the template's Blue channel against the frame's Red channel, producing very poor results.
This commit is contained in:
parent
aa5e25820b
commit
f5992a6cdd
1 changed files with 2 additions and 2 deletions
|
@ -92,13 +92,13 @@ enum
|
||||||
static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
|
static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
|
||||||
GST_PAD_SINK,
|
GST_PAD_SINK,
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("RGB"))
|
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("BGR"))
|
||||||
);
|
);
|
||||||
|
|
||||||
static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
|
static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
|
||||||
GST_PAD_SRC,
|
GST_PAD_SRC,
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("RGB"))
|
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("BGR"))
|
||||||
);
|
);
|
||||||
|
|
||||||
G_DEFINE_TYPE (GstTemplateMatch, gst_template_match, GST_TYPE_ELEMENT);
|
G_DEFINE_TYPE (GstTemplateMatch, gst_template_match, GST_TYPE_ELEMENT);
|
||||||
|
|
Loading…
Reference in a new issue