LingDong- / fast-many-face-detection-with-cpp-or-openframeworks-on-mac-using-neural-networks

Fast Many Face Detection with C++/OpenFrameworks on macOS using Neural Networks
MIT License
14 stars 5 forks source link

fatal error: 'opencv2/opencv.hpp' file not found #2

Open stephanschulz opened 5 years ago

stephanschulz commented 5 years ago

I tried to follow your instructions. I am on macOS 10.14.2, OF 0.10.1, Xcode 10.1

When compiling in the terminal and Xcode I get an error related to not finding opencv2/opencv.hpp

I wonder if brew did not create the correct symbolic links?

My opencv version is 4.1.0_1 The question also is if I always need to refer to it with _1 or leave that out?

Thanks, Stephan. Screen Shot 2019-04-19 at 3 04 53 PM

LingDong- commented 5 years ago

Hi Stephan,

I think for OpenCV 4.x the -I path is different, it needs to be

-I/usr/local/Cellar/opencv/4.1.0_1/include/opencv4

So something like:

c++ main.cpp -std=c++11 -lopencv_highgui -lopencv_imgproc -lopencv_dnn -lopencv_core -lopencv_videoio -I/usr/local/Cellar/opencv/4.1.0_1/include/opencv4

I mentioned the correct path for 4.x in "with OF" section but haven't updated the "no OF" section.

If the new path works for you, I'll update the README.

Thanks

stephanschulz commented 5 years ago

Hey Lingdong. Thanks that solved this specific problem. For both the terminal noof example and the Xcode version. (did not test the OF terminal option)

But in Xcode it now complains about

/Applications/of_v0.10.1_osx_release/apps/myApps/mySketch/src/ofApp.h:32:24: Use of undeclared identifier 'CV_RGB2BGR'
Screen Shot 2019-04-19 at 4 34 34 PM
LingDong- commented 5 years ago

Hi Stephan,

It think OpenCV 4 changed their constant names.

Try cv::COLOR_RGB2BGR

stephanschulz commented 5 years ago

Sorry the easter bunny delayed my reply.

This error got resolved. But now new ones appeared.

Here is my project:

Screen Shot 2019-04-23 at 10 50 59 AM

https://www.dropbox.com/s/jjl3p493gkcen1j/mySketch.zip?dl=0

LingDong- commented 5 years ago

Hi Stephan,

I believe you need to add project PROJECT_CFLAGS to config.make, with the same content as PROJECT_LDFLAGS, like this:

PROJECT_CFLAGS += -lopencv_videostab -lopencv_photo -lopencv_objdetect -lopencv_video -lopencv_ml -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_flann -lopencv_imgproc -lopencv_dnn -lopencv_imgcodecs -lopencv_core
PROJECT_CFLAGS += -I/usr/local/Cellar/opencv/4.1.0_1/include/opencv4

See the 5th bullet point from the "OF+makefile" section in the README for details.

stephanschulz commented 5 years ago

Thanks Lingdong for your help. It now works.

One thing I learned is that I can't just double click in to "other linker flags" and add the info, because it deleted references to

$(OF_CORE_LIBS)
$(OF_CORE_FRAMEWORKS)
$(LIB_OF)

and other addons

Screen Shot 2019-04-24 at 1 57 08 PM