GNOME Bugzilla – Bug 635646
opencv: Add cvcalchist element for calculating histogram
Last modified: 2018-11-03 13:06:52 UTC
Created attachment 175134 [details] [review] Patch to add cvcalchist Added the element cvcalchist which wraps the OpenCV function cvCalcHist. Only 8- and 16-bit monochrome video is supported at this time. By default the element will not alter the data, but if "draw-histogram" is true, then a crude histogram will be drawn over the image. I've included a test program under tests/examples/opencv that draws a text histogram to the console using the "histogram" message. Please review the patch, as I'm sure there are some issues. I wasn't sure of a nice way to handle RGB histograms, especially in terms of how to package the data in a message, so I left that alone for the time being. Also note I'm developed this under Windows, but hopefully I've modified the Makefiles appropriately.
I'm having problems building this. It was missing compat.h from opencv, so I included it, but then building fails because of: make[3]: Entering directory `/home/thiagoss/gst/head/gst-plugins-bad/ext/opencv' CC libgstopencv_la-gstopencv.lo cc1: warnings being treated as errors In file included from gstcvcalchist.h:49, from gstopencv.c:29: /usr/include/opencv/cvcompat.h: In function ‘cvMinAreaRect’: /usr/include/opencv/cvcompat.h:425: error: left-hand operand of comma expression has no effect /usr/include/opencv/cvcompat.h:425: error: left-hand operand of comma expression has no effect /usr/include/opencv/cvcompat.h:425: error: left-hand operand of comma expression has no effect /usr/include/opencv/cvcompat.h:425: error: statement with no effect make[3]: *** [libgstopencv_la-gstopencv.lo] Error 1 The line it points to is: CV_UNREFERENCED( (left, bottom, right, top) ); And finally, CV_UNREFERENCED is defined as: #ifdef __cplusplus #define CV_UNREFERENCED(arg) #else #define CV_UNREFERENCED(arg) arg #endif Need to think on how to solve this.
(In reply to comment #1) > I'm having problems building this. > > It was missing compat.h from opencv, so I included it, but then building fails > because of: I'm not sure why cvcompat.h would be needed, at least I don't need it with a MSVC 2008 build (OSSBuild). I don't think there's any need for us to use any old API, and if we do have any, we may as well update to use the 2.x API. What's the error that requires cvcompat.h?
cc1: warnings being treated as errors gstcvcalchist.c: In function ‘gst_cv_calchist_message_new’: gstcvcalchist.c:461: error: implicit declaration of function ‘cvQueryHistValue_1D’ gstcvcalchist.c:461: error: nested extern declaration of ‘cvQueryHistValue_1D’
Managed to get it to build, but it is still giving me errors when running. Gotta run now, but I'll try to debug it later. OpenCV Error: Bad argument (unrecognized or unsupported array type) in cvPtr1D, file /build/buildd/opencv-2.1.0/src/cxcore/cxarray.cpp, line 1729 terminate called after throwing an instance of 'cv::Exception' what(): /build/buildd/opencv-2.1.0/src/cxcore/cxarray.cpp:1729: error: (-5) unrecognized or unsupported array type in function cvPtr1D
can I help you fix this ?
any progress ? or if you think maybe I can solve this. Robert
This is not a priority for me right now, but if you'd like to try and fix the Linux compatibility please do so. Make sure you're working with the latest version of OpenCV, or at least the 2.x series.
It's okay. I'm working with OpenCV 2.2 and I can solve this with this version. I will post the patch on this week or this weekend. Robert
Getting an updated patch would be great to include it in the upcoming releases.
Anybody planning to work on this? New patch against latest git master of gst-plugins-bad would be needed :)
(In reply to comment #10) > Anybody planning to work on this? New patch against latest git master of > gst-plugins-bad would be needed :) I'd like to do this, but it will be a few weeks at least.
Created attachment 281889 [details] [review] opencv: Add cvcalchist element for calculating histogram Updated the patch to apply on latest master. Currently it acts as passthrough and analyzes the image but if draw-histogram=true it will push a buffer containing the histogram. Do we have any element with similar behavior or any standard way of doing this? 2 pads or a property?
Thiago, let's just get this in for now then... or alternatively close it as WONTFIX?
-- GitLab Migration Automatic Message -- This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/28.