📜  如何编译 opencv_traincascade - 任何代码示例

📅  最后修改于: 2022-03-11 14:58:59.644000             🧑  作者: Mango

代码示例1
Programs you will need: git, cmake and
    Visual Studio (with c/c++) (I used VS 2019)

Open commandline (cmd) in a folder of your choice.
Run the command:
    git clone 3.4 https://github.com/opencv/opencv.git
(the reason why version 3.4 is chosen is because
    traincascade doesn't work in newer versions of opencv)
In your folder you should now have a folder called 'opencv'

Now create a new folder (not inside opencv,
    but inside the 'folder of your choice')
Open commandline in that folder
Run the command: cmake -DBUILD_EXSAMPLES=ON ../opencv
Wait a long time for cmake to finish

Inside the folder you created for cmake, open
    apps/traincascade/opencv_traincascade.sln   with Visual Studio
In VS, on the top of the screen change the
    Solution Configurations from 'Debug' to 'Release'
In the solution explorer inside VS, click the folder applications
Then right-click opencv_traincascade, select
    Project Only -> Build only opencv_traincascade
(you might first have to select Clean Only opencv_traincascade)
It should now be compiling.
When compiling is done, the executable should be in
    [cmakefolder]/bin/release/opencv_traincascade.exe

To actually use the program, see
    https://docs.opencv.org/3.4/dc/d88/tutorial_traincascade.html
Running the program goes like this:
open command line in [cmakefolder]/bin/release
Run the command:
    opencv_traincascade -commandoption1 argument1 -commandoption2 argument2
Of course you have to fill in the commandoptions yourself
    (again, see https://docs.opencv.org/3.4/dc/d88/tutorial_traincascade.html)