Note that there are some explanatory texts on larger screens.

plurals
  1. POmediacodec and opencv mismatch color type
    text
    copied!<p>I have 2 apps, 1 I implement on <strong>Matlab(c) using OpenCV</strong> and the second is on <strong>eclipse(android,java) using MediaCodec</strong>.</p> <p>I want to Decode the first frame from a same mp4 video(I need more than 1 frame, I look at the first one only for debugging, that's why I chose MediaCodec and OpenCV).</p> <p>In Matlab I do this: </p> <pre><code> currFrame = videoFReader.read; % Convert to grayscale %currGray = Convert_Movie_To_Gray(currFrame); % Works on a single frame as well currGray = cv.cvtColor(currFrame,'BGR2GRAY'); </code></pre> <p>while currFrame is the <code>Frame[0]</code> and currGray is the grayscale frame.</p> <p>In Eclipse I do this:</p> <pre><code> GLES20.glReadPixels(0, 0, mWidth, mHeight, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, mPixelBuf); mPixelBuf.rewind(); int[] colors = mColorSwapBuf; mPixelBuf.asIntBuffer().get(colors); NativeClass.GrayIntArrayToMat(colors, mainMat.getNativeObjAddr()); </code></pre> <p>while <code>GrayIntArrayToMat</code> is a native function that convert the frames to grayscale:</p> <pre><code> for(int i = 0 ; i&lt; out-&gt;cols * out-&gt;rows; i++) { int col = inputarray[i]; int R,G,B; B = (col &gt;&gt; 16) &amp; 0xff; G = (col &gt;&gt; 8) &amp; 0xff; R = col &amp; 0xff; inputarray[i] = (int)(((((R*0.3) + (G*0.59) + (B*0.11))))); res[i] = inputarray[i]; } </code></pre> <p>My problem is that I don't get the same colors in both examples. If I look at the first 10 columns of the first row, I'm getting this(grayscale frame):</p> <pre><code>[27, 27, 27, 27, 27, 27, 29, 30, 31, 32] - in Matlab [27, 28, 27, 29, 28, 29, 30, 31, 31, 31] - in Eclipse </code></pre> <p>My reference is the Matlab, so I need to get the same or at least closer frame to his frame.</p> <p>Thanks for your help!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload