我從講師有一個程序和這裏的代碼:錯誤LNK2019和LNK1120同時使用OpenCV的
#include <iostream>
#include <opencv2/opencv.hpp>
int main(int argc, char* argv[])
{
printf("Hit ESC key to quit ...\n");
cv::VideoCapture cap(0); // open the default camera
if(!cap.isOpened()) { // check if we succeeded
printf("error ‐ can't open the camera\n");
system("PAUSE");
return 1;
}
double WIDTH = cap.get(CV_CAP_PROP_FRAME_WIDTH);
double HEIGHT = cap.get(CV_CAP_PROP_FRAME_HEIGHT);
printf("Image width=%f, height=%f\n", WIDTH, HEIGHT);
// Create image window named "My Image". (You actually don't have to do
// this step, but this command allows you to set properties of the window,
// such as its location, or whether you can resize it.)
cv::namedWindow("My Image");
// Allocate images
cv::Mat imgInput(
cv::Size(WIDTH,HEIGHT), // specify size
CV_8UC3, // specify type: CV_8UC3=8bit, unsigned, 3 channels
cv::Scalar(0)); // initialize to this value (optional)
// Run an infinite loop until user hits the ESC key
while (1) {
cap >> imgInput; // get image from camera
// Show the image in the window
cv::imshow("My Image", imgInput);
// wait for x ms (0 means wait until a keypress)
if (cv::waitKey(1) == 27)
break; // ESC is ascii 27
}
return EXIT_SUCCESS;
}
但我編譯時收到這些錯誤
錯誤LNK2019:無法解析的外部符號__CrtDbgReportW引用功能 「無效__cdecl的std :: _ Debug_message(wchar_t的常量*,爲wchar_t const的*,無符號整型)」(_Debug_message @ STD @@ YAXPB_W0I @ Z?)C:\用戶\聯想\桌面\ Tugas \ Smst6 \特拉\實驗2 \實驗2 \ libcpmtd.lib(stdthrow.obj)實驗2
錯誤LNK1120:1周無法解析的外部ç :\用戶\聯想\桌面\ Tugas \ Smst6 \特拉\實驗2 \調試\ lab2.exe 1實驗2
IM使用Visual Studio 2010和openvc 2.4.8
是什麼在opencv2/opencv.hpp? – starsplusplus