Ask Your Question
0

putText with opencv 2.4

asked 2013-06-02 07:09:40 -0600

MarcVO gravatar image

I'm trying to use putText as openCV doc explains:

string text = "Funny text inside the box";
int fontFace = cv::FONT_HERSHEY_SCRIPT_SIMPLEX;
double fontScale = 2;
int thickness = 3;

cvPutText(img1, text, cvPoint(30,30), fontFace, fontScale, cvScalar(200,200,250), thickness, 8);

but I can't compile because I receive the message: no matching function for call 'cvPutText'

if I use: putText(img1, text, cvPoint(30,30), fontFace, fontScale, cvScalar(200,200,250), thickness, 8); the error is: use of undeclared identifier 'putText', did you mean cv::putText?

I'm using xCode over OS X 10.8.3

where is my error? (I just want to write some text in my image)

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
1

answered 2013-06-02 07:23:02 -0600

Guanta gravatar image

First of all, don't mix C with C++. Include (and of course link against it) <opencv2/core/core.hpp> (guess you do that already since the compiler suggest already using cv::-prefix) and use cv::putText(). putText() is declared in the namespace cv, so either write "using namespace cv" above your class, or write the namespaces like cv:: and std:: explicitly to each command (I prefer the latter one so I always know where each command stems from).

edit flag offensive delete link more

Comments

Thanks! as you suggest already write cv::putText()….. but now the error is: Non-const Ivalue reference to type 'cv::Mat cannot bind to a value of unrelated type 'IplImage' (aka'_IplImage') why? my image is perfectly showed before the putText

MarcVO gravatar imageMarcVO ( 2013-06-02 07:38:09 -0600 )edit
1

cv::putText() expects a cv::Mat not an IplImage, so either convert it to a cv::Mat or better: don't use IplImage at all, i.e. use:

cv::Mat image = cv::imread(&lt;your_path_to_image&gt;);

to read in your image, then stick to the C++ api (the C-api won't be developed further)

Guanta gravatar imageGuanta ( 2013-06-02 08:11:14 -0600 )edit

thanks again, sorry for my c++ low level and thanks for your patience… but, whats the meaning of &lt and &gt? I have written: cv::Mat img = cv::imread("/users/sunny/image.jpg"); and now the error is: Undefined symbols for architecture x86_64: "cv::imread(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int)", referenced from: _main in main.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

Marc

MarcVO gravatar imageMarcVO ( 2013-06-02 16:13:47 -0600 )edit

'&lt' and '&gt' are the '<' and '>' symbols, which the forum-software somehow breaks if used in comments with code-tag. For your problem: have you included opencv2/highgui/highui.hpp and more important: have you also linked against it? Seems you haven't, so you need to fix your build-process.

Guanta gravatar imageGuanta ( 2013-06-03 06:17:35 -0600 )edit

Question Tools

Stats

Asked: 2013-06-02 07:09:40 -0600

Seen: 5,949 times

Last updated: Jun 02 '13