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


Java ImageReader.acquireNextImage方法代码示例

本文整理汇总了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);
                }
            }
        }
    });
}
 
开发者ID:FoxLabMakerSpace,项目名称:SIGHT-For-the-Blind,代码行数:41,代码来源:ImageClassifierActivity.java

示例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);
        }
    }
}
 
开发者ID:vshkl,项目名称:PXLSRT,代码行数:13,代码来源:Camera2.java

示例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();
}
 
开发者ID:EzequielAdrianM,项目名称:Camera2Vision,代码行数:10,代码来源:Camera2Source.java

示例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);
}
 
开发者ID:Deeplocal,项目名称:android-things-drawbot,代码行数:12,代码来源:MainActivity.java

示例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.");
        }
    }
}
 
开发者ID:kevalpatel2106,项目名称:robo-car,代码行数:21,代码来源:Camera.java

示例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);
                }
            });
        }
    }
}
 
开发者ID:spinaki,项目名称:android-camera,代码行数:27,代码来源:Camera2.java

示例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))));
}
 
开发者ID:code-mc,项目名称:FacerecognitionFlowpilots,代码行数:12,代码来源:CameraTwoEngine.java

示例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))));
}
 
开发者ID:commonsguy,项目名称:cwac-cam2,代码行数:13,代码来源:CameraTwoEngine.java

示例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();
}
 
开发者ID:donaldmunro,项目名称:AARemu,代码行数:32,代码来源:PreviewCamera.java


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