当前位置: 首页>>代码示例>>Java>>正文


Java Frame.Metadata方法代码示例

本文整理汇总了Java中com.google.android.gms.vision.Frame.Metadata方法的典型用法代码示例。如果您正苦于以下问题:Java Frame.Metadata方法的具体用法?Java Frame.Metadata怎么用?Java Frame.Metadata使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.android.gms.vision.Frame的用法示例。


在下文中一共展示了Frame.Metadata方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: padFrameRight

import com.google.android.gms.vision.Frame; //导入方法依赖的package包/类
/**
 * Creates a new frame based on the original frame, with additional width on the right to
 * increase the size to avoid the bug in the underlying face detector.
 */
private Frame padFrameRight( Frame originalFrame, int newWidth ) {
	Frame.Metadata metadata = originalFrame.getMetadata();
	int width = metadata.getWidth();
	int height = metadata.getHeight();

	Log.i( TAG, "Padded image from: " + width + "x" + height + " to " + newWidth + "x" + height );

	ByteBuffer origBuffer = originalFrame.getGrayscaleImageData();
	int origOffset = origBuffer.arrayOffset();
	byte[] origBytes = origBuffer.array();

	// This can be changed to just .allocate in the future, when Frame supports non-direct
	// byte buffers.
	ByteBuffer paddedBuffer = ByteBuffer.allocateDirect( newWidth * height );
	int paddedOffset = paddedBuffer.arrayOffset();
	byte[] paddedBytes = paddedBuffer.array();
	Arrays.fill( paddedBytes, (byte) 0 );

	for( int y = 0; y < height; ++y ) {
		int origStride = origOffset + y * width;
		int paddedStride = paddedOffset + y * newWidth;
		System.arraycopy( origBytes, origStride, paddedBytes, paddedStride, width );
	}

	return new Frame.Builder()
			.setImageData( paddedBuffer, newWidth, height, ImageFormat.NV21 )
			.setId( metadata.getId() )
			.setRotation( metadata.getRotation() )
			.setTimestampMillis( metadata.getTimestampMillis() )
			.build();
}
 
开发者ID:marpies,项目名称:face-detection-ane,代码行数:36,代码来源:SafeFaceDetector.java

示例2: padFrameBottom

import com.google.android.gms.vision.Frame; //导入方法依赖的package包/类
/**
 * Creates a new frame based on the original frame, with additional height on the bottom to
 * increase the size to avoid the bug in the underlying face detector.
 */
private Frame padFrameBottom( Frame originalFrame, int newHeight ) {
	Frame.Metadata metadata = originalFrame.getMetadata();
	int width = metadata.getWidth();
	int height = metadata.getHeight();

	Log.i( TAG, "Padded image from: " + width + "x" + height + " to " + width + "x" + newHeight );

	ByteBuffer origBuffer = originalFrame.getGrayscaleImageData();
	int origOffset = origBuffer.arrayOffset();
	byte[] origBytes = origBuffer.array();

	// This can be changed to just .allocate in the future, when Frame supports non-direct
	// byte buffers.
	ByteBuffer paddedBuffer = ByteBuffer.allocateDirect( width * newHeight );
	int paddedOffset = paddedBuffer.arrayOffset();
	byte[] paddedBytes = paddedBuffer.array();
	Arrays.fill( paddedBytes, (byte) 0 );

	// Copy the image content from the original, without bothering to fill in the padded bottom
	// part.
	for( int y = 0; y < height; ++y ) {
		int origStride = origOffset + y * width;
		int paddedStride = paddedOffset + y * width;
		System.arraycopy( origBytes, origStride, paddedBytes, paddedStride, width );
	}

	return new Frame.Builder()
			.setImageData( paddedBuffer, width, newHeight, ImageFormat.NV21 )
			.setId( metadata.getId() )
			.setRotation( metadata.getRotation() )
			.setTimestampMillis( metadata.getTimestampMillis() )
			.build();
}
 
开发者ID:marpies,项目名称:face-detection-ane,代码行数:38,代码来源:SafeFaceDetector.java

示例3: padFrameRight

import com.google.android.gms.vision.Frame; //导入方法依赖的package包/类
/**
 * Creates a new frame based on the original frame, with additional width on the right to
 * increase the size to avoid the bug in the underlying face detector.
 */
private Frame padFrameRight(Frame originalFrame, int newWidth) {
    Frame.Metadata metadata = originalFrame.getMetadata();
    int width = metadata.getWidth();
    int height = metadata.getHeight();

    Log.i(TAG, "Padded image from: " + width + "x" + height + " to " + newWidth + "x" + height);

    ByteBuffer origBuffer = originalFrame.getGrayscaleImageData();
    int origOffset = origBuffer.arrayOffset();
    byte[] origBytes = origBuffer.array();

    // This can be changed to just .allocate in the future, when Frame supports non-direct
    // byte buffers.
    ByteBuffer paddedBuffer = ByteBuffer.allocateDirect(newWidth * height);
    int paddedOffset = paddedBuffer.arrayOffset();
    byte[] paddedBytes = paddedBuffer.array();
    Arrays.fill(paddedBytes, (byte) 0);

    for (int y = 0; y < height; ++y) {
        int origStride = origOffset + y * width;
        int paddedStride = paddedOffset + y * newWidth;
        System.arraycopy(origBytes, origStride, paddedBytes, paddedStride, width);
    }

    return new Frame.Builder()
            .setImageData(paddedBuffer, newWidth, height, ImageFormat.NV21)
            .setId(metadata.getId())
            .setRotation(metadata.getRotation())
            .setTimestampMillis(metadata.getTimestampMillis())
            .build();
}
 
开发者ID:doomers,项目名称:FaceDoSwip,代码行数:36,代码来源:SafeFaceDetector.java

示例4: padFrameBottom

import com.google.android.gms.vision.Frame; //导入方法依赖的package包/类
/**
 * Creates a new frame based on the original frame, with additional height on the bottom to
 * increase the size to avoid the bug in the underlying face detector.
 */
private Frame padFrameBottom(Frame originalFrame, int newHeight) {
    Frame.Metadata metadata = originalFrame.getMetadata();
    int width = metadata.getWidth();
    int height = metadata.getHeight();

    Log.i(TAG, "Padded image from: " + width + "x" + height + " to " + width + "x" + newHeight);

    ByteBuffer origBuffer = originalFrame.getGrayscaleImageData();
    int origOffset = origBuffer.arrayOffset();
    byte[] origBytes = origBuffer.array();

    // This can be changed to just .allocate in the future, when Frame supports non-direct
    // byte buffers.
    ByteBuffer paddedBuffer = ByteBuffer.allocateDirect(width * newHeight);
    int paddedOffset = paddedBuffer.arrayOffset();
    byte[] paddedBytes = paddedBuffer.array();
    Arrays.fill(paddedBytes, (byte) 0);

    // Copy the image content from the original, without bothering to fill in the padded bottom
    // part.
    for (int y = 0; y < height; ++y) {
        int origStride = origOffset + y * width;
        int paddedStride = paddedOffset + y * width;
        System.arraycopy(origBytes, origStride, paddedBytes, paddedStride, width);
    }

    return new Frame.Builder()
            .setImageData(paddedBuffer, width, newHeight, ImageFormat.NV21)
            .setId(metadata.getId())
            .setRotation(metadata.getRotation())
            .setTimestampMillis(metadata.getTimestampMillis())
            .build();
}
 
开发者ID:doomers,项目名称:FaceDoSwip,代码行数:38,代码来源:SafeFaceDetector.java


注:本文中的com.google.android.gms.vision.Frame.Metadata方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。