1

I'm trying to run the following code which i found online to see if i've set up opencv correctly,

#include "opencv2/opencv.hpp"
#include "opencv2/highgui/highgui.hpp"

using namespace std;

int main(int argc, char** argv) {

namedWindow("Output",1);

//initialize a 120X350 matrix of black pixels:
Mat output = Mat::zeros( 120, 350, CV_8UC3 );

//write text on the matrix:
putText(output,
        "Hello World :)",
        cvPoint(15,70),
        FONT_HERSHEY_PLAIN,
        3,
        cvScalar(0,255,0),
        4);

//display the image:
imshow("Output", output);

//wait for the user to press any key:
waitKey(0);

return 0;

}

And I'm getting the following errors when i compile,

main.cpp: In function 'int main(int, char**)':
main.cpp:12:27: error: 'namedWindow' was not declared in this scope
main.cpp:15:5: error: 'Mat' was not declared in this scope
main.cpp:15:9: error: expected ';' before 'output'
main.cpp:18:13: error: 'output' was not declared in this scope
main.cpp:21:13: error: 'FONT_HERSHEY_PLAIN' was not declared in this     scope
main.cpp:24:14: error: 'putText' was not declared in this scope
main.cpp:27:28: error: 'imshow' was not declared in this scope
main.cpp:30:14: error: 'waitKey' was not declared in this scope
nbproject/Makefile-Debug.mk:66: recipe for target `build/Debug/MinGW-  Windows/main.o' failed

I've compiled opencv 3.0.0 on windows and I've added the following properties to my project, Include directories - E:/software/opencv/build/include Additional Library directories - E:/software/opencv/release/lib And I've added all the libraries in E:/software/opencv/release/lib to linker libraries.

1
  • Have you added OpenCV to your Path environment variable? Commented Sep 4, 2015 at 10:11

1 Answer 1

1

I think this might be easy fix. Add:

 using namespace cv;

Above or below:

 using namespace std;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.