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


Java Camera.setPreviewCallback方法代码示例

本文整理汇总了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) {
    }
}
 
开发者ID:yuriy-budiyev,项目名称:code-scanner,代码行数:21,代码来源:CodeScanner.java

示例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;
}
 
开发者ID:yuriy-budiyev,项目名称:code-scanner,代码行数:20,代码来源:CodeScanner.java

示例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");
	}
}
 
开发者ID:guzhigang001,项目名称:Zxing,代码行数:20,代码来源:PreviewCallback.java

示例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");
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:15,代码来源:PreviewCallback.java

示例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");
    }
}
 
开发者ID:10045125,项目名称:QrCode,代码行数:15,代码来源:PreviewCallback.java

示例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;
    }
 
开发者ID:Dnet3,项目名称:CustomAndroidOneSheeld,代码行数:29,代码来源:CameraHeadService.java

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

示例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");
  }
}
 
开发者ID:mangestudio,项目名称:GCSApp,代码行数:15,代码来源:PreviewCallback.java

示例9: setCallback

import android.hardware.Camera; //导入方法依赖的package包/类
@Override
public void setCallback(VideoCaptureAndroid captureAndroid, int numCaptureBuffers, int bufSize,
        Camera camera) {

    camera.setPreviewCallback(captureAndroid);
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:7,代码来源:CameraUtils5.java

示例10: unsetCallback

import android.hardware.Camera; //导入方法依赖的package包/类
@Override
public void unsetCallback(Camera camera) {
    camera.setPreviewCallback(null);
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:5,代码来源:CameraUtils5.java

示例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;
}
 
开发者ID:FacePlusPlus,项目名称:MegviiFacepp-Android-SDK,代码行数:46,代码来源:ICamera.java


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