i'm trying to learn openCV in C++ and i'm working on codeblocks 13.12 with the latest version of openCV on Windows 7(x64). As a beginning i tested a simple output of my webcam, witch worked without troubles. Next, i tried to make modify the output with cvtColor(img, img_gray, CV_BGR2GRAY)
. As you can see below i'm getting 2 error messages. Also to clarify, VisuWork vW
is a class that i made in order to code properly in OOP
as exercise. The class is not doing anything special.
Please can anyone help me to find an issue to this problem?
Tks for your help and time.
main.cpp :
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui_c.h>
#include <opencv/highgui.h>
using namespace cv;
using namespace std;
class VisuWork
{
CvCapture* capture;
public:
VisuWork()
{
capture=cvCaptureFromCAM(CV_CAP_ANY);
};
template<typename Type> void sHow(Type frame)
{
// IplImage* frame = cvQueryFrame(capture); //Create image frames from capture
cvShowImage("Camera_Output", frame); //Show image frames on created window
}
// void imHSV(IplImage* frame){
// Mat im(frame);
// Mat hsv;
// cvtColor(im, hsv, CV_BGR2HSV);
// }
~VisuWork()
{
cvReleaseCapture(&capture); //Release capture.
cvDestroyWindow("Camera_Output"); //Destroy Window
}
};
int main( int argc, const char** argv )
{
CvCapture* capture = 0;
capture = cvCaptureFromCAM(CV_CAP_ANY);
if (!capture)
{
// print error, quit application
}
else
{
VisuWork vW;
while(1) //Create infinte loop for live streaming
{
IplImage* im = cvQueryFrame(capture);
if(!im){}
else{
// vW.imHSV(frame);
Mat img_gray(im);
vW.sHow(im);
cvtColor(img, img_gray, CV_BGR2GRAY);
}
int key = cvWaitKey(10); //Capture Keyboard stroke
if (char(key) == 27)
{
break; //If you hit ESC key loop will break.
}
}
cvReleaseCapture(&capture); //Release capture.
cvDestroyWindow("Camera_Output"); //Destroy Window
}
}
The error messages:
C:\Users\PTOSH\Documents\tried.o:tried.cpp:(.text+0x7b): undefined reference to cv::Mat::Mat(_IplImage const*, bool)
C:\Users\PTOSH\Documents\tried.o:tried.cpp:(.text$_ZN2cv3MatD1Ev[__ZN2cv3MatD1Ev]+0x2d): undefined reference to cv::fastFree(void*)
This is the complete build log:
mingw32-g++.exe -std=c++11 -Wall -IC:\RPS\python\edp32\opencv\build\include -c C:\Users\PTOSH\Documents\tried.cpp -o C:\Users\PTOSH\Documents\tried.o mingw32-g++.exe -LC:\RPS\python\edp32\opencv\build\x86\vc12\lib -L"C:\Program Files (x86)\CodeBlocks\MinGW\lib" -LC:\RPS\python\edp32\opencv\sources\3rdparty -o C:\Users\PTOSH\Documents\tried.exe C:\Users\PTOSH\Documents\tried.o C:\RPS\python\edp32\opencv\build\x86\vc12\lib\opencv_calib3d248.lib C:\RPS\python\edp32\opencv\build\x86\vc12\lib\opencv_calib3d248d.lib C:\RPS\python\edp32\opencv\build\x86\vc12\lib\opencv_contrib248.lib C:\RPS\python\edp32\opencv\build\x86\vc12\lib\opencv_contrib248d.lib C:\RPS\python\edp32\opencv\build\x86\vc12\lib\opencv_core248.lib C:\RPS\python\edp32\opencv\build\x86\vc12\lib\opencv_core248d.lib C:\RPS\python\edp32\opencv\build\x86\vc12\lib\opencv_features2d248.lib C:\RPS\python\edp32\opencv\build\x86\vc12\lib\opencv_features2d248d.lib C:\RPS\python\edp32\opencv\build\x86\vc12\lib\opencv_flann248.lib C:\RPS\python\edp32\opencv\build\x86\vc12\lib\opencv_flann248d.lib C:\RPS\python\edp32\opencv\build\x86\vc12\lib\opencv_gpu248.lib C:\RPS\python\edp32\opencv\build\x86\vc12\lib\opencv_gpu248d.lib C:\RPS\python\edp32\opencv\build\x86\vc12\lib\opencv_highgui248.lib C:\RPS\python\edp32\opencv\build\x86\vc12\lib\opencv_highgui248d.lib C:\RPS\python\edp32\opencv\build\x86\vc12\lib\opencv_imgproc248.lib C:\RPS\python\edp32\opencv\build\x86\vc12\lib\opencv_imgproc248d.lib C:\RPS\python\edp32\opencv\build\x86\vc12\lib\opencv_legacy248.lib C:\RPS\python\edp32\opencv\build\x86\vc12\lib\opencv_legacy248d.lib C:\RPS\python\edp32\opencv\build\x86\vc12\lib\opencv_ml248.lib C:\RPS\python\edp32\opencv\build\x86\vc12\lib\opencv_ml248d.lib C:\RPS\python\edp32\opencv\build\x86\vc12\lib\opencv_nonfree248.lib C:\RPS\python\edp32\opencv\build\x86\vc12\lib\opencv_nonfree248d.lib C:\RPS\python\edp32\opencv\build\x86\vc12\lib\opencv_objdetect248.lib C:\RPS\python\edp32\opencv\build\x86\vc12\lib\opencv_objdetect248d.lib C:\RPS\python\edp32\opencv\build\x86\vc12\lib\opencv_ocl248.lib C:\RPS\python\edp32\opencv\build\x86\vc12\lib\opencv_ocl248d.lib C:\RPS\python\edp32\opencv\build\x86\vc12\lib\opencv_photo248.lib C:\RPS\python\edp32\opencv\build\x86\vc12\lib\opencv_photo248d.lib C:\RPS\python\edp32\opencv\build\x86\vc12\lib\opencv_stitching248.lib C:\RPS\python\edp32\opencv\build\x86\vc12\lib\opencv_stitching248d.lib C:\RPS\python\edp32\opencv\build\x86\vc12\lib\opencv_superres248.lib C:\RPS\python\edp32\opencv\build\x86\vc12\lib\opencv_superres248d.lib C:\RPS\python\edp32\opencv\build\x86\vc12\lib\opencv_ts248.lib C:\RPS\python\edp32\opencv\build\x86\vc12\lib\opencv_ts248d.lib C:\RPS\python\edp32\opencv\build\x86\vc12\lib\opencv_video248.lib C:\RPS\python\edp32\opencv\build\x86\vc12\lib\opencv_video248d.lib C:\RPS\python\edp32\opencv\build\x86\vc12\lib\opencv_videostab248.lib C:\RPS\python\edp32\opencv\build\x86\vc12\lib\opencv_videostab248d.lib C:\RPS\python\edp32\opencv\build\x64\vc12\lib\opencv_calib3d248.lib C:\RPS\python\edp32\opencv\build\x64\vc12\lib\opencv_calib3d248d.lib C:\RPS\python\edp32\opencv\build\x64\vc12\lib\opencv_contrib248.lib C:\RPS\python\edp32\opencv\build\x64\vc12\lib\opencv_contrib248d.lib C:\RPS\python\edp32\opencv\build\x64\vc12\lib\opencv_core248.lib C:\RPS\python\edp32\opencv\build\x64\vc12\lib\opencv_core248d.lib C:\RPS\python\edp32\opencv\build\x64\vc12\lib\opencv_features2d248.lib C:\RPS\python\edp32\opencv\build\x64\vc12\lib\opencv_features2d248d.lib C:\RPS\python\edp32\opencv\build\x64\vc12\lib\opencv_flann248.lib C:\RPS\python\edp32\opencv\build\x64\vc12\lib\opencv_flann248d.lib C:\RPS\python\edp32\opencv\build\x64\vc12\lib\opencv_gpu248.lib C:\RPS\python\edp32\opencv\build\x64\vc12\lib\opencv_gpu248d.lib C:\RPS\python\edp32\opencv\build\x64\vc12\lib\opencv_highgui248.lib C:\RPS\python\edp32\opencv\build\x64\vc12\lib\opencv_highgui248d.lib C:\RPS\python\edp32\opencv\build\x64\vc12\lib\opencv_imgproc248.lib C:\RPS\python\edp32\opencv\build\x64\vc12\lib\opencv_imgproc248d.lib C:\RPS\python\edp32\opencv\build\x64\vc12\lib\opencv_legacy248.lib C:\RPS\python\edp32\opencv\build\x64\vc12\lib\opencv_legacy248d.lib C:\RPS\python\edp32\opencv\build\x64\vc12\lib\opencv_ml248.lib C:\RPS\python\edp32\opencv\build\x64\vc12\lib\opencv_ml248d.lib C:\RPS\python\edp32\opencv\build\x64\vc12\lib\opencv_nonfree248.lib C:\RPS\python\edp32\opencv\build\x64\vc12\lib\opencv_nonfree248d.lib C:\RPS\python\edp32\opencv\build\x64\vc12\lib\opencv_objdetect248.lib C:\RPS\python\edp32\opencv\build\x64\vc12\lib\opencv_objdetect248d.lib C:\RPS\python\edp32\opencv\build\x64\vc12\lib\opencv_ocl248.lib C:\RPS\python\edp32\opencv\build\x64\vc12\lib\opencv_ocl248d.lib C:\RPS\python\edp32\opencv\build\x64\vc12\lib\opencv_photo248.lib C:\RPS\python\edp32\opencv\build\x64\vc12\lib\opencv_photo248d.lib C:\RPS\python\edp32\opencv\build\x64\vc12\lib\opencv_stitching248.lib C:\RPS\python\edp32\opencv\build\x64\vc12\lib\opencv_stitching248d.lib C:\RPS\python\edp32\opencv\build\x64\vc12\lib\opencv_superres248.lib C:\RPS\python\edp32\opencv\build\x64\vc12\lib\opencv_superres248d.lib C:\RPS\python\edp32\opencv\build\x64\vc12\lib\opencv_ts248.lib C:\RPS\python\edp32\opencv\build\x64\vc12\lib\opencv_ts248d.lib C:\RPS\python\edp32\opencv\build\x64\vc12\lib\opencv_video248.lib C:\RPS\python\edp32\opencv\build\x64\vc12\lib\opencv_video248d.lib C:\RPS\python\edp32\opencv\build\x64\vc12\lib\opencv_videostab248.lib C:\RPS\python\edp32\opencv\build\x64\vc12\lib\opencv_videostab248d.lib C:\Users\PTOSH\Documents\tried.o:tried.cpp:(.text+0x7b): undefined reference to
cv::Mat::Mat(_IplImage const*, bool)' C:\Users\PTOSH\Documents\tried.o:tried.cpp:(.text$_ZN2cv3MatD1Ev[__ZN2cv3MatD1Ev]+0x2d): undefined reference to
cv::fastFree(void)'* c:/program files (x86)/codeblocks/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: C:\Users\PTOSH\Documents\tried.o: bad reloc address 0x2d in section `.text$_ZN2cv3MatD1Ev[__ZN2cv3MatD1Ev]' c:/program files (x86)/codeblocks/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: final link failed: Invalid operation collect2.exe: error: ld returned 1 exit status Process terminated with status 1 (0 minute(s), 1 second(s)) 2 error(s), 0 warning(s) (0 minute(s), 1 second(s))