Sorry, this content is no longer available

Ask Your Question
1

Converting YUV to RGBA generates a gray preview

asked Jan 10 '13

liran gravatar image

updated Jan 10 '13

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!

Preview: (hide)

1 answer

Sort by » oldest newest most voted
1

answered Jan 10 '13

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.

Preview: (hide)

Comments

1

Thanks, it works!

liran gravatar imageliran (Jan 10 '13)edit

Question Tools

Stats

Asked: Jan 10 '13

Seen: 3,352 times

Last updated: Jan 10 '13