Reputation: 1241
I'm using OpenCV 2.4.11 in C++. I want to display a text with the putText()
function on my picture.
For example:
putText(imageOutput,"x:",Point(pos[0],pos[1]),1,1,Scalar(255,0,0),2);
What does the Scalar
input do? Is there an alternative input instead of Scalar
?
Upvotes: 3
Views: 1259
Reputation: 6666
Your code:
putText(imageOutput,"x:",Point(pos[0],pos[1]),1,1,Scalar(255,0,0),2);
Your question:
What does the Scalar function do?
You are creating a Scalar object, you can see the documentation here
If you want to create a BGR (full colour) image then you can initialise the Scalar with Scalar(B,G,R)
. However if you only want a greyscale image all you need to do is initialise it with your greyscale value:
Scalar(greyScaleValue);
so your code would be:
putText(imageOutput,"x:",Point(pos[0],pos[1]),1,1,Scalar(30),2);
for a greyscale value of 30.
Upvotes: 2