GNOME Bugzilla – Bug 760473
OpenCV face detection does not work with OpenCV newer than 2.4.11
Last modified: 2018-11-03 13:45:17 UTC
When I compile the module "gstreamer1.0-plugins-bad" in my pc, I get this error: fatal error: opencv2/legacy/legacy.hpp: No such file or directory compilation terminated. But this also happens with files: contrib.hpp, core_c.h, types_c.h. I have 3.0.0 version of OpenCV, and I looked inside folders Opencv and I don't find this files. Maybe OpenCV 3.0.0 was deleted it or modified, I try to find out what happened.
Created attachment 320182 [details] [review] opencv: pyramidsegment: element deleted. cvPyrSegmentation() has been deprecated in OpenCV 3.0, and there isn't function to replace it in any OpenCV version. This element was deleted into Makefile and gstopencv.cpp file. https://bugzilla.gnome.org/show_bug.cgi?id=760473
Created attachment 320183 [details] [review] opencv: gstcvsmooth: Ported to 3.1 OpenCV version, while keeping the compatibility with 2.4. cvarrToMat() is added because it is compatible with all versions of Opencv and the use the class constructor Mat is eliminated because is deprecated in 3.X versions. https://bugzilla.gnome.org/show_bug.cgi?id=760473
Created attachment 320184 [details] [review] opencv: grabcut: Ported to 3.1 OpenCV version, while keeping the compatibility with 2.4. cvarrToMat() is added because it is compatible with all versions of Opencv and using the class Mat constructor is eliminated, because is deprecated in 3.X versions. The use the using namespace cv because is called some functions many times. https://bugzilla.gnome.org/show_bug.cgi?id=760473
Created attachment 320185 [details] [review] opencv: faceblur: Ported to 3.1 OpenCV version, while keeping the compatibility with 2.4. cvarrToMat() is added because it is compatible with all versions of Opencv and the use of the class constructor Mat is eliminated because is deprecated in 3.X versions. Included 'using namespace std' because it is needed for the Vector class in 3.X versions. https://bugzilla.gnome.org/show_bug.cgi?id=760473
Created attachment 320186 [details] [review] opencv: handdetect: Ported to 3.1 OpenCV version, while keeping the compatibility with 2.4. cvarrToMat() is added because it is compatible with all versions of Opencv and the use of the class constructor Mat is eliminated because is deprecated in 3.X versions. Included 'using namespace std' because it is needed for the vector class in 3.X versions. https://bugzilla.gnome.org/show_bug.cgi?id=760473
Created attachment 320187 [details] [review] opencv: retinex: Ported to 3.1 OpenCV version, while keeping the compatibility with 2.4. cvarrToMat() is added because it is compatible with all versions of Opencv and using the class constructor Mat is eliminated because is deprecated in 3.X versions. https://bugzilla.gnome.org/show_bug.cgi?id=760473
Created attachment 320189 [details] [review] opencv: textoverlay: Ported to 3.1 OpenCV version, while keeping the compatibility with 2.4. imgproc_c.h is added because CvFont struct needs it in new 3.X versions. Opencv changes this struct towards this library. https://bugzilla.gnome.org/show_bug.cgi?id=760473
Created attachment 320190 [details] [review] opencv: segmentation: Ported to 3.1 OpenCV version, while keeping the compatibility with 2.4. Add namespace bgsegm, replacement functions and Template class for new Opencv versions because these functions are removed. cvarrToMat() is added because it is compatible with all versions of Opencv and using the class Mat constructor is eliminated, because is deprecated in 3.X versions. The use the using namespace cv because is called some functions many times. https://bugzilla.gnome.org/show_bug.cgi?id=760473
Created attachment 320191 [details] [review] opencv: disparity: Ported to 3.1 OpenCV version, while keeping the compatibility with 2.4. 'METHOD_VAR', 'METHOD_GC' is removed because there aren't equivalent functions in new OpenCV versions. 'img_right_as_cvMat_rgb', 'img_left_as_cvMat_rgb' and 'depth_map_as_cvMat2' variables is removed because these aren't used. cvarrToMat() is added because it is compatible with all versions of Opencv and using the class Mat constructor is eliminated, because is deprecated in 3.X versions. The use 'using namespace cv' because is called some functions many times. https://bugzilla.gnome.org/show_bug.cgi?id=760473
Created attachment 320192 [details] [review] opencv: facedetect: Ported to 3.1 OpenCV version, while keeping the compatibility with 2.4. cvarrToMat() is added because it is compatible with all versions of Opencv and the use of the class constructor Mat is eliminated because is deprecated in 3.X versions. Included 'using namespace std' because it is needed for the vector class in 3.X versions. The files '.xml' are added into Gstreamer and Makefile because in 3.X versions of Opencv are deleted.
Created attachment 320193 [details] [review] opencv: skindetect: Ported to 3.1 OpenCV version, while keeping the compatibility with 2.4. cvCVPixToPlane() has been deprecated in OpenCV 3.0, and there is function to replace it cvSplit(). The include compat.hpp is deleted because in 3.X versions doen't exist and it isn't necessary for 2.4.X versions in this element. https://bugzilla.gnome.org/show_bug.cgi?id=760473
Created attachment 320195 [details] [review] opencv: Ported to 3.1 OpenCV version, while keeping the compatibility with 2.4. configure.ac was changed to work with new versions of OpenCV 3.X. A new include is added gstopencvutils.cpp because it contains the previous. https://bugzilla.gnome.org/show_bug.cgi?id=760473
Just to let everybody know, I am looking into this. I have followed Vanessa's good work and the problems with newer OpenCV versions. Will soon get around to doing a proper review of these patches.
Any input ? Check with Sebastien and Tim, it might not be too late for 1.8 ?
I'd like to get this into 1.8.1 ideally
I have been waiting until 1.8 is released to review/merge these patches. Since these are not really bug fixes, but just making these elements ready for when people start transitioning to OpenCV 3.1. Right now most distributions have 2.4 as the default.
I will review and get the patches ready today or this weekend. Push to master after 1.8, and backport to 1.8.1
Review of attachment 320183 [details] [review]: Looks good :) Will merge once I have reviewed the entire series.
Review of attachment 320184 [details] [review]: Vanessa, This looks like two changes in one commit. Switching to using the namespace cv, and the addition of cvarrToMat(). Could you split this into two commits? If you don't have time it is not a big issue, which is why I mark it as mergeable.
Review of attachment 320185 [details] [review]: Looks good :)
Review of attachment 320186 [details] [review]: Also looks good
Review of attachment 320187 [details] [review]: Good :)
Review of attachment 320189 [details] [review]: Vanessa, Could you make it so which header file gets included depending on the OpenCV version used? Via an #ifdef.
(In reply to Luis de Bethencourt from comment #23) > Review of attachment 320189 [details] [review] [review]: > > Vanessa, > > Could you make it so which header file gets included depending on the OpenCV > version used? Via an #ifdef. Do you mean with this include I put? I didn't do it because when you have the version 2.4.X this include exists. But yes I can change it and I will put the #ifelse like I did in another parts.
(In reply to Luis de Bethencourt from comment #19) > Review of attachment 320184 [details] [review] [review]: > > Vanessa, > > This looks like two changes in one commit. Switching to using the namespace > cv, and the addition of cvarrToMat(). > > Could you split this into two commits? If you don't have time it is not a > big issue, which is why I mark it as mergeable. Ok I can try it, if I see I don't have time between today and tomorrow I will tell you.
Review of attachment 320190 [details] [review]: Is #include <opencv2/bgsegm.hpp> meant to work in 2.4? I am getting the following compilation error: gstsegmentation.h:52:30: fatal error: opencv2/bgsegm.hpp: No such file or directory Maybe select includes based on which OpenCV version is available using an #if.
Review of attachment 320191 [details] [review]: Here you do the "#if (CV_MAJOR_VERSION >= 3)" I have suggested for some of the other patches :) This patch is the most complicated one so far since the API has changed completely and you can't use the same in both versions. The patch looks good. Great work.
Review of attachment 320192 [details] [review]: This one is tricky. It is going to need the decision of a Maintainer. The xml files that it pulls into ext/opencv/ are big. Maybe too big to be in the repository/tarballs for people who don't use the OpenCV elements. facedetect has a profile property that can be used to tell it where the Haar cascade file to use is. Maybe this could be empty and just suggest an URL to get them, even though that relies on OpenCV providing a stable location for them. Will ask for input.
Forgot to mention in the review about the facedetect patch that the code itself is good. It is just the XML files that need looking into.
Review of attachment 320193 [details] [review]: Looks good :)
Review of attachment 320195 [details] [review]: Looks good :)
Review of attachment 320182 [details] [review]: This still surprises me. OpenCV dropped this API and didn't offer any replacements. If we want to use OpenCV 3.x we need to remove this element. Unfortunate.
Any reason why you didn't push the ones that are ready already? :)
No. Just waiting a bit to see if we can push them all together in a block. But it isn't that important so I will push the ready ones today.
I will try to have all of them ready today, if I don't, I will have the patches ready tomorrow at the latest.
Review of attachment 320195 [details] [review]: Merged. Thanks Vanessa
Review of attachment 320193 [details] [review]: Merged. Thanks Vanessa
Review of attachment 320191 [details] [review]: Merged. Thanks Vanessa
Review of attachment 320187 [details] [review]: Merged. Thanks Vanessa
Review of attachment 320186 [details] [review]: Merged. Thanks Vanessa
Review of attachment 320185 [details] [review]: Merged. Thanks Vanessa
Review of attachment 320184 [details] [review]: Merged. Thanks Vanessa
Review of attachment 320183 [details] [review]: Merged. Thanks Vanessa
Review of attachment 320182 [details] [review]: In this patch you forgot to remove all references to pyramidsegment in the docs/ folder. Check commit d1266be4313d5f395cc253b22b9cfa3cd1bb6fe2 to see this. For the rest of the merged commits I changed the subject lines and messages a little: commit d1266be4313d5f395cc253b22b9cfa3cd1bb6fe2 Author: Vanessa Chipirras Navalon <vanechipi@qtec.com> Date: Wed Mar 30 22:34:59 2016 +0100 opencv: pyramidsegment: delete element cvPyrSegmentation() has been deprecated in OpenCV 3.0, and there isn't any function to replace it. Deleting this element so we can support OpenCV 3.1 without build issues. commit d3b6b8c64f3e7d2d8decdcd41f83777a3ee2b28f Author: Vanessa Chipirras Navalon <vanechipi@qtec.com> Date: Tue Jan 26 16:52:37 2016 +0100 opencv: gstcvsmooth: Ported to OpenCV version 3.1 cvarrToMat() is added because it is compatible with all versions of Opencv and the use the class constructor Mat is eliminated because is deprecated in 3.X versions. This keeps compatibility with 2.4. commit 0a08e771d47728e847a3aae17d00859e28f0b383 Author: Vanessa Chipirras Navalon <vanechipi@qtec.com> Date: Wed Jan 27 10:05:13 2016 +0100 opencv: grabcut: Ported to OpenCV version 3.1 cvarrToMat() is added because it is compatible with all versions of Opencv and using the class Mat constructor is eliminated, because is deprecated in 3.X versions. The use the using namespace cv because is called some functions many times. This keeps compatibility with 2.4. commit 120f32fed4d83ba869ab24c21ecea1bf32edd85a Author: Vanessa Chipirras Navalon <vanechipi@qtec.com> Date: Wed Jan 27 15:37:39 2016 +0100 opencv: faceblur: Ported to OpenCV version 3.1 cvarrToMat() is added because it is compatible with all versions of Opencv and the use of the class constructor Mat is eliminated because is deprecated in 3.X versions. Included 'using namespace std' because it is needed for the Vector class in 3.X versions. This keeps compatibility with 2.4. commit 93b83edfe55031fedd09b32635ccc37601edaa57 Author: Vanessa Chipirras Navalon <vanechipi@qtec.com> Date: Wed Jan 27 15:51:37 2016 +0100 opencv: handdetect: Ported to OpenCV version 3.1 cvarrToMat() is added because it is compatible with all versions of Opencv and the use of the class constructor Mat is eliminated because is deprecated in 3.X versions. Included 'using namespace std' because it is needed for the vector class in 3.X versions. This keeps compatibility with 2.4. commit f91b71eddeed426c2eb4a1f759067cb892574349 Author: Vanessa Chipirras Navalon <vanechipi@qtec.com> Date: Wed Jan 27 16:51:13 2016 +0100 opencv: retinex: Ported to OpenCV version 3.1 cvarrToMat() is added because it is compatible with all versions of Opencv and using the class constructor Mat is eliminated because is deprecated in 3.X versions. This keeps compatibility with 2.4. commit 037f54d64462931da378c8d6eb0d5af4d7d04c27 Author: Vanessa Chipirras Navalon <vanechipi@qtec.com> Date: Thu Jan 28 16:19:46 2016 +0100 opencv: disparity: Ported to OpenCV version 3.1 'METHOD_VAR', 'METHOD_GC' is removed because there aren't equivalent functions in new OpenCV versions. 'img_right_as_cvMat_rgb', 'img_left_as_cvMat_rgb' and 'depth_map_as_cvMat2' variables is removed because these aren't used. cvarrToMat() is added because it is compatible with all versions of Opencv and using the class Mat constructor is eliminated, because is deprecated in 3.X versions. The use 'using namespace cv' because is called some functions many times. This keeps compatibility with 2.4. commit 4b60b470754f7ed17c51e70e48f7f559a2592ed4 Author: Vanessa Chipirras Navalon <vanechipi@qtec.com> Date: Mon Feb 1 13:58:49 2016 +0100 opencv: skindetect: Ported to OpenCV version 3.1 cvCVPixToPlane() has been deprecated in OpenCV 3.0, and there is function to replace it cvSplit(). The include compat.hpp is deleted because in 3.X versions doen't exist and it isn't necessary for 2.4.X versions in this element. This keeps compatibility with 2.4. commit b37c759e528ed28997965e370357524f5701502e Author: Vanessa Chipirras Navalon <vanechipi@qtec.com> Date: Thu Jan 28 17:40:51 2016 +0100 opencv: Ported to OpenCV version 3.1 OpenCV configure.ac was changed to work with new versions of OpenCV 3.X. A new include is added gstopencvutils.cpp because it contains the previous. This keeps compatibility with 2.4.
(In reply to Luis de Bethencourt from comment #44) > Review of attachment 320182 [details] [review] [review]: > > In this patch you forgot to remove all references to pyramidsegment in the > docs/ folder. > > Check commit d1266be4313d5f395cc253b22b9cfa3cd1bb6fe2 to see this. > > For the rest of the merged commits I changed the subject lines and messages > a little: > > commit d1266be4313d5f395cc253b22b9cfa3cd1bb6fe2 > Author: Vanessa Chipirras Navalon <vanechipi@qtec.com> > Date: Wed Mar 30 22:34:59 2016 +0100 > > opencv: pyramidsegment: delete element > > cvPyrSegmentation() has been deprecated in OpenCV 3.0, and there isn't > any > function to replace it. Deleting this element so we can support OpenCV > 3.1 > without build issues. > > commit d3b6b8c64f3e7d2d8decdcd41f83777a3ee2b28f > Author: Vanessa Chipirras Navalon <vanechipi@qtec.com> > Date: Tue Jan 26 16:52:37 2016 +0100 > > opencv: gstcvsmooth: Ported to OpenCV version 3.1 > > cvarrToMat() is added because it is compatible with all versions of > Opencv > and the use the class constructor Mat is eliminated because is deprecated > in 3.X versions. This keeps compatibility with 2.4. > > commit 0a08e771d47728e847a3aae17d00859e28f0b383 > Author: Vanessa Chipirras Navalon <vanechipi@qtec.com> > Date: Wed Jan 27 10:05:13 2016 +0100 > > opencv: grabcut: Ported to OpenCV version 3.1 > > cvarrToMat() is added because it is compatible with all versions of > Opencv > and using the class Mat constructor is eliminated, because is deprecated > in 3.X versions. The use the using namespace cv because is called some > functions many times. This keeps compatibility with 2.4. > > commit 120f32fed4d83ba869ab24c21ecea1bf32edd85a > Author: Vanessa Chipirras Navalon <vanechipi@qtec.com> > Date: Wed Jan 27 15:37:39 2016 +0100 > > opencv: faceblur: Ported to OpenCV version 3.1 > > cvarrToMat() is added because it is compatible with all versions of > Opencv > and the use of the class constructor Mat is eliminated because is > deprecated > in 3.X versions. Included 'using namespace std' because it is needed for > the > Vector class in 3.X versions. This keeps compatibility with 2.4. > > commit 93b83edfe55031fedd09b32635ccc37601edaa57 > Author: Vanessa Chipirras Navalon <vanechipi@qtec.com> > Date: Wed Jan 27 15:51:37 2016 +0100 > > opencv: handdetect: Ported to OpenCV version 3.1 > > cvarrToMat() is added because it is compatible with all versions of > Opencv > and the use of the class constructor Mat is eliminated because is > deprecated > in 3.X versions. Included 'using namespace std' because it is needed for > the > vector class in 3.X versions. This keeps compatibility with 2.4. > > commit f91b71eddeed426c2eb4a1f759067cb892574349 > Author: Vanessa Chipirras Navalon <vanechipi@qtec.com> > Date: Wed Jan 27 16:51:13 2016 +0100 > > opencv: retinex: Ported to OpenCV version 3.1 > > cvarrToMat() is added because it is compatible with all versions of > Opencv > and using the class constructor Mat is eliminated because is deprecated > in 3.X versions. This keeps compatibility with 2.4. > > commit 037f54d64462931da378c8d6eb0d5af4d7d04c27 > Author: Vanessa Chipirras Navalon <vanechipi@qtec.com> > Date: Thu Jan 28 16:19:46 2016 +0100 > > opencv: disparity: Ported to OpenCV version 3.1 > > 'METHOD_VAR', 'METHOD_GC' is removed because there aren't equivalent > functions > in new OpenCV versions. 'img_right_as_cvMat_rgb', > 'img_left_as_cvMat_rgb' and > 'depth_map_as_cvMat2' variables is removed because these aren't used. > cvarrToMat() is added because it is compatible with all versions of > Opencv > and using the class Mat constructor is eliminated, because is deprecated > in 3.X versions. The use 'using namespace cv' because is called some > functions many times. This keeps compatibility with 2.4. > > commit 4b60b470754f7ed17c51e70e48f7f559a2592ed4 > Author: Vanessa Chipirras Navalon <vanechipi@qtec.com> > Date: Mon Feb 1 13:58:49 2016 +0100 > > opencv: skindetect: Ported to OpenCV version 3.1 > > cvCVPixToPlane() has been deprecated in OpenCV 3.0, and there is > function to replace it cvSplit(). The include compat.hpp is deleted > because > in 3.X versions doen't exist and it isn't necessary for 2.4.X versions > in this element. This keeps compatibility with 2.4. > > commit b37c759e528ed28997965e370357524f5701502e > Author: Vanessa Chipirras Navalon <vanechipi@qtec.com> > Date: Thu Jan 28 17:40:51 2016 +0100 > > opencv: Ported to OpenCV version 3.1 OpenCV > > configure.ac was changed to work with new versions of OpenCV 3.X. > A new include is added gstopencvutils.cpp because it contains > the previous. This keeps compatibility with 2.4. Ok ok, I saw it, sorry and thanks!
I'm sorry, today I can't have these patches ready because I had unforeseen events, but I will have it the next week. I hope this isn't a problem.
Created attachment 325138 [details] [review] opencv: textoverlay: Ported to OpenCV version 3.1 Done. Ready for review.
Review of attachment 325138 [details] [review]: Great :)
Created attachment 325147 [details] [review] opencv: segmentation: Ported to OpenCV version 3.1 opencv: segmentation: Ported to OpenCV version 3.1 Add namespace bgsegm, replacement functions and Template class for new Opencv versions because these functions are removed. cvarrToMat() is added because it is compatible with all versions of Opencv and the use of class Mat constructor is eliminated, it is deprecated in 3.X versions. The use the namespace cv because some functions are called many times. This keeps compatibility with 2.4 https://bugzilla.gnome.org/show_bug.cgi?id=760473 Done. Ready for review.
Review of attachment 325147 [details] [review]: Thanks :)
Where you find opencv2/bgsegm.hpp ? I can't find them anywhere. On opencv master have only cudabgsegm
I also can't seem to find it in the Debian OpenCV packages.
I found it's on opencv extra plugins(opencv_contrib). But it's in many places not included. For example buildroot use plugins only from opencv and not have opencv_contrib packet
What's left to be done here? Decide what to do with facedetect and whether to slurp these large xml files into GStreamer? Looks like Matt fixed the build with opencv 3.1: commit 044ed50190a756a83f2b7c26bfd2d49c4b5e448e Author: Matthew Waters <matthew@centricular.com> Date: Sat May 14 17:05:45 2016 +0100 opencv/facedetect: fix the build with opencv 3.1.0
-- 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/341.