cvCvtColor nv12 from V4l buffer

asked 2015-09-01 18:32:24 -0500

Hi people i have a problem when i try con conver nv12 buffer to BGR and write to jpeg.

This is the code

void* detect(void  * ptr_data)
{
        LOGI("enter to detect");
        CvMat cvmat;
        CvMat cvMatConverted;
        cvmat = cvMat(720, 1280,  CV_8UC3, ptr_data);
        LOGI("cvmat: cols %d, rows %d, ptr %u\n", cvmat.cols, cvmat.rows,cvmat.data);
        LOGI("before converted");
        cvMatConverted = cvMat(720,1280, CV_8UC3, &ptr_data);
        LOGI("before cvtcolor");
        cvCvtColor(&cvmat,&cvMatConverted,CV_YUV2BGR_NV12);
        LOGI("after cvtcolor");
        cvSaveImage("/sdcard/emma-frame.jpg",&cvMatConverted,0);
        return NULL ;
}

the error says that can not convert because:

E/cv::error()( 1749): OpenCV Error: Assertion failed (dst.data == dst0.data) in void cvCvtColor(const CvArr, CvArr, int), file /hdd2/buildbot/slaves/slave_ardbeg1/50-SDK/opencv/modules/imgproc/src/color.cpp, line 4424

edit retag flag offensive close merge delete

Comments

1

please use cv::Mat and cv::cvtColor, not the deprecated c-api.

berak gravatar imageberak ( 2015-09-02 00:57:15 -0500 )edit

i use the cv::cvtColor from cpp lib and now i have an image broken equally this is the code now http://pastebin.com/gsGDFSmu and this is the result image https://drive.google.com/file/d/0Bz9I...

gonzafirewall gravatar imagegonzafirewall ( 2015-09-02 12:12:11 -0500 )edit

I resolved using opencv in c++ and before to saving use a sws_scale conversion from NV12 to BGR24 before i show you the code resulting

gonzafirewall gravatar imagegonzafirewall ( 2015-09-02 15:11:01 -0500 )edit