Hello!
I use opencv-2.4.8
Before encode YUV420 buffer I have to add some information, e.g. timestamp.
Follow my code:
cv::Mat *_img[3];
_img[0] = new cv::Mat(encop.picHeight, encop.picWidth, CV_8UC1,
reinterpret_cast<unsigned *="">(_src_mem.virt_uaddr));
_img[1] = new cv::Mat(encop.picHeight / 2, encop.picWidth / 2, CV_8UC1,
reinterpret_cast<unsigned *="">(_src_mem.virt_uaddr +
_size));
_img[2] = new cv::Mat(encop.picHeight / 2, encop.picWidth / 2, CV_8UC1,
reinterpret_cast<unsigned *="">(_src_mem.virt_uaddr +
_size + _size / 4));
CvScalar OCV::yuv_color(float red,
float green,
float blue)
{
return cvScalar(0.299 * red + 0.587 * green + 0.114 * blue,
-0.14713 * red - 0.28886 * green + 0.436 * blue,
0.615 * red - 0.51499 * green - 0.10001 * blue);
}
const CvScalar color = OCV::yuv_color(6.0, 249.0, 223.0);
putText(*_img[0], _osd, cv::Point(20, 20), cv::FONT_HERSHEY_SIMPLEX,
0.5, color, 0, 16);
putText(*_img[1], _osd, cv::Point(10, 10), cv::FONT_HERSHEY_SIMPLEX,
0.25, color, 0, 16);
putText(*_img[2], _osd, cv::Point(10, 10), cv::FONT_HERSHEY_SIMPLEX,
0.25, color, 0, 16);
Code work fine, but I have little proble:
1. I get green text if I use RGB color
2. I get magenta text if I use YUV color
How can control text color for YUV420?
Thank you and excuse my bad english.