Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

putText is displaying text in wrong color

Hello,

I am trying to use putText to place text on my webcam video stream. I was able to have the text displayed on the window, but the color is displayed wrong. From my understanding, color is expressed in BGR in OpenCV, hence I expect (255,0,0) should display Blue; (0,255,0) should display Green; (0,0,255) should display Red.

In my code, I tried 3 colors as:

namedWindow("Live", WINDOW_NORMAL);

resizeWindow("Live", 640, 480);

putText(frame, "Press 'C' to start calibration", Point(10, 20), FONT_HERSHEY_SIMPLEX, 0.6, (0, 0, 255), 2);

putText(frame, "Press 'Q' to quit", Point(10, 40), FONT_HERSHEY_SIMPLEX, 0.6, (0, 255, 0), 2);

putText(frame, to_string(num_img) + " Chessboards are detected ", Point(10, 60), FONT_HERSHEY_SIMPLEX, 0.5, (255, 0, 0), 2);

imshow("Live", frame);

I was expecting the 3 lines of text to be Red, Green, and Blue. But the result is displayed as Blue Black Blackimage description

I wonder where did I do wrong.

Thanks in advance.

putText is displaying text in wrong color

Hello,

I am trying to use putText to place text on my webcam video stream. I was able to have the text displayed on the window, but the color is displayed wrong. From my understanding, color is expressed in BGR in OpenCV, hence I expect (255,0,0) should display Blue; (0,255,0) should display Green; (0,0,255) should display Red.

In my code, I tried 3 colors as:

namedWindow("Live", WINDOW_NORMAL);

WINDOW_NORMAL);

resizeWindow("Live", 640, 480);

480);

putText(frame, "Press 'C' to start calibration", Point(10, 20), FONT_HERSHEY_SIMPLEX, 0.6, (0, **(0, 0, 255), 2);

255)**, 2);

putText(frame, "Press 'Q' to quit", Point(10, 40), FONT_HERSHEY_SIMPLEX, 0.6, (0, **(0, 255, 0), 2);

0)**, 2);

putText(frame, to_string(num_img) + " Chessboards are detected ", Point(10, 60), FONT_HERSHEY_SIMPLEX, 0.5, (255, **(255, 0, 0), 2);

0)**, 2);

imshow("Live", frame);

frame);

I was expecting the 3 lines of text to be Red, Green, and Blue. But the result is displayed as Blue Black Blackimage description

I wonder where did I do wrong.

Thanks in advance.