opencv2/core.hpp: No such file or directory
Closed this issue · 7 comments
I was trying to compile the code,
but make
gave me the following error:
In file included from src/DrawAux.cpp:1:0:
include/DrawAux.h:1:28: fatal error: opencv2/core.hpp: No such file or directory
#include <opencv2/core.hpp>
^
compilation terminated.
make: *** [Bin/Intermediate/x64-Release/BodySkeletonTracker/DrawAux.o] Error 1
the code is not finding opencv2/core.hpp but it successfully installed and I can find it under: /usr/include/opencv2/core/core.hpp
what should I do to make it visible to the code?
Thanks
Hi @ItsJas,
Are you running on Linux? Try to run this command on your Linux terminal:
pkg-config --cflags --libs opencv
Here on my machine the command exit is:
-I/usr/local/include/opencv -I/usr/local/include -L/usr/local/lib -lopencv_shape -lopencv_stitching -lopencv_objdetect -lopencv_superres -lopencv_videostab -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_video -lopencv_photo -lopencv_ml -lopencv_imgproc -lopencv_flann -lopencv_viz -lopencv_core
This command is used at the Makefile, and it has the flags for include the opencv head files (-I/usr/local/include/opencv -I/usr/local/include).
Please check you when you run the command this part appears. If don't you can add this to the Makefile at the line #39:
INC_DIRS += $(OPENNI2_INCLUDE)
to that:
INC_DIRS += $(OPENNI2_INCLUDE) -I/usr/local/include/opencv -I/usr/local/include
Hope that it helps.
Best regards,
Derzu.
Hi @derzu ,
Thanks for your reply,
Yes I'm running on Linux, precisely on Ubuntu 14.04.
In my case the pkg-config --cflags --libs opencv
command gave me the following output:
-I/usr/include/opencv /usr/lib/x86_64-linux-gnu/libopencv_calib3d.so ...
I tried adding /usr/local/include/opencv , /usr/local/include and /usr/include/opencv to the make file but nothing changed.
I do have the core.hpp file under /usr/include/opencv2/core/ so I changed the include from #include <opencv2/core.hpp> to #include <opencv2/core/core.hpp> and I did so for all the other opencv2 imports since I do have the .hpp files under a directory with the same name all the time.
in this case I no longer have import errors but I do have new ones:
please see the make command output: log.txt
Thanks,
Regards,
ItsJas.
Hi @ItsJas,
I don't know why the following line is not compiling, maybe is same compiler version difference.
p1 /= subSample;
But you can change the line to:
p1.x /= subSample;
p1.y /= subSample;
or:
p1.x = p1.x/subSample;
p1.y = p1.y/subSample;
Let me know if it works now.
Best regards,
Derzu.
This answer explains:
https://stackoverflow.com/a/43701862/1178478
Add opencv2 file to /usr/include directory
In my case, pkg-config --cflags --libs opencv
was giving me No package 'opencv' found
. I realised my opencv version was 4.
In this case, locate
(sudo apt install mlocate
) gave me a large output, being the first line:
locate opencv2
/usr/include/opencv4/opencv2
Also following @Ankita-Singh-21 's comment, I copied that opencv2 folder to /usr/include
, and make gives another error:
$ make
g++ -MD -MP -MT "./Bin/Intermediate/x64-Release/BodySkeletonTracker/DrawAux.d Bin/Intermediate/x64-Release/BodySkeletonTracker/DrawAux.o" -c -msse3 -DUNIX -DGLX_GLXEXT_LEGACY -DDEPTH -O2 -DNDEBUG -Iinclude -I/home/brooklyn/Downloads/OpenNI-Linux-x86-2.2.0.33/OpenNI-Linux-x86-2.2/Include -fPIC -fvisibility=hidden -Werror -o Bin/Intermediate/x64-Release/BodySkeletonTracker/DrawAux.o src/DrawAux.cpp
g++ -MD -MP -MT "./Bin/Intermediate/x64-Release/BodySkeletonTracker/main.d Bin/Intermediate/x64-Release/BodySkeletonTracker/main.o" -c -msse3 -DUNIX -DGLX_GLXEXT_LEGACY -DDEPTH -O2 -DNDEBUG -Iinclude -I/home/brooklyn/Downloads/OpenNI-Linux-x86-2.2.0.33/OpenNI-Linux-x86-2.2/Include -fPIC -fvisibility=hidden -Werror -o Bin/Intermediate/x64-Release/BodySkeletonTracker/main.o src/main.cpp
g++ -MD -MP -MT "./Bin/Intermediate/x64-Release/BodySkeletonTracker/Point3D.d Bin/Intermediate/x64-Release/BodySkeletonTracker/Point3D.o" -c -msse3 -DUNIX -DGLX_GLXEXT_LEGACY -DDEPTH -O2 -DNDEBUG -Iinclude -I/home/brooklyn/Downloads/OpenNI-Linux-x86-2.2.0.33/OpenNI-Linux-x86-2.2/Include -fPIC -fvisibility=hidden -Werror -o Bin/Intermediate/x64-Release/BodySkeletonTracker/Point3D.o src/Point3D.cpp
g++ -MD -MP -MT "./Bin/Intermediate/x64-Release/BodySkeletonTracker/SampleViewer.d Bin/Intermediate/x64-Release/BodySkeletonTracker/SampleViewer.o" -c -msse3 -DUNIX -DGLX_GLXEXT_LEGACY -DDEPTH -O2 -DNDEBUG -Iinclude -I/home/brooklyn/Downloads/OpenNI-Linux-x86-2.2.0.33/OpenNI-Linux-x86-2.2/Include -fPIC -fvisibility=hidden -Werror -o Bin/Intermediate/x64-Release/BodySkeletonTracker/SampleViewer.o src/SampleViewer.cpp
src/SampleViewer.cpp: In member function ‘virtual void SampleViewer::display()’:
src/SampleViewer.cpp:311:50: error: ‘CV_WINDOW_NORMAL’ was not declared in this scope
311 | cvNamedWindow("Skeleton Traker", CV_WINDOW_NORMAL | CV_WINDOW_KEEPRATIO | CV_GUI_EXPANDED);
| ^~~~~~~~~~~~~~~~
src/SampleViewer.cpp:311:69: error: ‘CV_WINDOW_KEEPRATIO’ was not declared in this scope
311 | cvNamedWindow("Skeleton Traker", CV_WINDOW_NORMAL | CV_WINDOW_KEEPRATIO | CV_GUI_EXPANDED);
| ^~~~~~~~~~~~~~~~~~~
src/SampleViewer.cpp:311:91: error: ‘CV_GUI_EXPANDED’ was not declared in this scope
311 | cvNamedWindow("Skeleton Traker", CV_WINDOW_NORMAL | CV_WINDOW_KEEPRATIO | CV_GUI_EXPANDED);
| ^~~~~~~~~~~~~~~
src/SampleViewer.cpp:311:17: error: ‘cvNamedWindow’ was not declared in this scope
311 | cvNamedWindow("Skeleton Traker", CV_WINDOW_NORMAL | CV_WINDOW_KEEPRATIO | CV_GUI_EXPANDED);
| ^~~~~~~~~~~~~
src/SampleViewer.cpp:316:24: error: ‘CV_FOURCC’ was not declared in this scope
316 | CV_FOURCC('D','I','V','X'),
| ^~~~~~~~~
src/SampleViewer.cpp: In member function ‘int SampleViewer::initOpenNI(const char*)’:
src/SampleViewer.cpp:118:1: error: control reaches end of non-void function [-Werror=return-type]
118 | }
| ^
cc1plus: all warnings being treated as errors
make: *** [CommonCppMakefile:133: Bin/Intermediate/x64-Release/BodySkeletonTracker/SampleViewer.o] Error 1
Which led me to this issue, related to opencv versioning. Still working around to fix it.