當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。