Ask Your Question
1

Converting YUV to RGBA generates a gray preview

asked 2013-01-10 04:57:35 -0600

liran gravatar image

updated 2013-01-10 04:58:19 -0600

Hi,

I am trying to covert YUV to RGBA using openCV, but the preview somehow is gray. here is the relevant code:

if(mYuv != null) mYuv.release();
  mYuv = new Mat(mFrameHeight+mFrameHeight/2, mFrameWidth, CvType.CV_8UC1);
if(Sample2View.mRgba != null) Sample2View.mRgba.release();
  Sample2View.mRgba = new Mat(mFrameHeight, mFrameWidth,CvType.CV_8UC4);
     ....
       while(mThreadRun) {
        synchronized(this) {
            try {
                this.wait();
                mYuv.put(0, 0, mFrame);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
          ...
Imgproc.cvtColor(mYuv,mRgba,Imgproc.COLOR_YUV2RGBA_I420);

what am I doing wrong that makes the preview gray and not colored?

Thanks for the help!

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2013-01-10 06:13:19 -0600

rics gravatar image

There is a similar code snippet in OpenCV tutorials. Based on Tutorial 1 I think that you should use Imgproc.COLOR_YUV420sp2RGB instead of Imgproc.COLOR_YUV2RGBA_I420.

edit flag offensive delete link more

Comments

1

Thanks, it works!

liran gravatar imageliran ( 2013-01-10 06:27:30 -0600 )edit

Question Tools

Stats

Asked: 2013-01-10 04:57:35 -0600

Seen: 3,339 times

Last updated: Jan 10 '13