title: Android CameraX Analyzer Image with format YUV_420_888 to OpenCV Mat
body: <p>With <strong>Android CameraX Analyzer</strong> <code>ImageProxy</code> uses <code>ImageReader</code> under the hood with a default <code>YUV_420_888</code> image format.</p>
  
  <p>I'd like to convert it in OpenCV <code>Mat</code> in order to use OpenCV inside my analyzer:</p>
  
  <pre><code>override fun analyze(imageProxy: ImageProxy, rotationDegrees: Int) {
      try {
        imageProxy.image?.let {
          // ImageProxy uses an ImageReader under the hood:
          // https://developer.android.com/reference/androidx/camera/core/ImageProxy.html
          // That has a default format of YUV_420_888 if not changed that's the default
          // Android camera format.
          // https://developer.android.com/reference/android/graphics/ImageFormat.html#YUV_420_888
          // https://developer.android.com/reference/android/media/ImageReader.html
  
          // Sanity check
          if (it.format == ImageFormat.YUV_420_888
              &amp;&amp; it.planes.size == 3
          ) {
             // TODO - convert ImageProxy.image to Mat
          } else {
            // Manage other image formats
            // TODO - https://developer.android.com/reference/android/media/Image.html
          }
        }
      } catch (ise: IllegalStateException) {
        ise.printStackTrace()
      }
    }
  </code></pre>
  
  <p>How can I do that?</p>