Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Converting YUV to RGBA gives a gray preview

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!

Converting YUV to RGBA gives generates a gray preview

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!