After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 752528 - OpenCV hand gesture detection does not work with OpenCV newer than 2.4.10
OpenCV hand gesture detection does not work with OpenCV newer than 2.4.10
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
git master
Other All
: Normal normal
: 1.7.1
Assigned To: Vanessa Chipirrás Navalón
GStreamer Maintainers
Depends on:
Blocks: 753940
 
 
Reported: 2015-07-17 12:07 UTC by Vanessa Chipirrás Navalón
Modified: 2015-10-02 16:20 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Code refactoring of gst_handdetect_load_profile. (3.73 KB, patch)
2015-08-17 20:54 UTC, Vanessa Chipirrás Navalón
committed Details | Review
Check CvHaarClassifierCascade is release before being modified. (1.55 KB, patch)
2015-08-17 20:55 UTC, Vanessa Chipirrás Navalón
committed Details | Review
Remove unnecessary variable. (1.66 KB, patch)
2015-08-17 20:56 UTC, Vanessa Chipirrás Navalón
committed Details | Review
Change gsthanddetect to C++. (47.51 KB, patch)
2015-08-17 20:58 UTC, Vanessa Chipirrás Navalón
none Details | Review
Change gsthanddetect to C++ (48.33 KB, patch)
2015-08-19 14:48 UTC, Vanessa Chipirrás Navalón
none Details | Review
Change gsthanddetect to C++ (48.39 KB, patch)
2015-08-19 15:53 UTC, Vanessa Chipirrás Navalón
none Details | Review
Change gsthanddetect to C++ (48.82 KB, patch)
2015-08-19 16:18 UTC, Vanessa Chipirrás Navalón
none Details | Review
Change gsthanddetect to C++ (48.84 KB, patch)
2015-08-19 16:38 UTC, Vanessa Chipirrás Navalón
none Details | Review
Change gsthanddetect to C++ (48.67 KB, patch)
2015-08-21 00:43 UTC, Vanessa Chipirrás Navalón
committed Details | Review
Need to migrate to C++ (17.45 KB, patch)
2015-08-21 03:12 UTC, Vanessa Chipirrás Navalón
committed Details | Review
Detection test of palm gesture (115.62 KB, image/jpeg)
2015-08-21 04:04 UTC, Vanessa Chipirrás Navalón
  Details
Detection test of fist gesture (113.62 KB, image/jpeg)
2015-08-21 04:05 UTC, Vanessa Chipirrás Navalón
  Details
Remove other unnecessary variable (1.97 KB, patch)
2015-08-21 04:32 UTC, Vanessa Chipirrás Navalón
none Details | Review
Remove another unused variable (1.97 KB, patch)
2015-08-21 11:43 UTC, Vanessa Chipirrás Navalón
committed Details | Review

Description Vanessa Chipirrás Navalón 2015-07-17 12:07:49 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>
Comment 1 Luis de Bethencourt 2015-07-17 12:10:07 UTC
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 :)
Comment 2 Vanessa Chipirrás Navalón 2015-08-17 20:54:36 UTC
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.
Comment 3 Vanessa Chipirrás Navalón 2015-08-17 20:55:59 UTC
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.
Comment 4 Vanessa Chipirrás Navalón 2015-08-17 20:56:55 UTC
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.
Comment 5 Luis de Bethencourt 2015-08-17 20:57:52 UTC
Will review and test this tomorrow.

Thank you Vanessa
Comment 6 Vanessa Chipirrás Navalón 2015-08-17 20:58:24 UTC
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.
Comment 7 Vanessa Chipirrás Navalón 2015-08-17 21:19:49 UTC
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.
Comment 8 Luis de Bethencourt 2015-08-18 11:24:29 UTC
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
Comment 9 Luis de Bethencourt 2015-08-18 11:25:05 UTC
Review of attachment 309422 [details] [review]:

Vanessa,

Remember to add the URL of the bug in the last line of the commit message.
Comment 10 Luis de Bethencourt 2015-08-18 12:33:34 UTC
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
Comment 11 Luis de Bethencourt 2015-08-18 12:53:06 UTC
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
Comment 12 Vanessa Chipirrás Navalón 2015-08-19 14:48:14 UTC
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.
Comment 13 Vanessa Chipirrás Navalón 2015-08-19 15:53:50 UTC
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
Comment 14 Luis de Bethencourt 2015-08-19 16:05:07 UTC
-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
Comment 15 Vanessa Chipirrás Navalón 2015-08-19 16:18:13 UTC
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
Comment 16 Luis de Bethencourt 2015-08-19 16:24:30 UTC
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.
Comment 17 Vanessa Chipirrás Navalón 2015-08-19 16:38:00 UTC
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.
Comment 18 Luis de Bethencourt 2015-08-19 16:48:31 UTC
Review of attachment 309619 [details] [review]:

Thanks Vanessa! :)
Comment 19 Luis de Bethencourt 2015-08-19 16:56:00 UTC
Review of attachment 309619 [details] [review]:

This better wait till after the freeze.
Comment 20 Vanessa Chipirrás Navalón 2015-08-21 00:43:45 UTC
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.
Comment 21 Vanessa Chipirrás Navalón 2015-08-21 03:12:42 UTC
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.
Comment 22 Vanessa Chipirrás Navalón 2015-08-21 04:04:53 UTC
Created attachment 309781 [details]
Detection test of palm gesture
Comment 23 Vanessa Chipirrás Navalón 2015-08-21 04:05:49 UTC
Created attachment 309782 [details]
Detection test of fist gesture
Comment 24 Vanessa Chipirrás Navalón 2015-08-21 04:32:39 UTC
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.
Comment 25 Luis de Bethencourt 2015-08-21 10:06:45 UTC
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.
Comment 26 Luis de Bethencourt 2015-08-21 10:19:50 UTC
Review of attachment 309777 [details] [review]:

My bad. Read the diff backwards, you added those G_PARAM_STATIC_STRINGS. Good.
Comment 27 Luis de Bethencourt 2015-08-21 10:48:38 UTC
Review of attachment 309778 [details] [review]:

Good job :)

Tested it here and it works.
Comment 28 Luis de Bethencourt 2015-08-21 10:48:55 UTC
Review of attachment 309784 [details] [review]:

Good find.
Comment 29 Vanessa Chipirrás Navalón 2015-08-21 10:49:29 UTC
Great! :)
Comment 30 Vanessa Chipirrás Navalón 2015-08-21 11:43:34 UTC
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
Comment 31 Vanessa Chipirrás Navalón 2015-08-21 11:45:46 UTC
I changed the message of last patch.
Comment 32 Luis de Bethencourt 2015-08-21 11:57:32 UTC
Review of attachment 309807 [details] [review]:

It's good. Just a commit message rewording.
Comment 33 Luis de Bethencourt 2015-10-02 16:13:49 UTC
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
Comment 34 Luis de Bethencourt 2015-10-02 16:14:25 UTC
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
Comment 35 Luis de Bethencourt 2015-10-02 16:15:23 UTC
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
Comment 36 Luis de Bethencourt 2015-10-02 16:20:01 UTC
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
Comment 37 Luis de Bethencourt 2015-10-02 16:20:48 UTC
Thanks Vanessa!