Prev: Kalman Filter
Next: Rotation of an ellipse in 3D
From: Fin Raziel on 20 Jan 2010 18:03 Hello I have a need to acquire and process images from a "Point Grey Research Chameleon" camera in MATLAB. I do not have the Image Acquisition Toolbox, however, I do have some C++ code making use of functions in OpenCV to do the acquisition and have been successful in compiling a C++ MEX file to get images into Matlab. I have been developing my program further and making use of a particular OpenCV function "cvCreateImage" which results in a compilation error as follows: g++ -Wall -fPIC -ansi -pthread -DMX_COMPAT_32 -DMATLAB_MEX_FILE -I/home/$USER$/matlab/extern/include -I/usr/local/include/opencv -c test2.cpp test2.cpp: In function ‘void mexFunction(int, mxArray**, int, const mxArray**)’: test2.cpp:32: warning: unused variable ‘frame_undistorted’ test2.cpp:39: warning: unused variable ‘intrinsic’ test2.cpp:40: warning: unused variable ‘distortion’ test2.cpp:48: warning: unused variable ‘mapx’ /home/$USER$/matlab/bin/mex -cxx CC='g++' CXX='g++' LD='g++' -L/usr/local/lib -lm -lcv -lhighgui -lcvaux -output test2 test2.o test2.o: In function `mexFunction': test2.cpp:(.text+0xe7): undefined reference to `cvCreateImage' collect2: ld returned 1 exit status mex: link of ' "test2.mexglx"' failed. make: *** [test2.mexglx] Error 1 My system is running Ubuntu 9.04 and I'm using the following makefile to compile the code: MEXSUFFIX = mexglx MATLABHOME = /home/$USER$/matlab MEX = $(MATLABHOME)/bin/mex CXX = g++ CFLAGS = -Wall -fPIC -ansi -pthread -DMX_COMPAT_32 -DMATLAB_MEX_FILE LIBS = -L/usr/local/lib -lm -lcv -lhighgui -lcvaux INCLUDE = -I$(MATLABHOME)/extern/include -I/usr/local/include/opencv MEXFLAGS = -cxx CC='$(CXX)' CXX='$(CXX)' LD='$(CXX)' FILE = test2 $(FILE).$(MEXSUFFIX): $(FILE).o $(MEX) $(MEXFLAGS) $(LIBS) -output $(FILE) $^ $(FILE).o: $(FILE).cpp $(CXX) $(CFLAGS) $(INCLUDE) -c $^ clean: rm -rf *.o *.mexglx *.bmp *.csv Now if I compile just using g++ and don't have anything to do with Matlab it compiles fine. The corresponding makefile is as follows: CC = g++ CFLAGS = -Wall LIBS = -L /usr/local/lib -lm -lcv -lhighgui -lcvaux INC = -I/usr/local/include/opencv FILE = test2 ${FILE} : ${FILE}.o ${CC} ${CFLAGS} ${OBJS} ${LIBS} ${FILE}.o -o ${FILE} ${FILE}.o: ${FILE}.cpp ${CC} ${CFLAGS} ${INC} -c ${FILE}.cpp It seems there is some MATLAB related issue causing the linking error. Any ideas on how to fix this? Cheers Fin
|
Pages: 1 Prev: Kalman Filter Next: Rotation of an ellipse in 3D |