本文整理匯總了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();
}