Ask Your Question

Kirill's profile - activity

2015-11-20 02:47:38 -0600 asked a question Assert on P and R parameters depth in initUndistortRectifyMap

Hello!

I use OpenCV-3.0 for correct fisheye image.

Follow my code

cv::Mat in(height * 3 / 2, width, CV_8UC1, pBuf);
cv::Mat out;
cv::Mat _rgb;
cv::cvtColor(in, out, CV_YUV2RGB_YV12);
cv::Matx33d K(_coefficient.fx, 0, _coefficient.cx, 0, _coefficient.fy, _coefficient.cy, 0, 0, 1);
cv::Vec4d D(_coefficient.k1, _coefficient.k2, _coefficient.k3, _coefficient.k4);
cv::fisheye::undistortImage(out, _rgb, K, D);

Unfortunately code exit with assert

OpenCV Error: Assertion failed ((P.depth() == CV_32F || P.depth() == CV_64F) && (R.depth() == CV_32F || R.depth() == CV_64F)) in initUndistortRectifyMap, file /opencv/modules/calib3d/src/fisheye.cpp, line 409

I not understand reason this assert because I think what I set correct K and D variables.

How can I solve this problem?

Thank you and excuse my bad english.

2014-03-25 03:23:58 -0600 asked a question YUV420: text color

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.