Ask Your Question
0

Cannot Figure Out How To Run OpenCV

asked 2020-10-07 14:40:03 -0600

Hi there, I'm somewhat new to programming and have just been introduced to OpenCV. I'm trying to use opencv_traincascade for a project to detect whether someone is sleeping while driving. After reading the tutorial:

https://docs.opencv.org/master/dc/d88...

I understand what I have to do in terms of the overall process. What I can't seem to do is get any of the opencv apps to work in terminal (I'm a MacOS user). Every time this is what happens:

fatal error: 'opencv2/core.hpp' file not found

when I type the command:

g++ -o traincascade traincascade.cpp

I downloaded OpenCV and tested it to make sure it worked in VSC with this tutorial:

https://thecodinginterface.com/blog/o...

And everything seemed to work fine. I know this is probably a dumb question but I cannot figure it out for the life of me. Any help is appreciated.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2020-10-11 15:15:49 -0600

crackwitz gravatar image

the compiler needs to be told where the header files ("include" directory) can be found.

the compiler also needs to know where the library files ("lib" directory) can be found.

where those are depends on how and where you installed OpenCV.

when you call g++ like that, you're responsible for everything. when you use cmake, cmake can find those things for you and construct a Makefile or other project file that contains this information.

to a beginner I would recommend using Python instead of C++. for python there's someone who has been providing a decently built module you can just install with "pip install opencv-python".

edit flag offensive delete link more

Comments

I completely agree and to be frank, I'm more familiar with Python. But, this is for a school project and must be in C++. Thank you for the advice!

ryPython1024 gravatar imageryPython1024 ( 2020-10-24 11:08:07 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2020-10-07 14:40:03 -0600

Seen: 497 times

Last updated: Oct 11 '20