3

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?

Angie Quijano
  • 4,167
  • 3
  • 25
  • 30
black
  • 1,151
  • 3
  • 18
  • 46

1 Answers1

2

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.

GPPK
  • 6,546
  • 4
  • 32
  • 57