本文整理汇总了Java中com.google.android.gms.vision.Frame.getMetadata方法的典型用法代码示例。如果您正苦于以下问题:Java Frame.getMetadata方法的具体用法?Java Frame.getMetadata怎么用?Java Frame.getMetadata使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.gms.vision.Frame
的用法示例。
在下文中一共展示了Frame.getMetadata方法的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();
}
示例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();
}
示例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();
}
示例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();
}