Cascade Classifier Training - Application: opencv_traincascade

For Cascade Classifier Training , the opencv_traincascade application as mentioned here:

http://docs.opencv.org/master/dc/d88/tutorial_traincascade.html

The source code does not compile as some of the files with the old_ml prefix in the source code make reference to a CvFileStorage data structure. This seems not to be present in version 4.x of OpenCV (Documentation has it listed in version 3.x).

How can I build this application ? (I would like to for version 4.x and 32-bit & 64-bit, dynamic linked & static linked)

indeed, the train cascade tools can no longer be built with 4.x

as of now, you have to checkout the 3.4 branch (which still has the missing c-api parts) by either

// if you got it via git, just change the branch
cd opencv
git checkout 3.4 

// else download anew
git clone  -b 3.4 https://github.com/opencv/opencv.git

anyway, you’ll have to remove all your previous cmake artefacts, and start all over.

So I have to use version 3.4 to build the tool ?.

Also, why was the tool not updated for 4.x ?, was there some limiting factor ?

@berek

I tried building with 3.4. But I get huge amount of compiler errors.

Are you sure it actually will compile with 3.4 ?.

Can you give fool-proof step by step instructions, from scratch? (include all steps such as download,extract,configuration,setup,Visual Studio Project configuration, etc…), for every file. - For Static and Dynamic (Shared), 32-Bit and 64-Bit, using Visual Studio 2019 ( Windows 7 SP1)

well, it should

sorry, i can’t, not using VS (mayne someone else ?)

this is controlled by a cmake flag, irresp. of the compiler used.

in cmake, set BUILD_SHARED_LIBS=OFF for building and linking against static libs

apart from that, please clarify, what you want to detect later (is this even the correct tool ?)
have you considered different means to do so, like HogDetector or some (pre or re) - trained network ?

Yes correct tool, been referred to it by the tutorials.

When compiling I get Build error output:

1>C:\OpenCV_3.4.13\traincascade\old_ml_precomp.hpp(49,10): fatal error C1083: Cannot open include file: 'opencv2/core/private.hpp': No such file or directory

Is traincascade program really needed for your application? to update (opencv 4.5.2) it you will need not only one day

I do not understand the 2nd half of the questions, after the questions mark, but I answer as best as I can:

Yes it is needed, for training, cannot without it. I will be using it many times (not just once).

I got the source supplied with 3.4 to build with 3.4. But cannot get the source supplied with 4.6 to build with 3.4 (content is different)
?

Hi, I’m at the same juncture. Is there a workaround to using the train cascade tools with opencv 4.x versions?

no there isnt.
check out the 3.4 branch, and build that together with the apps