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


Java ImageReader.OnImageAvailableListener方法代码示例

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


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

示例1: initializeCamera

import android.media.ImageReader; //导入方法依赖的package包/类
/**
 * Initialize the camera device
 */
public void initializeCamera(Context context,
                             Handler backgroundHandler,
                             ImageReader.OnImageAvailableListener imageAvailableListener) {
    // Discover the camera instance
    CameraManager manager = (CameraManager) context.getSystemService(Context.CAMERA_SERVICE);
    String[] camIds = {};
    try {
        camIds = manager.getCameraIdList();
    } catch (CameraAccessException e) {
        Log.d(TAG, "Cam access exception getting IDs", e);
    }
    if (camIds.length < 1) {
        Log.d(TAG, "No cameras found");
        return;
    }
    String id = camIds[0];
    Log.d(TAG, "Using camera id " + id);
    // Initialize the image processor
    mImageReader = ImageReader.newInstance(IMAGE_WIDTH, IMAGE_HEIGHT,
            ImageFormat.JPEG, MAX_IMAGES);
    mImageReader.setOnImageAvailableListener(
            imageAvailableListener, backgroundHandler);
    // Open the camera resource
    try {
        manager.openCamera(id, mStateCallback, backgroundHandler);
    } catch (CameraAccessException cae) {
        Log.d(TAG, "Camera access exception", cae);
    }
}
 
开发者ID:googlecodelabs,项目名称:androidthings-imageclassifier,代码行数:33,代码来源:CameraHandler.java

示例2: initializeCamera

import android.media.ImageReader; //导入方法依赖的package包/类
/**
 * Initialize the camera device
 */
@SuppressLint("MissingPermission")
public void initializeCamera(Context context,
                             Handler backgroundHandler,
                             ImageReader.OnImageAvailableListener imageAvailableListener) {
    // Discover the camera instance
    CameraManager manager = (CameraManager) context.getSystemService(CAMERA_SERVICE);
    String[] camIds = {};
    try {
        camIds = manager.getCameraIdList();
    } catch (CameraAccessException e) {
        Timber.e(e, "Cam access exception getting IDs");
    }
    if (camIds.length < 1) {
        Timber.d("No cameras found");
        return;
    }
    String id = camIds[0];
    Timber.d("Using camera id %s", id);

    // Initialize the image processor
    mImageReader = ImageReader.newInstance(IMAGE_WIDTH, IMAGE_HEIGHT,
            ImageFormat.JPEG, MAX_IMAGES);
    mImageReader.setOnImageAvailableListener(
            imageAvailableListener, backgroundHandler);

    // Open the camera resource
    try {
        manager.openCamera(id, mStateCallback, backgroundHandler);
    } catch (CameraAccessException cae) {
        Timber.e(cae, "Camera access exception");
    }
}
 
开发者ID:leinardi,项目名称:androidthings-kuman-sm9,代码行数:36,代码来源:Camera.java

示例3: initializeCamera

import android.media.ImageReader; //导入方法依赖的package包/类
/**
 * Initialize the camera device
 */
void initializeCamera(@NonNull Context context,
                      @NonNull Handler backgroundHandler,
                      @NonNull ImageReader.OnImageAvailableListener imageAvailableListener) {
    mBackgroundHandler = backgroundHandler;

    // Discover the camera instance
    CameraManager manager = (CameraManager) context.getSystemService(CAMERA_SERVICE);
    String[] camIds = {};
    try {
        camIds = manager.getCameraIdList();
    } catch (CameraAccessException e) {
        Log.e(TAG, "Cam access exception getting IDs", e);
    }
    if (camIds.length < 1) {
        Log.e(TAG, "No cameras found");
        return;
    }
    String id = camIds[0];
    Log.d(TAG, "Using camera id " + id);

    // Initialize the image processor
    mImageReader = ImageReader.newInstance(IMAGE_WIDTH, IMAGE_HEIGHT, ImageFormat.JPEG, MAX_IMAGES);
    mImageReader.setOnImageAvailableListener(imageAvailableListener, backgroundHandler);

    // Open the camera resource
    try {
        if (ActivityCompat.checkSelfPermission(context, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
            Log.d(TAG, "initializeCamera: Camera permission not available.");
            return;
        }
        manager.openCamera(id, mStateCallback, backgroundHandler);
    } catch (CameraAccessException cae) {
        Log.d(TAG, "Camera access exception", cae);
    }
}
 
开发者ID:kevalpatel2106,项目名称:robo-car,代码行数:39,代码来源:PiCameraDriver.java

示例4: initializeCamera

import android.media.ImageReader; //导入方法依赖的package包/类
/**
 * Initialize the camera device
 */
public void initializeCamera(Context context,
                             Handler backgroundHandler,
                             ImageReader.OnImageAvailableListener imageAvailableListener) {
    // Discover the camera instance
    CameraManager manager = (CameraManager) context.getSystemService(CAMERA_SERVICE);
    String[] camIds = {};
    try {
        camIds = manager.getCameraIdList();
    } catch (CameraAccessException e) {
        Log.d(TAG, "Cam access exception getting IDs", e);
    }
    if (camIds.length < 1) {
        Log.d(TAG, "No cameras found");
        return;
    }
    String id = camIds[0];
    Log.d(TAG, "Using camera id " + id);

    // Initialize the image processor
    mImageReader = ImageReader.newInstance(IMAGE_WIDTH, IMAGE_HEIGHT,
            ImageFormat.JPEG, MAX_IMAGES);
    mImageReader.setOnImageAvailableListener(
            imageAvailableListener, backgroundHandler);

    // Open the camera resource
    try {
        manager.openCamera(id, mStateCallback, backgroundHandler);
    } catch (CameraAccessException cae) {
        Log.d(TAG, "Camera access exception", cae);
    }
}
 
开发者ID:androidthings,项目名称:doorbell,代码行数:35,代码来源:DoorbellCamera.java

示例5: setupImageListener

import android.media.ImageReader; //导入方法依赖的package包/类
public void  setupImageListener() {
    mOnImageAvailableListener = new ImageReader.OnImageAvailableListener() {
        @Override
        public void onImageAvailable(ImageReader reader) {
            mBackgroundHandler.post(new ImageSaverThread(reader.acquireNextImage(), mFile));
        }
    };
}
 
开发者ID:tonyconstantinides,项目名称:LiveMultimedia,代码行数:9,代码来源:LollipopCamera.java

示例6: CameraFrameCapture

import android.media.ImageReader; //导入方法依赖的package包/类
private CameraFrameCapture(ConnectionCallback connectionCallback, ImageReader.OnImageAvailableListener imageListener) {
    this.mCameraConnectionCallback = connectionCallback;
    this.mOnImageAvailableListener = imageListener;
}
 
开发者ID:hpi-xnor,项目名称:android-image-classification,代码行数:5,代码来源:CameraFrameCapture.java

示例7: newInstance

import android.media.ImageReader; //导入方法依赖的package包/类
public static CameraFrameCapture newInstance(
        final ConnectionCallback connectionCallback,
        final ImageReader.OnImageAvailableListener imageListener) {
    return new CameraFrameCapture(connectionCallback, imageListener);
}
 
开发者ID:hpi-xnor,项目名称:android-image-classification,代码行数:6,代码来源:CameraFrameCapture.java


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