本文整理汇总了Java中android.media.ImageReader.acquireNextImage方法的典型用法代码示例。如果您正苦于以下问题:Java ImageReader.acquireNextImage方法的具体用法?Java ImageReader.acquireNextImage怎么用?Java ImageReader.acquireNextImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.media.ImageReader
的用法示例。
在下文中一共展示了ImageReader.acquireNextImage方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onImageAvailable
import android.media.ImageReader; //导入方法依赖的package包/类
@Override
public void onImageAvailable(ImageReader reader) {
final Bitmap bitmap;
try (Image image = reader.acquireNextImage()) {
bitmap = mImagePreprocessor.preprocessImage(image);
}
runOnUiThread(new Runnable() {
@Override
public void run() {
mImage.setImageBitmap(bitmap);
}
});
final List<Classifier.Recognition> results = mTensorFlowClassifier.doRecognize(bitmap);
Log.d(TAG, "Got the following results from Tensorflow: " + results);
if (mTtsEngine != null) {
// speak out loud the result of the image recognition
mTtsSpeaker.speakResults(mTtsEngine, results);
} else {
// if theres no TTS, we don't need to wait until the utterance is spoken, so we set
// to ready right away.
setReady(true);
}
runOnUiThread(new Runnable() {
@Override
public void run() {
for (int i = 0; i < mResultViews.length; i++) {
if (results.size() > i) {
Classifier.Recognition r = results.get(i);
mResultViews[i].setText(r.getTitle() + " : " + r.getConfidence().toString());
} else {
mResultViews[i].setText(null);
}
}
}
});
}
示例2: onImageAvailable
import android.media.ImageReader; //导入方法依赖的package包/类
@Override
public void onImageAvailable(ImageReader reader) {
try (Image image = reader.acquireNextImage()) {
Image.Plane[] planes = image.getPlanes();
if (planes.length > 0) {
ByteBuffer buffer = planes[0].getBuffer();
byte[] data = new byte[buffer.remaining()];
buffer.get(data);
mCallback.onPictureTaken(data);
}
}
}
示例3: onImageAvailable
import android.media.ImageReader; //导入方法依赖的package包/类
@Override
public void onImageAvailable(ImageReader reader) {
Image mImage = reader.acquireNextImage();
if(mImage == null) {
return;
}
mFrameProcessor.setNextFrame(convertYUV420888ToNV21(mImage));
mImage.close();
}
示例4: onImageAvailable
import android.media.ImageReader; //导入方法依赖的package包/类
@Override
public void onImageAvailable(ImageReader reader) {
Log.d(TAG, "onImageAvailable()");
try (Image image = reader.acquireNextImage()) {
mImagePreprocessor.preprocessImage(image);
}
processPhoto(true);
}
示例5: onImageAvailable
import android.media.ImageReader; //导入方法依赖的package包/类
/**
* Get the sOutBitmap image from the camera. This function works on the {@link Camera#mCameraThread} thread.
*
* @param reader {@link ImageReader}
* @see ImageReader.OnImageAvailableListener
*/
@Override
public void onImageAvailable(@NonNull ImageReader reader) {
//Get the image in sOutBitmap.
try (Image image = reader.acquireNextImage()) {
Bitmap capturedBmp = Utils.imageToBitmap(image);
image.close();
if (capturedBmp != null) {
mListener.onImageCaptured(capturedBmp);
} else {
Log.e(TAG, "onImageAvailable: ImageReader did not returned any byte.");
}
}
}
示例6: onImageAvailable
import android.media.ImageReader; //导入方法依赖的package包/类
@Override
public void onImageAvailable(ImageReader reader) {
try (Image image = reader.acquireNextImage()) {
Image.Plane[] planes = image.getPlanes();
if (planes.length > 0) {
ByteBuffer buffer = planes[0].getBuffer();
final byte[] data = new byte[buffer.remaining()];
buffer.get(data);
uiHandler.post(new Runnable() {
@Override
public void run() {
cameraStatusCallback.onPhotoTaken(data);
}
});
final Bitmap bitmap = BitmapUtils.createSampledBitmapFromBytes(data, getMaxWidthSize());
final Bitmap rotatedBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap
.getHeight(), getImageTransformMatrix(), false);
uiHandler.post(new Runnable() {
@Override
public void run() {
cameraStatusCallback.onBitmapProcessed(rotatedBitmap);
}
});
}
}
}
示例7: onImageAvailable
import android.media.ImageReader; //导入方法依赖的package包/类
@Override
public void onImageAvailable(ImageReader imageReader) {
Image image=imageReader.acquireNextImage();
ByteBuffer buffer=image.getPlanes()[0].getBuffer();
byte[] bytes=new byte[buffer.remaining()];
buffer.get(bytes);
image.close();
bus.post(new PictureTakenEvent(xact.process(new ImageContext(ctxt, bytes))));
}
示例8: onImageAvailable
import android.media.ImageReader; //导入方法依赖的package包/类
@Override
public void onImageAvailable(ImageReader imageReader) {
Image image=imageReader.acquireNextImage();
ByteBuffer buffer=image.getPlanes()[0].getBuffer();
byte[] bytes=new byte[buffer.remaining()];
buffer.get(bytes);
image.close();
bus.post(new PictureTakenEvent(xact,
xact.process(new ImageContext(ctxt, bytes))));
}
示例9: onImageAvailable
import android.media.ImageReader; //导入方法依赖的package包/类
@Override
public void onImageAvailable(ImageReader reader)
//----------------------------------------------
{
Image image;
try { image = reader.acquireNextImage(); } catch (Exception e) { Log.e(LOGTAG, "", e); image = null; }
if (image == null)
return;
if (mustBuffer)
{
Image.Plane[] planes = image.getPlanes();
long timestamp = SystemClock.elapsedRealtimeNanos();
Image.Plane Yplane = planes[0];
Image.Plane Uplane = planes[1];
Image.Plane Vplane = planes[2];
ByteBuffer Y = Yplane.getBuffer();
ByteBuffer U = Uplane.getBuffer();
ByteBuffer V = Vplane.getBuffer();
Y.rewind();
U.rewind();
V.rewind();
final int ylen = Y.remaining();
final int ulen = U.remaining();
final int vlen = V.remaining();
final int ustride = Uplane.getPixelStride();
final int vstride = Vplane.getPixelStride();
frameBuffer.pushYUV(timestamp, Y, ylen, U, ulen, ustride, V, vlen, vstride, 5);
}
image.close();
frameAvailCondVar.open();
}