Java Code Examples for android.graphics.ImageFormat#DEPTH16

The following examples show how to use android.graphics.ImageFormat#DEPTH16 . 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: CameraUtils.java    From libcommon with Apache License 2.0 5 votes vote down vote up
/**
 * 対応する映像フォーマットをlogCatへ出力する
 * @param params
 */
public static void dumpSupportedPictureFormats(@NonNull final Camera.Parameters params) {
	final List<Integer> formats = params.getSupportedPictureFormats();
	for (final int format: formats) {
		switch (format) {
		case ImageFormat.DEPTH16:			Log.i(TAG, "supported: DEPTH16"); break;
		case ImageFormat.DEPTH_POINT_CLOUD:	Log.i(TAG, "supported: DEPTH_POINT_CLOUD"); break;
		case ImageFormat.FLEX_RGBA_8888:	Log.i(TAG, "supported: FLEX_RGBA_8888"); break;
		case ImageFormat.FLEX_RGB_888:		Log.i(TAG, "supported: FLEX_RGB_888"); break;
		case ImageFormat.JPEG:				Log.i(TAG, "supported: JPEG"); break;
		case ImageFormat.NV16:				Log.i(TAG, "supported: NV16"); break;
		case ImageFormat.NV21:				Log.i(TAG, "supported: NV21"); break;
		case ImageFormat.PRIVATE:			Log.i(TAG, "supported: PRIVATE"); break;
		case ImageFormat.RAW10:				Log.i(TAG, "supported: RAW10"); break;
		case ImageFormat.RAW12:				Log.i(TAG, "supported: RAW12"); break;
		case ImageFormat.RAW_PRIVATE:		Log.i(TAG, "supported: RAW_PRIVATE"); break;
		case ImageFormat.RAW_SENSOR:		Log.i(TAG, "supported: RAW_SENSOR"); break;
		case ImageFormat.RGB_565:			Log.i(TAG, "supported: RGB_565"); break;
		case ImageFormat.UNKNOWN:			Log.i(TAG, "supported: UNKNOWN"); break;
		case ImageFormat.YUV_420_888:		Log.i(TAG, "supported: YUV_420_888"); break;
		case ImageFormat.YUV_422_888:		Log.i(TAG, "supported: YUV_422_888"); break;
		case ImageFormat.YUV_444_888:		Log.i(TAG, "supported: YUV_444_888"); break;
		case ImageFormat.YUY2:				Log.i(TAG, "supported: YUY2"); break;
		case ImageFormat.YV12:				Log.i(TAG, "supported: YV12"); break;
		default:
			Log.i(TAG, String.format("supported: unknown, %08x", format));
			break;
		}
	}
}
 
Example 2
Source File: StreamConfigurationMap.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
/**
 * Convert an internal format compatible with {@code graphics.h} into public-visible
 * {@code ImageFormat}. This assumes the dataspace of the format is HAL_DATASPACE_DEPTH.
 *
 * <p>In particular these formats are converted:
 * <ul>
 * <li>HAL_PIXEL_FORMAT_BLOB => ImageFormat.DEPTH_POINT_CLOUD
 * <li>HAL_PIXEL_FORMAT_Y16 => ImageFormat.DEPTH16
 * </ul>
 * </p>
 *
 * <p>Passing in an implementation-defined format which has no public equivalent will fail;
 * as will passing in a public format which has a different internal format equivalent.
 * See {@link #checkArgumentFormat} for more details about a legal public format.</p>
 *
 * <p>All other formats are returned as-is, no further invalid check is performed.</p>
 *
 * <p>This function is the dual of {@link #imageFormatToInternal} for formats associated with
 * HAL_DATASPACE_DEPTH.</p>
 *
 * @param format image format from {@link ImageFormat} or {@link PixelFormat}
 * @return the converted image formats
 *
 * @throws IllegalArgumentException
 *          if {@code format} is {@code HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED} or
 *          {@link ImageFormat#JPEG}
 *
 * @see ImageFormat
 * @see PixelFormat
 * @see #checkArgumentFormat
 */
static int depthFormatToPublic(int format) {
    switch (format) {
        case HAL_PIXEL_FORMAT_BLOB:
            return ImageFormat.DEPTH_POINT_CLOUD;
        case HAL_PIXEL_FORMAT_Y16:
            return ImageFormat.DEPTH16;
        case HAL_PIXEL_FORMAT_RAW16:
            return ImageFormat.RAW_DEPTH;
        case ImageFormat.JPEG:
            throw new IllegalArgumentException(
                    "ImageFormat.JPEG is an unknown internal format");
        case HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED:
            throw new IllegalArgumentException(
                    "IMPLEMENTATION_DEFINED must not leak to public API");
        default:
            throw new IllegalArgumentException(
                    "Unknown DATASPACE_DEPTH format " + format);
    }
}
 
