Java Code Examples for android.graphics.ImageFormat#YV12
The following examples show how to use
android.graphics.ImageFormat#YV12 .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VideoCapture.java From android-chromium with BSD 2-Clause "Simplified" License | 6 votes |
@CalledByNative public int getColorspace() { switch (mImageFormat){ case ImageFormat.YV12: return AndroidImageFormatList.ANDROID_IMAGEFORMAT_YV12; case ImageFormat.NV21: return AndroidImageFormatList.ANDROID_IMAGEFORMAT_NV21; case ImageFormat.YUY2: return AndroidImageFormatList.ANDROID_IMAGEFORMAT_YUY2; case ImageFormat.NV16: return AndroidImageFormatList.ANDROID_IMAGEFORMAT_NV16; case ImageFormat.JPEG: return AndroidImageFormatList.ANDROID_IMAGEFORMAT_JPEG; case ImageFormat.RGB_565: return AndroidImageFormatList.ANDROID_IMAGEFORMAT_RGB_565; case ImageFormat.UNKNOWN: default: return AndroidImageFormatList.ANDROID_IMAGEFORMAT_UNKNOWN; } }
Example 2
Source File: Camera.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
private int pixelFormatForCameraFormat(String format) { if (format == null) return ImageFormat.UNKNOWN; if (format.equals(PIXEL_FORMAT_YUV422SP)) return ImageFormat.NV16; if (format.equals(PIXEL_FORMAT_YUV420SP)) return ImageFormat.NV21; if (format.equals(PIXEL_FORMAT_YUV422I)) return ImageFormat.YUY2; if (format.equals(PIXEL_FORMAT_YUV420P)) return ImageFormat.YV12; if (format.equals(PIXEL_FORMAT_RGB565)) return ImageFormat.RGB_565; if (format.equals(PIXEL_FORMAT_JPEG)) return ImageFormat.JPEG; return ImageFormat.UNKNOWN; }
Example 3
Source File: VideoCapture.java From android-chromium with BSD 2-Clause "Simplified" License | 6 votes |
@CalledByNative public int getColorspace() { switch (mImageFormat){ case ImageFormat.YV12: return AndroidImageFormatList.ANDROID_IMAGEFORMAT_YV12; case ImageFormat.NV21: return AndroidImageFormatList.ANDROID_IMAGEFORMAT_NV21; case ImageFormat.YUY2: return AndroidImageFormatList.ANDROID_IMAGEFORMAT_YUY2; case ImageFormat.NV16: return AndroidImageFormatList.ANDROID_IMAGEFORMAT_NV16; case ImageFormat.JPEG: return AndroidImageFormatList.ANDROID_IMAGEFORMAT_JPEG; case ImageFormat.RGB_565: return AndroidImageFormatList.ANDROID_IMAGEFORMAT_RGB_565; case ImageFormat.UNKNOWN: default: return AndroidImageFormatList.ANDROID_IMAGEFORMAT_UNKNOWN; } }
Example 4
Source File: JavaCameraView.java From VIA-AI with MIT License | 5 votes |
@Override public Mat rgba() { if (mPreviewFormat == ImageFormat.NV21) Imgproc.cvtColor(mYuvFrameData, mRgba, Imgproc.COLOR_YUV2RGBA_NV21, 4); else if (mPreviewFormat == ImageFormat.YV12) Imgproc.cvtColor(mYuvFrameData, mRgba, Imgproc.COLOR_YUV2RGB_I420, 4); // COLOR_YUV2RGBA_YV12 produces inverted colors else throw new IllegalArgumentException("Preview Format can be NV21 or YV12"); return mRgba; }
Example 5
Source File: JavaCameraView.java From Chinese-number-gestures-recognition with BSD 2-Clause "Simplified" License | 5 votes |
@Override public Mat rgba() { if (mPreviewFormat == ImageFormat.NV21) Imgproc.cvtColor(mYuvFrameData, mRgba, Imgproc.COLOR_YUV2RGBA_NV21, 4); else if (mPreviewFormat == ImageFormat.YV12) Imgproc.cvtColor(mYuvFrameData, mRgba, Imgproc.COLOR_YUV2RGB_I420, 4); // COLOR_YUV2RGBA_YV12 produces inverted colors else throw new IllegalArgumentException("Preview Format can be NV21 or YV12"); return mRgba; }
Example 6
Source File: JavaCameraView.java From OpenCvFaceDetect with Apache License 2.0 | 5 votes |
@Override public Mat rgba() { if (mPreviewFormat == ImageFormat.NV21) Imgproc.cvtColor(mYuvFrameData, mRgba, Imgproc.COLOR_YUV2RGBA_NV21, 4); else if (mPreviewFormat == ImageFormat.YV12) Imgproc.cvtColor(mYuvFrameData, mRgba, Imgproc.COLOR_YUV2RGB_I420, 4); // COLOR_YUV2RGBA_YV12 produces inverted colors else throw new IllegalArgumentException("Preview Format can be NV21 or YV12"); return mRgba; }
Example 7
Source File: VideoCapture.java From android-chromium with BSD 2-Clause "Simplified" License | 5 votes |
static int getImageFormat() { if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) { return ImageFormat.NV21; } for (String buggyDevice : sBUGGY_DEVICE_LIST) { if (buggyDevice.contentEquals(android.os.Build.MODEL)) { return ImageFormat.NV21; } } return ImageFormat.YV12; }
Example 8
Source File: JavaCameraView.java From pasm-yolov3-Android with GNU General Public License v3.0 | 5 votes |
@Override public Mat rgba() { if (mPreviewFormat == ImageFormat.NV21) Imgproc.cvtColor(mYuvFrameData, mRgba, Imgproc.COLOR_YUV2RGBA_NV21, 4); else if (mPreviewFormat == ImageFormat.YV12) Imgproc.cvtColor(mYuvFrameData, mRgba, Imgproc.COLOR_YUV2RGB_I420, 4); // COLOR_YUV2RGBA_YV12 produces inverted colors else throw new IllegalArgumentException("Preview Format can be NV21 or YV12"); return mRgba; }
Example 9
Source File: JavaCamera2View.java From pasm-yolov3-Android with GNU General Public License v3.0 | 5 votes |
@Override public Mat rgba() { if (mPreviewFormat == ImageFormat.NV21) Imgproc.cvtColor(mYuvFrameData, mRgba, Imgproc.COLOR_YUV2RGBA_NV21, 4); else if (mPreviewFormat == ImageFormat.YV12) Imgproc.cvtColor(mYuvFrameData, mRgba, Imgproc.COLOR_YUV2RGB_I420, 4); // COLOR_YUV2RGBA_YV12 produces inverted colors else if (mPreviewFormat == ImageFormat.YUV_420_888) { assert (mUVFrameData != null); Imgproc.cvtColorTwoPlane(mYuvFrameData, mUVFrameData, mRgba, Imgproc.COLOR_YUV2RGBA_NV21); } else throw new IllegalArgumentException("Preview Format can be NV21 or YV12"); return mRgba; }
Example 10
Source File: Camera.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private String cameraFormatForPixelFormat(int pixel_format) { switch(pixel_format) { case ImageFormat.NV16: return PIXEL_FORMAT_YUV422SP; case ImageFormat.NV21: return PIXEL_FORMAT_YUV420SP; case ImageFormat.YUY2: return PIXEL_FORMAT_YUV422I; case ImageFormat.YV12: return PIXEL_FORMAT_YUV420P; case ImageFormat.RGB_565: return PIXEL_FORMAT_RGB565; case ImageFormat.JPEG: return PIXEL_FORMAT_JPEG; default: return null; } }
Example 11
Source File: VideoCapture.java From android-chromium with BSD 2-Clause "Simplified" License | 5 votes |
static int getImageFormat() { if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) { return ImageFormat.NV21; } for (String buggyDevice : sBUGGY_DEVICE_LIST) { if (buggyDevice.contentEquals(android.os.Build.MODEL)) { return ImageFormat.NV21; } } return ImageFormat.YV12; }
Example 12
Source File: JavaCamera2View.java From AndroidDocumentScanner with MIT License | 5 votes |
@Override public Mat rgba() { if (mPreviewFormat == ImageFormat.NV21) Imgproc.cvtColor(mYuvFrameData, mRgba, Imgproc.COLOR_YUV2RGBA_NV21, 4); else if (mPreviewFormat == ImageFormat.YV12) Imgproc.cvtColor(mYuvFrameData, mRgba, Imgproc.COLOR_YUV2RGB_I420, 4); // COLOR_YUV2RGBA_YV12 produces inverted colors else if (mPreviewFormat == ImageFormat.YUV_420_888) { assert (mUVFrameData != null); Imgproc.cvtColorTwoPlane(mYuvFrameData, mUVFrameData, mRgba, Imgproc.COLOR_YUV2RGBA_NV21); } else throw new IllegalArgumentException("Preview Format can be NV21 or YV12"); return mRgba; }
Example 13
Source File: VideoCaptureCamera.java From 365browser with Apache License 2.0 | 5 votes |
static int getImageFormat() { for (String buggyDevice : COLORSPACE_BUGGY_DEVICE_LIST) { if (buggyDevice.contentEquals(android.os.Build.MODEL)) { return ImageFormat.NV21; } } return ImageFormat.YV12; }
Example 14
Source File: LandmarkPainter.java From ssj with GNU General Public License v3.0 | 5 votes |
private void decodeColor(final byte[] data, int width, int height, int format) { // TODO: implement missing conversions switch (format) { case ImageFormat.YV12: { throw new UnsupportedOperationException("Not implemented, yet"); } case ImageFormat.YUV_420_888: //YV12_PACKED_SEMI { CameraUtil.decodeYV12PackedSemi(argbData, data, width, height); break; } case ImageFormat.NV21: { CameraUtil.convertNV21ToARGBInt(argbData, data, width, height); break; } case ImageFormat.FLEX_RGB_888: { CameraUtil.convertRGBToARGBInt(argbData, data, width, height); break; } default: { Log.e("Wrong color format"); throw new RuntimeException(); } } }
Example 15
Source File: JavaCameraView.java From FaceDetectDemo with Apache License 2.0 | 5 votes |
@Override public Mat rgba() { if (mPreviewFormat == ImageFormat.NV21) Imgproc.cvtColor(mYuvFrameData, mRgba, Imgproc.COLOR_YUV2RGBA_NV21, 4); else if (mPreviewFormat == ImageFormat.YV12) Imgproc.cvtColor(mYuvFrameData, mRgba, Imgproc.COLOR_YUV2RGB_I420, 4); // COLOR_YUV2RGBA_YV12 produces inverted colors else throw new IllegalArgumentException("Preview Format can be NV21 or YV12"); return mRgba; }
Example 16
Source File: VideoCapture.java From 365browser with Apache License 2.0 | 5 votes |
@CalledByNative public final int getColorspace() { switch (mCaptureFormat.mPixelFormat) { case ImageFormat.YV12: return AndroidImageFormat.YV12; case ImageFormat.YUV_420_888: return AndroidImageFormat.YUV_420_888; case ImageFormat.NV21: return AndroidImageFormat.NV21; case ImageFormat.UNKNOWN: default: return AndroidImageFormat.UNKNOWN; } }
Example 17
Source File: StreamConfigurationMap.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
private String formatToString(int format) { switch (format) { case ImageFormat.YV12: return "YV12"; case ImageFormat.YUV_420_888: return "YUV_420_888"; case ImageFormat.NV21: return "NV21"; case ImageFormat.NV16: return "NV16"; case PixelFormat.RGB_565: return "RGB_565"; case PixelFormat.RGBA_8888: return "RGBA_8888"; case PixelFormat.RGBX_8888: return "RGBX_8888"; case PixelFormat.RGB_888: return "RGB_888"; case ImageFormat.JPEG: return "JPEG"; case ImageFormat.YUY2: return "YUY2"; case ImageFormat.Y8: return "Y8"; case ImageFormat.Y16: return "Y16"; case ImageFormat.RAW_SENSOR: return "RAW_SENSOR"; case ImageFormat.RAW_PRIVATE: return "RAW_PRIVATE"; case ImageFormat.RAW10: return "RAW10"; case ImageFormat.DEPTH16: return "DEPTH16"; case ImageFormat.DEPTH_POINT_CLOUD: return "DEPTH_POINT_CLOUD"; case ImageFormat.RAW_DEPTH: return "RAW_DEPTH"; case ImageFormat.PRIVATE: return "PRIVATE"; default: return "UNKNOWN"; } }
Example 18
Source File: CameraInfo.java From MobileInfo with Apache License 2.0 | 4 votes |
private static String getFormat(int format) { switch (format) { case ImageFormat.DEPTH16: return "DEPTH16"; case ImageFormat.DEPTH_POINT_CLOUD: return "DEPTH_POINT_CLOUD"; case ImageFormat.FLEX_RGBA_8888: return "FLEX_RGBA_8888"; case ImageFormat.FLEX_RGB_888: return "FLEX_RGB_888"; case ImageFormat.JPEG: return "JPEG"; case ImageFormat.NV16: return "NV16"; case ImageFormat.NV21: return "NV21"; case ImageFormat.PRIVATE: return "PRIVATE"; case ImageFormat.RAW10: return "RAW10"; case ImageFormat.RAW12: return "RAW12"; case ImageFormat.RAW_PRIVATE: return "RAW_PRIVATE"; case ImageFormat.RAW_SENSOR: return "RAW_SENSOR"; case ImageFormat.RGB_565: return "RGB_565"; case ImageFormat.YUV_420_888: return "YUV_420_888"; case ImageFormat.YUV_422_888: return "YUV_422_888"; case ImageFormat.YUV_444_888: return "YUV_444_888"; case ImageFormat.YUY2: return "YUY2"; case ImageFormat.YV12: return "YV12"; default: return UNKNOWN + "-" + format; } }
Example 19
Source File: CameraConfig.java From AndroidDemo with MIT License | 4 votes |
public CameraConfig(String cameraId, StreamConfigurationMap map, @Nullable View view, OnImageAvailableListener listener, Handler handler) { if (view != null) { this.view = view; if (view instanceof TextureView) { type = TYPE_TEXTURE_VIEW; } else if (view instanceof SurfaceView) { type = TYPE_SURFACE_VIEW; } else { throw new IllegalArgumentException("不支持类型"); } } this.streamConfigurationMap = map; this.cameraId = cameraId; this.imageAvailableListener = listener; this.handler = handler; int format = ImageFormat.JPEG; if (map.isOutputSupportedFor(ImageFormat.YUV_420_888)) { format = ImageFormat.YUV_420_888; Log.i(TAG, "support YUV_420_888"); } else if (map.isOutputSupportedFor(ImageFormat.YV12)) { format = ImageFormat.YV12; } Log.e(TAG, "current ImageFormat = " + format); largest = calculationSize(map); Log.d(TAG, "width = " + largest.getWidth() + " height = " + largest.getHeight()); //三通道 YUV YV12,YUV_420_888,不支持 NV21 imageReader = ImageReader.newInstance(largest.getWidth(), largest.getHeight(), format, 1); imageReader.setOnImageAvailableListener(imageAvailableListener, handler); this.cameraStateCallback = new CameraDevice.StateCallback() { @Override public void onOpened(@NonNull CameraDevice camera) { cameraDevice = camera; createCameraSession(); } @Override public void onDisconnected(@NonNull CameraDevice camera) { camera.close(); cameraDevice = null; } @Override public void onError(@NonNull CameraDevice camera, int error) { camera.close(); cameraDevice = null; Log.e(TAG, _error[error]); } }; }
Example 20
Source File: MainActivity.java From FastBarcodeScanner with Apache License 2.0 | 4 votes |
private String formatFormat(int imageFormat) { switch (imageFormat) { case ImageFormat.UNKNOWN: return "UNKNOWN"; case ImageFormat.NV21: return "NV21"; case ImageFormat.NV16: return "NV16"; case ImageFormat.YV12: return "YV12"; case ImageFormat.YUY2: return "YUY2"; case ImageFormat.YUV_420_888: return "YUV_420_888"; case ImageFormat.YUV_422_888: return "YUV_422_888"; case ImageFormat.YUV_444_888: return "YUV_444_888"; case ImageFormat.FLEX_RGB_888: return "FLEX_RGB_888"; case ImageFormat.FLEX_RGBA_8888: return "FLEX_RGBA_8888"; case ImageFormat.JPEG: return "JPEG"; case ImageFormat.RGB_565: return "RGB_565"; case ImageFormat.RAW_SENSOR: return "RAW_SENSOR"; case ImageFormat.RAW10: return "RAW10"; case ImageFormat.RAW12: return "RAW12"; case ImageFormat.DEPTH16: return "DEPTH16"; case ImageFormat.DEPTH_POINT_CLOUD: return "DEPTH_POINT_CLOUD"; //case ImageFormat.Y8: //case ImageFormat.Y16: } return "" + imageFormat; }