lần đầu tiên đăng câu hỏi ở đây để stackoverflow. Xin lỗi nếu tôi bán thịt định dạng!lỗi biểu tượng bên ngoài chưa được giải quyết khi nhập thư viện cho OpenCV2.3 trong Visual Studio 2010 Express C++
Tôi đang cố gắng làm theo một hướng dẫn cơ bản về OpenCV, cụ thể là cái này: http://aishack.in/tutorials/tracking-colored-objects-in-opencv/
tôi đã xem xét nhiều hướng dẫn trực tuyến về cách cài đặt OpenCV, bao gồm:
Setup OpenCV-2.3 for Visual Studio 2010 và opencv. willowgarage.com/wiki/VisualC%2B%2B
mà không có nhiều may mắn.
Phiên bản hiện tại tôi đang chạy ngay bây giờ là OpenCV 2.3.0. Tôi hiện đang chạy trên Windows 7 với Microsoft Visual C++ nhanh 2010.
Bất cứ khi nào tôi cố gắng xây dựng và chạy mã của tôi, tôi nhận được các lỗi sau đây:
1>------ Build started: Project: Camera, Configuration: Debug Win32 ------
1>camera.obj : error LNK2019: unresolved external symbol _cvReleaseImage referenced in function "struct _IplImage * __cdecl GetThresholdedImage(struct _IplImage *)" ([email protected]@[email protected]@[email protected]@Z)
1>camera.obj : error LNK2019: unresolved external symbol _cvInRangeS referenced in function "struct _IplImage * __cdecl GetThresholdedImage(struct _IplImage *)" ([email protected]@[email protected]@[email protected]@Z)
1>camera.obj : error LNK2019: unresolved external symbol _cvCvtColor referenced in function "struct _IplImage * __cdecl GetThresholdedImage(struct _IplImage *)" ([email protected]@[email protected]@[email protected]@Z)
1>camera.obj : error LNK2019: unresolved external symbol _cvCreateImage referenced in function "struct _IplImage * __cdecl GetThresholdedImage(struct _IplImage *)" (?GetTh[email protected]@[email protected]@[email protected]@Z)
1>camera.obj : error LNK2019: unresolved external symbol _cvGetSize referenced in function "struct _IplImage * __cdecl GetThresholdedImage(struct _IplImage *)" ([email protected]@[email protected]@[email protected]@Z)
1>camera.obj : error LNK2019: unresolved external symbol _cvReleaseCapture referenced in function _main
1>camera.obj : error LNK2019: unresolved external symbol _cvWaitKey referenced in function _main
1>camera.obj : error LNK2019: unresolved external symbol _cvShowImage referenced in function _main
1>camera.obj : error LNK2019: unresolved external symbol _cvAdd referenced in function _main
1>camera.obj : error LNK2019: unresolved external symbol _cvLine referenced in function _main
1>camera.obj : error LNK2019: unresolved external symbol _cvGetCentralMoment referenced in function _main
1>camera.obj : error LNK2019: unresolved external symbol _cvGetSpatialMoment referenced in function _main
1>camera.obj : error LNK2019: unresolved external symbol _cvMoments referenced in function _main
1>camera.obj : error LNK2019: unresolved external symbol _cvQueryFrame referenced in function _main
1>camera.obj : error LNK2019: unresolved external symbol _cvNamedWindow referenced in function _main
1>camera.obj : error LNK2019: unresolved external symbol _cvCreateCameraCapture referenced in function _main
1>C:\Users\Kevin\Documents\Visual Studio 2010\Projects\Camera\Debug\Camera.exe : fatal error LNK1120: 16 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Mã của tôi là như sau:
#include "cv.h"
#include "highgui.h"
IplImage* GetThresholdedImage(IplImage* img)
{
IplImage* imgHSV = cvCreateImage(cvGetSize(img), 8, 3);
cvCvtColor(img, imgHSV, CV_BGR2HSV);
IplImage* imgThreshed = cvCreateImage(cvGetSize(img), 8, 1);
cvInRangeS(imgHSV, cvScalar(20, 100, 100), cvScalar(30, 255, 255), imgThreshed);
cvReleaseImage(&imgHSV);
return imgThreshed;
}
int main()
{
CvCapture* capture = 0;
capture = cvCaptureFromCAM(1);
if(!capture)
{
printf("Could not initialize capturing...\n");
getchar();
return -1;
}
cvNamedWindow("video");
cvNamedWindow("thresh");
IplImage* imgScribble = NULL;
while(1)
{
IplImage* frame = 0;
frame = cvQueryFrame(capture);
if(!frame)
break;
//cvErode(frame, frame, 0, 2); // ADD this line
//initalize the scribble frame if has not already been done yet
if(imgScribble == NULL)
{
imgScribble = cvCreateImage(cvGetSize(frame), 8, 3);
}
IplImage* imgYellowThresh = GetThresholdedImage(frame);
CvMoments *moments = (CvMoments*)malloc(sizeof(CvMoments));
cvMoments(imgYellowThresh, moments, 1);
// The actual moment values
double moment10 = cvGetSpatialMoment(moments, 1, 0);
double moment01 = cvGetSpatialMoment(moments, 0, 1);
double area = cvGetCentralMoment(moments, 0, 0);
// Holding the last and current ball positions
static int posX = 0;
static int posY = 0;
int lastX = posX;
int lastY = posY;
posX = moment10/area;
posY = moment01/area;
printf("position (%d,%d)\n", posX, posY);
// We want to draw a line only if its a valid position
if(lastX>0 && lastY>0 && posX>0 && posY>0)
{
// Draw a yellow line from the previous point to the current point
cvLine(imgScribble, cvPoint(posX, posY), cvPoint(lastX, lastY), cvScalar(0,255,255), 5);
}
cvAdd(frame, imgScribble, frame);
cvShowImage("thresh", imgYellowThresh);
cvShowImage("video", frame);
int c = cvWaitKey(5);
if((char)c==27)
break;
// Release the thresholded image+moments... we need no memory leaks.. please
cvReleaseImage(&imgYellowThresh);
delete moments;
}
// We're done using the camera. Other applications can now use it
cvReleaseCapture(&capture);
cvReleaseCapture(&capture);
return 0;
}
tôi đã cài đặt mở CV để C:\OpenCV2.3
tôi đã thêm phụ thuộc bổ sung, thêm thư mục itional, vv. Đối với các ưu đãi cho dự án của tôi, họ là như sau:
Dependencies bổ sung:
enter code here
opencv_core230.lib
opencv_highgui230.lib
opencv_legacy230.lib
opencv_video230.lib
opencv_ml230.lib
opencv_core230d.lib
opencv_highgui230d.lib
opencv_legacy230d.lib
opencv_video230d.lib
opencv_ml230d.lib
opencv_calib3d230d.lib
aditional Thư viện Thư mục: Bao gồm C:\OpenCV2.3\build\x64\vc10\lib;C:\OpenCV2.3\build\x64\vc10\bin;C:\OpenCV2.3\build\x64\vc10\staticlib;%(AdditionalLibraryDirectories)
bổ sung Thư mục:
C:\OpenCV2.3\build\include\opencv;C:\OpenCV2.3\build\include\opencv2;C:\OpenCV2.3\build\include
Tôi cũng bao gồm một đường dẫn đến DLL trên biến đường dẫn của tôi cho các cửa sổ:
;C:\OpenCV2.3\build\x64\vc10\bin;C:\OpenCV2.3\build\bin;
Tôi đã xem các diễn đàn khác, các câu hỏi tràn ngăn xếp khác, vv mà không cần trợ giúp nhiều. Tôi đã cố gắng để có được điều này để làm việc cho một phần tốt hơn của một ngày cuối tuần. Bất kì sự trợ giúp nào đều được đánh giá cao!
tại sao cùng một câu hỏi được hỏi hai lần trong vòng 4 giờ: http://stackoverflow.com/questions/10472393/opencv-wont-compile-due-to-unresolved-externals-lnk2019#comment13530952_10472393 – guinny