本文整理汇总了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);
}
}
示例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");
}
}
示例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);
}
}
示例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);
}
}
示例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));
}
};
}
示例6: CameraFrameCapture
import android.media.ImageReader; //导入方法依赖的package包/类
private CameraFrameCapture(ConnectionCallback connectionCallback, ImageReader.OnImageAvailableListener imageListener) {
this.mCameraConnectionCallback = connectionCallback;
this.mOnImageAvailableListener = imageListener;
}
示例7: newInstance
import android.media.ImageReader; //导入方法依赖的package包/类
public static CameraFrameCapture newInstance(
final ConnectionCallback connectionCallback,
final ImageReader.OnImageAvailableListener imageListener) {
return new CameraFrameCapture(connectionCallback, imageListener);
}