title: OpenCV Android - color issue using CameraBridgeViewBase
body: <p>I'm encountering a strange problem using Android emulators &amp; OpenCV <code>CameraBridgeViewBase</code>.</p>
  
  <p>Using <code>onCameraFrame</code> I get a picture that looks like it wasn't decoded properly.</p>
  
  <pre><code>public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
      return inputFrame.rgba();
  }
  </code></pre>
  
  <p>Using 'inputFrame.gray()' I get what's expected - black and white image without artifacts or any other issues.</p>
  
  <p>That's what I get:</p>
  
  <p><img src="https://i.stack.imgur.com/qfz4q.png" alt="First picture"></p>
  
  <p><a href="https://i.stack.imgur.com/CsTgz.png" rel="nofollow noreferrer">One more picture (a bigger one)</a></p>
  
  <p>What I've tried so far:  </p>
  
  <ol>
  <li>Different API levels (from 15 up to 21).</li>
  <li>Different emulators: Genymotion &amp; Google Android emulator.</li>
  <li>Different platform architectures - both ARM and Intel x86.</li>
  <li>Launching emulator on different laptop with Linux: <strong>it works</strong> as expected, the issue is gone!</li>
  <li>Launching apps, using OpenCV, downloaded from Play Store. They DO work! <strong>However:</strong>
  
  <ol>
  <li>Launch app that works as expected, then close it.</li>
  <li>Launch your app (or one of the OpenCV tutorials), then close it.</li>
  <li>Launching app from the 5.1 again I see that it's affected by the same bug!</li>
  </ol></li>
  <li>Different OpenCV versions (2.4.9 and 2.4.10).</li>
  <li>Different versions of the OpenCV manager (one from the Play Store and 2.4.9 &amp; 2.4.10 from OpenCV package).</li>
  <li>Finally, as I noticed in 5.2, precompiled tutorial .apk files from the OpenCV package are affected by the issue too.</li>
  </ol>
  
  <p>Everything works as expected on my real android devices.</p>
  
  <p>After looking at sources of the <code>CameraBridgeViewBase</code> and Java/Native camera classes I came to the decision that the problem occurs while decoding image. Probably there is a problem with platform-specific camera output format (YUV, NV21). However, it's strange that .gray() gives out a proper image (without artifacts).</p>
  
  <p>I'm using Mac OS X 10.10 Yosemite and MacBook Air with "Facetime HD" camera if that matters.</p>
  
  <p>Any ideas on how to overcome this problem &amp; help in finding the root of the problem are greatly appreciated!</p>