Example 3
Source File: StreamConfigurationMap.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
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 4
Source File: CameraInfo.java    From MobileInfo with Apache License 2.0 4 votes vote down vote up
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 5
Source File: MainActivity.java    From FastBarcodeScanner with Apache License 2.0 4 votes vote down vote up
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;
}
 
Example 6
Source File: StillSequenceCamera.java    From FastBarcodeScanner with Apache License 2.0 4 votes vote down vote up
private static double getFormatCost(int format) {
    switch (format) {
        case ImageFormat.UNKNOWN:
            return 1.0;
        case ImageFormat.NV21:
            return 0.8;
        case ImageFormat.NV16:
            // This format has never been seen in the wild, but is compatible as we only care
            // about the Y channel, so allow it.
            return 0.8;
        case ImageFormat.YV12:
        case ImageFormat.YUY2:
        case ImageFormat.YUV_420_888:
            return 0.5; // pure guesswork - but it IS faster than JPEG
        case ImageFormat.YUV_422_888:
            // only varies from yuv_420_888 in chroma-subsampling, which I'm guessing
            // doesn't affect the luminance much
            // (see https://en.wikipedia.org/wiki/Chroma_subsampling)
            return 0.5;
        case ImageFormat.YUV_444_888:
            // only varies from yuv_420_888 in chroma-subsampling, which I'm guessing
            // doesn't affect the luminance much
            // (see https://en.wikipedia.org/wiki/Chroma_subsampling)
            return 0.5;
        case ImageFormat.FLEX_RGB_888:
        case ImageFormat.FLEX_RGBA_8888:
        case ImageFormat.RGB_565:
            return 0.8; // pure guesswork
        case ImageFormat.JPEG:
            return 1.0; // duh...?
        case ImageFormat.RAW_SENSOR:
        case ImageFormat.RAW10:
        case ImageFormat.RAW12:
            return 0.4; // pure guesswork - but any RAW format must be optimal (wrt capture speed)?
        case ImageFormat.DEPTH16:
        case ImageFormat.DEPTH_POINT_CLOUD:
            return 1.5; // sound terribly complicated - but I'm just guessing....
        //ImageFormat.Y8:
        //ImageFormat.Y16:
    }

    return 1.0;
}
 
Example 7
Source File: JpegUtils.java    From FastBarcodeScanner with Apache License 2.0 4 votes vote down vote up
public static byte[] ToJpeg(byte[] imageData, int imageFormat, int width, int height)
{
    if (imageData == null)
        return null;

    switch (imageFormat)
    {
        case ImageFormat.NV21:
        case ImageFormat.YUY2:
            YuvImage img = new YuvImage(imageData, imageFormat, width, height, null);
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            int quality = 20; //set quality
            img.compressToJpeg(new Rect(0, 0, width, height), quality, baos);//this line decreases the image quality
            return baos.toByteArray();
        case ImageFormat.YUV_420_888:
            return JpegFromYuv420888(imageData, imageFormat, width, height);


        case ImageFormat.UNKNOWN:
            return null;
        case ImageFormat.NV16:
            // Source: http://www.programcreek.com/java-api-examples/index.php?source_dir=Roid-Library-master/src/com/rincliu/library/common/persistence/zxing/camera/CameraManager.java
            // This format has never been seen in the wild, but is compatible as we only care
            // about the Y channel, so allow it.
        case ImageFormat.YV12:
            // source: https://github.com/evopark/tiqr-android/blob/master/src/main/java/de/evopark/tiqr/android/processing/ZxingQrScanner.java
        case ImageFormat.YUV_422_888:
            // only varies from yuv_420_888 in chroma-subsampling, which I'm guessing
            // doesn't affect the luminance much
            // (see https://en.wikipedia.org/wiki/Chroma_subsampling)
        case ImageFormat.YUV_444_888:
            // only varies from yuv_420_888 in chroma-subsampling, which I'm guessing
            // doesn't affect the luminance much
            // (see https://en.wikipedia.org/wiki/Chroma_subsampling)
            return null;//new PlanarYUVLuminanceSource(data, width, height, 0, 0, width, height, false);
        case ImageFormat.FLEX_RGB_888:
        case ImageFormat.FLEX_RGBA_8888:
            return null;//new RGBLuminanceSource(width, height, uncompress(data, width, height));// PlanarYUVLuminanceSource(bytes, width, height, 0, 0, width, height, false);
        case ImageFormat.JPEG:
            // Tried and tested myself
            return null;//new RGBLuminanceSource(width, height, uncompress(data, width, height));// PlanarYUVLuminanceSource(bytes, width, height, 0, 0, width, height, false);
        case ImageFormat.RGB_565:
            return null;//new RGB565(width, height, uncompress(data, width, height));// PlanarYUVLuminanceSource(bytes, width, height, 0, 0, width, height, false);
        case ImageFormat.RAW_SENSOR:
        case ImageFormat.RAW10:
        case ImageFormat.RAW12:
        case ImageFormat.DEPTH16:
        case ImageFormat.DEPTH_POINT_CLOUD:
            //ImageFormat.Y8:
            //ImageFormat.Y16:
            return null;
        default:
            throw new IllegalArgumentException("No support for image format " + imageFormat);
    }
}
 
