GNOME Bugzilla – Bug 752528
OpenCV hand gesture detection does not work with OpenCV newer than 2.4.10
Last modified: 2015-10-02 16:20:48 UTC
$ gst-launch-1.0 autovideosrc ! videoconvert ! video/x-raw, formt=RGB, width=320, height=240 ! videoscale ! handdetect ! videoconvert ! autovideosink When I run this, the hand gesture detection is not detected in the camera. It is due to the new structure of the classifier "CascadeClassifier" that opencv used in versions newer than 2.4.10. "gsthanddetect.c" should be transform C ++ language and to use the "load" method to load the old and new structure of the classifier. Previously the classifier was: <haarcascade_frontalface_default type_id="opencv-haar-classifier"> Now it is: <cascade type_id="opencv-cascade-classifier"><stageType>BOOST</stageType>
Vanessa, You could use the work you have done in facedetect. Update the element to use latest OpenCV and make it work again. I am assigning this to you :)
Created attachment 309422 [details] [review] Code refactoring of gst_handdetect_load_profile. Changes inside the gst_handdetect_load_profile function, the number of input parameters and in lines where it is used due to it cannot be used generically.
Created attachment 309423 [details] [review] Check CvHaarClassifierCascade is release before being modified. For PROP_PROFILE_FIST and PROP_PROFILE_PALM cases that exist inside gst_handdetect_set_property function loads the new XML file in the CvHaarClassifierCascade property without first checking that it is released because maybe there is an XML file previously loaded.
Created attachment 309424 [details] [review] Remove unnecessary variable. Only memory is reserved for this variable and then released without making any other use of it.
Will review and test this tomorrow. Thank you Vanessa
Created attachment 309425 [details] [review] Change gsthanddetect to C++. Change the gsthanddetect.c file to cpp and add it into Makefile. It is necessary migrate to C++ the handdetect plugin, in order to fix the bug 752528.
The patches are ready for review. I did not try if the first three changes work because I don't have installed the previous version 2.4.11 of opencv, but I think the changes will not affect. The latest patch is only renowned gsthanddetect.c to gsthanddetect.cpp, but still doesn't contain C ++ methods inside the file. That will be the next commit.
commit 00a55d1a6915b21db58e481ed48c10afbcd0e675 Author: Vanessa Chipirrás Navalón <vchipirras6@gmail.com> Date: Mon Aug 17 17:47:42 2015 +0200 handdetect: code refactoring of gst_handdetect_load_profile. Change gst_handdetect_load_profile() so it can be used generically. https://bugzilla.gnome.org/show_bug.cgi?id=752528
Review of attachment 309422 [details] [review]: Vanessa, Remember to add the URL of the bug in the last line of the commit message.
Review of attachment 309423 [details] [review]: commit fc03a17430d7fec3501d703961f318a2b0068f08 Author: Vanessa Chipirrás Navalón <vchipirras6@gmail.com> Date: Mon Aug 17 18:02:28 2015 +0200 handdetect: check CvHaarClassifierCascade is release before being modified. Make sure a previous cascade, if it exists, is released before loading a new XML file onto it. https://bugzilla.gnome.org/show_bug.cgi?id=752528
Review of attachment 309424 [details] [review]: commit 7dd86c26b25abb36006b347d63724e06b5f3da21 Author: Vanessa Chipirrás Navalón <vchipirras6@gmail.com> Date: Mon Aug 17 18:06:30 2015 +0200 handdetect: remove unnecessary variable. Memory is reserved for this variable and then released without making any use of it. https://bugzilla.gnome.org/show_bug.cgi?id=752528
Created attachment 309605 [details] [review] Change gsthanddetect to C++ Change the gsthanddetect.c file to cpp and add it into Makefile. It is necessary migrate to C++ the handdetect plugin, in order to fix the bug 752528.
Created attachment 309611 [details] [review] Change gsthanddetect to C++ Change the gsthanddetect.c file to cpp and add it into Makefile. It is necessary to migrate the handdetect plugin to C++, in order to load new and old classifiers, to make handdetect work with newer versions of Opencv. https://bugzilla.gnome.org/show_bug.cgi?id=752528
-libgstopencv_la_CXXFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CXXFLAGS) $(OPENCV_CFLAGS) +libgstopencv_la_CXXFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CXXFLAGS) $(OPENCV_CFLAGS)\ + -DGST_HAAR_CASCADES_DIR=\"$(pkgdatadir)/@GST_API_VERSION@/opencv_haarcascades\" Is correct, since now we need that macro un the C++ side of things. But that macro isn't used in any C plugins now. Remove it from the libgstopencv_la_CFLAGS
Created attachment 309617 [details] [review] Change gsthanddetect to C++ Change the gsthanddetect.c file to cpp and add it into Makefile. It is necessary to migrate the handdetect plugin to C++, in order to load new and old classifiers, to make handdetect work with newer versions of Opencv. https://bugzilla.gnome.org/show_bug.cgi?id=752528
Could you run gst-indent on ext/opencv/gsthanddetect.cpp? Your changes casting to guint to avoid compilation errors have made multiple lines be over 80 characters.
Created attachment 309619 [details] [review] Change gsthanddetect to C++ Change the gsthanddetect.c file to cpp and add it into Makefile. It is necessary to migrate the handdetect plugin to C++, in order to load new and old classifiers, to make handdetect work with newer versions of Opencv.
Review of attachment 309619 [details] [review]: Thanks Vanessa! :)
Review of attachment 309619 [details] [review]: This better wait till after the freeze.
Created attachment 309777 [details] [review] Change gsthanddetect to C++ Change the gsthanddetect.c file to cpp and add it into Makefile. It is necessary to migrate the handdetect plugin to C++, in order to load new and old classifiers, to make handdetect work with newer versions of Opencv. https://bugzilla.gnome.org/show_bug.cgi?id=752528 Final patch of "Change gsthanddetect to C++". This is correct.
Created attachment 309778 [details] [review] Need to migrate to C++ The cascade classifier changes its structure on new version of OpenCV 2.4.11. It is need to migrate to C++ to utilize the new load method of OpenCV which allows to load the old and new classifiers. https://bugzilla.gnome.org/show_bug.cgi?id=752528 Ready to review, although the patch is not clear because I modified many lines within the gst_handdetect_transform_ip() function.
Created attachment 309781 [details] Detection test of palm gesture
Created attachment 309782 [details] Detection test of fist gesture
Created attachment 309784 [details] [review] Remove other unnecessary variable Memory is reserved for this variable and then released without making any use of it. https://bugzilla.gnome.org/show_bug.cgi?id=752528 This fix is repeated in other lines, I put a patch of this correction with the same summary and description of the other. I have not had this situation before, and I do not know if I did right. If it's wrong let me know and I fix it.
Review of attachment 309777 [details] [review]: < + 0, UINT_MAX, 0, (GParamFlags) G_PARAM_READWRITE) --- > + 0, UINT_MAX, 0, > + (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)) Why do you remove the G_PARAM_STATIC_STRINGS of all properties? Please keep this.
Review of attachment 309777 [details] [review]: My bad. Read the diff backwards, you added those G_PARAM_STATIC_STRINGS. Good.
Review of attachment 309778 [details] [review]: Good job :) Tested it here and it works.
Review of attachment 309784 [details] [review]: Good find.
Great! :)
Created attachment 309807 [details] [review] Remove another unused variable Memory is reserved for this variable and then released without making any use of it. https://bugzilla.gnome.org/show_bug.cgi?id=752528
I changed the message of last patch.
Review of attachment 309807 [details] [review]: It's good. Just a commit message rewording.
Review of attachment 309777 [details] [review]: handdetect: Change gsthanddetect to C++ Change the gsthanddetect.c file to cpp and add it into Makefile. It is necessary to migrate the handdetect plugin to C++, in order to load new and old classifiers, to make handdetect work with newer versions of Opencv. https://bugzilla.gnome.org/show_bug.cgi?id=752528
Review of attachment 309778 [details] [review]: handdetect: need to migrate to C++ The cascade classifier changes its structure on new version of OpenCV 2.4.11. It is need to migrate to C++ to utilize the new load method of OpenCV which allows to load the old and new classifiers. https://bugzilla.gnome.org/show_bug.cgi?id=752528
After rebasing Vanessa's patches with post-1.6 master it failed to build. So had to do the following fix: commit e00461a789c7ceb2fedc7e118097090dad27a85c Author: Luis de Bethencourt <luisbg@osg.samsung.com> Date: Fri Oct 2 17:02:42 2015 +0100 handdetect: CvPoint values changed from uint to int The x and y values of CvPoint changed from unsigned to signed integers in OpenCV 2.4.11. https://bugzilla.gnome.org/show_bug.cgi?id=752528
Review of attachment 309807 [details] [review]: commit 31b1938a5f51ae345a2487000c99153b0bd1b78d Author: Vanessa Chipirrás Navalón <vchipirras6@gmail.com> Date: Fri Oct 2 17:18:33 2015 +0100 handdetect: remove another unused variable Memory is reserved for this variable and then released without making any use of it. https://bugzilla.gnome.org/show_bug.cgi?id=752528
Thanks Vanessa!