Ask Your Question

adin's profile - activity

2016-06-12 00:54:14 -0600 received badge  Popular Question (source)
2016-01-20 04:28:54 -0600 received badge  Popular Question (source)
2014-07-09 16:09:32 -0600 received badge  Teacher (source)
2014-07-09 14:33:16 -0600 received badge  Self-Learner (source)
2014-07-09 14:23:09 -0600 answered a question How to compile old OpenCV code using 2.4.9

Ok, finally the error was two fold in order to compile for the old OpenCV functions.

First, the problem is the use of old headers, so I changed the #include <opencv/cv.h> and use

#include <opencv2/legacy/legacy.hpp>
#include "opencv2/legacy/compat.hpp"

in my header files that included old headers.

Then, the makefile was wrong. It seems that to compile and link the linking libraries can only be in the last parameters of the call.

That is, g++ <flags> -o <target> <sources> <libs>, after fixing that order the files compile. I made a newer makefile, just in case someone stumble upon the same or similar problem.

CC=g++
CFLAGS=-Wall $(shell pkg-config --cflags opencv)
LDLIBS=$(shell pkg-config --libs opencv) 

all: main

# the main program, it uses the .o objects to rebuild
main: main.o global.o IntImage.h util.o mdarray.h
    $(CC) $(CFLAGS) -o main main.o global.o util.o $(LDLIBS)

# a target for all the objects
# it doesn't link (-c option)
%.o: %.cpp
    $(CC) $(CFLAGS) -c -o $@ $<

clean:
    rm -rf *.o main
2014-07-08 13:00:57 -0600 commented question How to compile old OpenCV code using 2.4.9

@unxnut I don't have other libraries. Just the ones I posted using the pkg-config. I don't understand why is not finding the symbols. Searching the web I found that there were some errors with the pkg-config of previous OpenCV releases. Not sure if that is the problem though.

2014-07-08 11:29:26 -0600 received badge  Editor (source)
2014-07-08 08:30:53 -0600 commented question How to compile old OpenCV code using 2.4.9

For the linking I'm using pkg-config --cflags opencv and pkg-config --libs opencv. The latter includes the legacy libopencv_legacy.so. But still gives me error. I build OpenCV myself, should I need some special flag to build legacy?

2014-07-07 14:13:49 -0600 asked a question How to compile old OpenCV code using 2.4.9

I'm trying to compile some old code of OpenCV that I found here.

However, the code seems quite old. I was able to compile it by adding the new headers

#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>

using namespace cv;

to the files global.h and IntImage.h, with addition of

#include <opencv/cv.h>

to the IntImage.h.

Note that I don't want to port all the code to OpenCV 2.4.9 right now, but rather to make it work. Thus, once that compile I still obtain the error:

UIUCscene.o: In function IntImage<double>::Load(std::string const&)': UIUCscene.cpp:(.text._ZN8IntImageIdE4LoadERKSs[_ZN8IntImageIdE4LoadERKSs]+0x20): undefined reference tocvLoadImage' UIUCscene.cpp:(.text._ZN8IntImageIdE4LoadERKSs[_ZN8IntImageIdE4LoadERKSs]+0x53): undefined reference to cvCreateImage' UIUCscene.cpp:(.text._ZN8IntImageIdE4LoadERKSs[_ZN8IntImageIdE4LoadERKSs]+0x6b): undefined reference tocvCvtColor' UIUCscene.cpp:(.text._ZN8IntImageIdE4LoadERKSs[_ZN8IntImageIdE4LoadERKSs]+0x78): undefined reference to cvReleaseImage' UIUCscene.cpp:(.text._ZN8IntImageIdE4LoadERKSs[_ZN8IntImageIdE4LoadERKSs]+0x73c): undefined reference to cvReleaseImage' collect2: error: ld returned 1 exit status make: * [place] Error 1

It seems to me that the problem is linking. However, I'm not sure where the problem is. In the Makefile the flags are set using pkg-config --cflags opencv, and the same for retrieving the libraries. The result of running pkg-config --libs opencv is

/usr/local/lib/libopencv_calib3d.so /usr/local/lib/libopencv_contrib.so /usr/local/lib/libopencv_core.so /usr/local/lib/libopencv_features2d.so /usr/local/lib/libopencv_flann.so /usr/local/lib/libopencv_gpu.so /usr/local/lib/libopencv_highgui.so /usr/local/lib/libopencv_imgproc.so /usr/local/lib/libopencv_legacy.so /usr/local/lib/libopencv_ml.so /usr/local/lib/libopencv_nonfree.so /usr/local/lib/libopencv_objdetect.so /usr/local/lib/libopencv_ocl.so /usr/local/lib/libopencv_photo.so /usr/local/lib/libopencv_stitching.so /usr/local/lib/libopencv_superres.so /usr/local/lib/libopencv_ts.a /usr/local/lib/libopencv_video.so /usr/local/lib/libopencv_videostab.so /usr/lib/x86_64-linux-gnu/libXext.so /usr/lib/x86_64-linux-gnu/libX11.so /usr/lib/x86_64-linux-gnu/libICE.so /usr/lib/x86_64-linux-gnu/libSM.so /usr/lib/x86_64-linux-gnu/libGL.so /usr/lib/x86_64-linux-gnu/libGLU.so -ltbb -lrt -lpthread -lm -ldl

as you can see, the legacy library is there.

What am I missing? Any help or pointers are appreciated.

2012-12-14 02:09:07 -0600 received badge  Nice Question (source)
2012-07-31 15:45:23 -0600 received badge  Student (source)
2012-07-31 01:16:17 -0600 received badge  Supporter (source)
2012-07-31 01:16:11 -0600 commented answer Can't checkout from SVN repository, version 2.4.2

Thanks for the info. It wasn't clear from the site. I suspect something like that. Maybe, all the site should be checked, as new people coming to the wiki may get confused.

2012-07-31 01:15:22 -0600 received badge  Scholar (source)
2012-07-31 00:59:07 -0600 asked a question Can't checkout from SVN repository, version 2.4.2

I'm trying to access the SVN repository as stated in the documentation: http://code.opencv.org/svn/opencv/tags/2.4.2 However, I got error when I tried to access it in the browser, and also through the SVN command line.

Should I access the repository somewhere else? This is strange because the official site says that this should work.