Example 8
Source File: StreamConfigurationMap.java    From android_9.0.0_r45 with Apache License 2.0 3 votes vote down vote up
/**
 * Convert a public format compatible with {@code ImageFormat} to an internal format
 * from {@code graphics.h}.
 *
 * <p>In particular these formats are converted:
 * <ul>
 * <li>ImageFormat.JPEG => HAL_PIXEL_FORMAT_BLOB
 * <li>ImageFormat.DEPTH_POINT_CLOUD => HAL_PIXEL_FORMAT_BLOB
 * <li>ImageFormat.DEPTH16 => HAL_PIXEL_FORMAT_Y16
 * </ul>
 * </p>
 *
 * <p>Passing in an internal format which has a different public format equivalent will fail.
 * See {@link #checkArgumentFormat} for more details about a legal public format.</p>
 *
 * <p>All other formats are returned as-is, no invalid check is performed.</p>
 *
 * <p>This function is the dual of {@link #imageFormatToPublic}.</p>
 *
 * @param format public image format from {@link ImageFormat} or {@link PixelFormat}
 * @return the converted image formats
 *
 * @see ImageFormat
 * @see PixelFormat
 *
 * @throws IllegalArgumentException
 *              if {@code format} was {@code HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED}
 */
static int imageFormatToInternal(int format) {
    switch (format) {
        case ImageFormat.JPEG:
        case ImageFormat.DEPTH_POINT_CLOUD:
            return HAL_PIXEL_FORMAT_BLOB;
        case ImageFormat.DEPTH16:
            return HAL_PIXEL_FORMAT_Y16;
        case ImageFormat.RAW_DEPTH:
            return HAL_PIXEL_FORMAT_RAW16;
        default:
            return format;
    }
}
 
Example 9
Source File: StreamConfigurationMap.java    From android_9.0.0_r45 with Apache License 2.0 3 votes vote down vote up
/**
 * Convert a public format compatible with {@code ImageFormat} to an internal dataspace
 * from {@code graphics.h}.
 *
 * <p>In particular these formats are converted:
 * <ul>
 * <li>ImageFormat.JPEG => HAL_DATASPACE_V0_JFIF
 * <li>ImageFormat.DEPTH_POINT_CLOUD => HAL_DATASPACE_DEPTH
 * <li>ImageFormat.DEPTH16 => HAL_DATASPACE_DEPTH
 * <li>others => HAL_DATASPACE_UNKNOWN
 * </ul>
 * </p>
 *
 * <p>Passing in an implementation-defined format here will fail (it's not a public format);
 * as will passing in an internal format which has a different public format equivalent.
 * See {@link #checkArgumentFormat} for more details about a legal public format.</p>
 *
 * <p>All other formats are returned as-is, no invalid check is performed.</p>
 *
 * <p>This function is the dual of {@link #imageFormatToPublic}.</p>
 *
 * @param format public image format from {@link ImageFormat} or {@link PixelFormat}
 * @return the converted image formats
 *
 * @see ImageFormat
 * @see PixelFormat
 *
 * @throws IllegalArgumentException
 *              if {@code format} was {@code HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED}
 */
static int imageFormatToDataspace(int format) {
    switch (format) {
        case ImageFormat.JPEG:
            return HAL_DATASPACE_V0_JFIF;
        case ImageFormat.DEPTH_POINT_CLOUD:
        case ImageFormat.DEPTH16:
        case ImageFormat.RAW_DEPTH:
            return HAL_DATASPACE_DEPTH;
        default:
            return HAL_DATASPACE_UNKNOWN;
    }
}