本文整理汇总了Java中android.hardware.Camera.setPreviewCallback方法的典型用法代码示例。如果您正苦于以下问题:Java Camera.setPreviewCallback方法的具体用法?Java Camera.setPreviewCallback怎么用?Java Camera.setPreviewCallback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.hardware.Camera
的用法示例。
在下文中一共展示了Camera.setPreviewCallback方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startPreviewInternal
import android.hardware.Camera; //导入方法依赖的package包/类
private void startPreviewInternal(boolean internal) {
try {
DecoderWrapper decoderWrapper = mDecoderWrapper;
Camera camera = decoderWrapper.getCamera();
camera.setPreviewCallback(mPreviewCallback);
camera.setPreviewDisplay(mSurfaceHolder);
if (!internal && decoderWrapper.isFlashSupported() && mFlashEnabled) {
setFlashEnabledInternal(true);
}
camera.startPreview();
mStoppingPreview = false;
mPreviewActive = true;
mSafeAutoFocusing = false;
mSafeAutoFocusAttemptsCount = 0;
if (mAutoFocusMode == AutoFocusMode.SAFE) {
scheduleSafeAutoFocusTask();
}
} catch (Exception ignored) {
}
}
示例2: stopPreviewInternal
import android.hardware.Camera; //导入方法依赖的package包/类
private void stopPreviewInternal(boolean internal) {
try {
DecoderWrapper decoderWrapper = mDecoderWrapper;
Camera camera = decoderWrapper.getCamera();
if (!internal && decoderWrapper.isFlashSupported() && mFlashEnabled) {
Camera.Parameters parameters = camera.getParameters();
if (parameters != null && Utils.setFlashMode(parameters, Camera.Parameters.FLASH_MODE_OFF)) {
camera.setParameters(parameters);
}
}
camera.setPreviewCallback(null);
camera.stopPreview();
} catch (Exception ignored) {
}
mStoppingPreview = false;
mPreviewActive = false;
mSafeAutoFocusing = false;
mSafeAutoFocusAttemptsCount = 0;
}
示例3: onPreviewFrame
import android.hardware.Camera; //导入方法依赖的package包/类
public void onPreviewFrame(byte[] data, Camera camera)
{
Point cameraResolution = configManager.getCameraResolution();
if (!useOneShotPreviewCallback)
{
camera.setPreviewCallback(null);
}
if (previewHandler != null)
{
Message message = previewHandler
.obtainMessage(previewMessage, cameraResolution.x, cameraResolution.y, data);
message.sendToTarget();
previewHandler = null;
}
else
{
Log.d(TAG, "Got preview callback, but no handler for it");
}
}
示例4: onPreviewFrame
import android.hardware.Camera; //导入方法依赖的package包/类
public void onPreviewFrame(byte[] data, Camera camera) {
Point cameraResolution = configManager.getCameraResolution();
if (!useOneShotPreviewCallback) {
camera.setPreviewCallback(null);
}
if (previewHandler != null) {
Message message = previewHandler.obtainMessage(previewMessage, cameraResolution.x,
cameraResolution.y, data);
message.sendToTarget();
previewHandler = null;
} else {
Log.d(TAG, "Got preview callback, but no handler for it");
}
}
示例5: onPreviewFrame
import android.hardware.Camera; //导入方法依赖的package包/类
public void onPreviewFrame(byte[] data, Camera camera) {
Point cameraResolution = configManager.getCameraResolution();
if (!useOneShotPreviewCallback) {
camera.setPreviewCallback(null);
}
if (previewHandler != null) {
Message message = previewHandler.obtainMessage(previewMessage, cameraResolution.x,
cameraResolution.y, data);
message.sendToTarget();
previewHandler = null;
} else {
Log.d(TAG, "Got preview callback, but no handler for it");
}
}
示例6: openFrontFacingCameraGingerbread
import android.hardware.Camera; //导入方法依赖的package包/类
private Camera openFrontFacingCameraGingerbread() {
if (mCamera != null) {
queue.removeCallbacks(null);
mCamera.setPreviewCallback(null);
mCamera.stopPreview();
mCamera.release();
}
int cameraCount = 0;
Camera cam = null;
Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
cameraCount = Camera.getNumberOfCameras();
for (int camIdx = 0; camIdx < cameraCount; camIdx++) {
Camera.getCameraInfo(camIdx, cameraInfo);
if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
try {
cam = Camera.open(camIdx);
} catch (RuntimeException e) {
Log.e("cameraS",
"Camera failed to open: " + e.getLocalizedMessage());
}
}
}
// cam.setDisplayOrientation(90);
setCameraDisplayOrientation(Camera.CameraInfo.CAMERA_FACING_FRONT, cam);
if (registeredShieldsIDs.contains(UIShield.COLOR_DETECTION_SHIELD.name()))
cam.setPreviewCallback(previewCallback);
return cam;
}
示例7: onPreviewFrame
import android.hardware.Camera; //导入方法依赖的package包/类
public void onPreviewFrame(byte[] data, Camera camera) {
Point cameraResolution = configManager.getCameraResolution();
if (!useOneShotPreviewCallback) {
camera.setPreviewCallback(null);
}
if (previewHandler != null) {
Message message = previewHandler.obtainMessage(previewMessage, cameraResolution.x,
cameraResolution.y, data);
message.sendToTarget();
previewHandler = null;
}
}
示例8: onPreviewFrame
import android.hardware.Camera; //导入方法依赖的package包/类
public void onPreviewFrame(byte[] data, Camera camera) {
Point cameraResolution = configManager.getCameraResolution();
if (!useOneShotPreviewCallback) {
camera.setPreviewCallback(null);
}
if (previewHandler != null) {
Message message = previewHandler.obtainMessage(previewMessage, cameraResolution.x,
cameraResolution.y, data);
message.sendToTarget();
previewHandler = null;
} else {
F.d( "Got preview callback, but no handler for it");
}
}
示例9: setCallback
import android.hardware.Camera; //导入方法依赖的package包/类
@Override
public void setCallback(VideoCaptureAndroid captureAndroid, int numCaptureBuffers, int bufSize,
Camera camera) {
camera.setPreviewCallback(captureAndroid);
}
示例10: unsetCallback
import android.hardware.Camera; //导入方法依赖的package包/类
@Override
public void unsetCallback(Camera camera) {
camera.setPreviewCallback(null);
}
示例11: getCameraPreviewSize
import android.hardware.Camera; //导入方法依赖的package包/类
public static ArrayList<HashMap<String, Integer>> getCameraPreviewSize(
int cameraId) {
ArrayList<HashMap<String, Integer>> size = new ArrayList<HashMap<String, Integer>>();
Camera camera = null;
try {
camera = Camera.open(cameraId);
if (camera == null)
camera = Camera.open(0);
List<Camera.Size> allSupportedSize = camera.getParameters()
.getSupportedPreviewSizes();
for (Camera.Size tmpSize : allSupportedSize) {
if (tmpSize.width > tmpSize.height) {
HashMap<String, Integer> map = new HashMap<String, Integer>();
map.put("width", tmpSize.width);
map.put("height", tmpSize.height);
if (tmpSize.width==640&&tmpSize.height==480){
size.add(map);
}
if (tmpSize.width==960&&tmpSize.height==540){
size.add(map);
}
if (tmpSize.width==1280&&tmpSize.height==720){
size.add(map);
}
if (tmpSize.width==1920&&tmpSize.height==1080){
size.add(map);
}
}
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (camera != null) {
camera.stopPreview();
camera.setPreviewCallback(null);
camera.release();
camera = null;
}
}
return size;
}