Can't compile OpenCV code (C ++)

Ok so I have been looking for this problem for a while and I still don't know how to solve it.

I am trying to run the sample code available here: http://docs.opencv.org/trunk/d1/dc5/tutorial_background_subtraction.html . I understand the code. I just can't compile it! The problem is what the library includes . Here my Makefile

:

CFLAGS = `pkg-config --cflags opencv`
LIBS = `pkg-config --libs opencv`

% : %.cpp
    g++ $(CFLAGS) $(LIBS) -o $@ $<

      

Here's the error :

prakhar@inS4n3 ~/dev/gender recognition $ make bs
g++ `pkg-config --cflags opencv` `pkg-config --libs opencv` -o bs bs.cpp
bs.cpp:2:33: fatal error: opencv2/imgcodecs.hpp: No such file or directory
 #include "opencv2/imgcodecs.hpp"
                                 ^
compilation terminated.
Makefile:5: recipe for target 'bs' failed
make: *** [bs] Error 1

      

If I (for now) comment out this file, I get a similar error with imgproc.hpp

. In another of my code, the OpenCV

following compilations are prefect :

#include "opencv2/core/core.hpp"
#include "opencv2/contrib/contrib.hpp"
#include "opencv2/highgui/highgui.hpp"

      

As far as I can tell, replacing opencv2/core.hpp

with opencv2/core/core.hpp

or replacing opencv2/imgproc.hpp

with opencv2/imgproc/imgproc.hpp

does the job.

So I looked deeper and here is my folder opencv2

:

prakhar@inS4n3 /usr/include/opencv2 $ ll
total 84
drwxr-xr-x 2 root root 4096 Nov 14 19:42 calib3d
drwxr-xr-x 2 root root 4096 Nov 14 19:42 contrib
drwxr-xr-x 2 root root 4096 Nov 14 19:42 core
drwxr-xr-x 2 root root 4096 Nov 14 19:42 features2d
drwxr-xr-x 2 root root 4096 Nov 14 19:42 flann
drwxr-xr-x 3 root root 4096 Nov 14 19:42 gpu
drwxr-xr-x 2 root root 4096 Nov 14 19:42 highgui
drwxr-xr-x 2 root root 4096 Nov 14 19:42 imgproc
drwxr-xr-x 2 root root 4096 Nov 14 19:42 legacy
drwxr-xr-x 2 root root 4096 Nov 14 19:42 ml
drwxr-xr-x 2 root root 4096 Nov 14 19:42 nonfree
drwxr-xr-x 2 root root 4096 Nov 14 19:42 objdetect
drwxr-xr-x 2 root root 4096 Nov 14 19:42 ocl
-rw-r--r-- 1 root root 2751 Oct  1  2014 opencv.hpp
-rw-r--r-- 1 root root  672 Nov 12 00:02 opencv_modules.hpp
drwxr-xr-x 2 root root 4096 Nov 14 19:42 photo
drwxr-xr-x 3 root root 4096 Nov 14 19:42 stitching
drwxr-xr-x 2 root root 4096 Nov 14 19:42 superres
drwxr-xr-x 2 root root 4096 Nov 14 19:42 ts
drwxr-xr-x 2 root root 4096 Nov 14 19:42 video
drwxr-xr-x 2 root root 4096 Nov 14 19:42 videostab

      

Can anyone tell me why this is happening and how do I get the modules imgcodecs.hpp

and videoio.hpp

?
I am using OpenCV

2.4.10-2

, on Arch Linux.

+3


source to share


1 answer


Ok, with the help of @Micka, I finally figured out that the document is for OpenCV 3.0 beta

and not 2.4.10

. So making changes to this solves the problem.

However, I just installed 3.0 beta and it worked great.



Here 's a moving guide that was hard for me to find (still don't know why!).

+3


source







All Articles