0

i got a program from my lecturer and here the code:

#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;
}

but when i compile i receive these errors

error LNK2019: unresolved external symbol __CrtDbgReportW referenced in function "void __cdecl std::_Debug_message(wchar_t const *,wchar_t const *,unsigned int)" (?_Debug_message@std@@YAXPB_W0I@Z) C:\Users\LENOVO\Desktop\Tugas\Smst6\Citra\lab2\lab2\libcpmtd.lib(stdthrow.obj) lab2

error LNK1120: 1 unresolved externals C:\Users\LENOVO\Desktop\Tugas\Smst6\Citra\lab2\Debug\lab2.exe 1 1 lab2

im using visual studio 2010 and openvc 2.4.8

2 Answers2

0

check msdn for description error LNK2019 , I also faced this kind of error while my application development, on brief analysis also found error in vcxprojs file of the project, In my case it was corrupted. Also have you done the setup for Opencv on you machine before using the code. If yes then might be something to do with vcxproj. Please let me know for more questions.

Mayur
  • 789
  • 10
  • 37
0

Are you using CMake to build and configure? If so, you may need to modify it to include the libraries as well. For lnk1120 errors, check your additional dependencies, you've probably missed out a library.

lnk1120 MSDN

lnk2019 MSDN

Also see - I'm getting LNK2019 errors using SDL 2.0.1 in Visual Studio 2013

Community
  • 1
  • 1
catalyst
  • 95
  • 1
  • 6