本文整理汇总了Java中android.hardware.Camera.release方法的典型用法代码示例。如果您正苦于以下问题:Java Camera.release方法的具体用法?Java Camera.release怎么用?Java Camera.release使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.hardware.Camera
的用法示例。
在下文中一共展示了Camera.release方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCameraInfo
import android.hardware.Camera; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public WritableMap getCameraInfo(int index) {
CameraInfo info = new CameraInfo();
Size size = null;
try {
Camera.getCameraInfo(index, info);
Camera camera = Camera.open(index);
size = getMaxSupportedVideoSize(camera);
camera.release();
} catch (Exception var3) {
Logging.e("CameraEnumerationAndroid", "getCameraInfo failed on index " + index, var3);
return null;
}
WritableMap params = Arguments.createMap();
String facing = info.facing == 1 ? "front" : "back";
params.putString("label", "Camera " + index + ", Facing " + facing + ", Orientation " + info.orientation);
params.putString("id", "" + index);
params.putString("facing", facing);
params.putString("kind", "video");
params.putString("maxWidth", String.valueOf(size.width));
params.putString("maxHeight", String.valueOf(size.height));
return params;
}
示例2: Init
import android.hardware.Camera; //导入方法依赖的package包/类
@Override
public void Init(VideoCaptureDeviceInfoAndroid deviceInfoAndroid,
List<AndroidVideoCaptureDevice> listToPopulate)
throws SecurityException,
IllegalArgumentException, NoSuchMethodException, ClassNotFoundException,
IllegalAccessException, InvocationTargetException {
Camera camera = null;
// From Android 2.3 and onwards
for (int i = 0; i < Camera.getNumberOfCameras(); ++i) {
AndroidVideoCaptureDevice newDevice = deviceInfoAndroid.new AndroidVideoCaptureDevice();
Camera.CameraInfo info = new Camera.CameraInfo();
Camera.getCameraInfo(i, info);
newDevice.index = i;
newDevice.orientation = info.orientation;
if (info.facing == Camera.CameraInfo.CAMERA_FACING_BACK) {
newDevice.deviceUniqueName =
"Camera " + i + ", Facing back, Orientation " + info.orientation;
}
else {
newDevice.deviceUniqueName =
"Camera " + i + ", Facing front, Orientation " + info.orientation;
newDevice.frontCameraType = FrontFacingCameraType.Android23;
}
camera = Camera.open(i);
Camera.Parameters parameters = camera.getParameters();
deviceInfoAndroid.AddDeviceInfo(newDevice, parameters);
camera.release();
camera = null;
listToPopulate.add(newDevice);
}
}
示例3: isCameraCanUse
import android.hardware.Camera; //导入方法依赖的package包/类
/**
* 测试当前摄像头能否被使用
*
* @return true可用,false不可用
*/
public static boolean isCameraCanUse(Activity activity) {
boolean canUseCamera;
/* if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){//6.0以上系统
if (ContextCompat.checkSelfPermission(activity,Manifest.permission.CAMERA)!= PackageManager.PERMISSION_GRANTED) {
return false;
}else{
return true;
}
}else {*/
Camera mCamera = null;
try {
mCamera = Camera.open(Camera.CameraInfo.CAMERA_FACING_BACK);
canUseCamera = true;
} catch (Exception e) {
canUseCamera = false;
}
if (canUseCamera) {
mCamera.release();
}
// }
return canUseCamera;
}
示例4: GetCameraInfo
import android.hardware.Camera; //导入方法依赖的package包/类
public static PjCameraInfo GetCameraInfo(int idx)
{
if (idx < 0 || idx >= GetCameraCount())
return null;
Camera cam;
try {
cam = Camera.open(idx);
} catch (Exception e) {
Log.d("IOException", e.getMessage());
return null;
}
PjCameraInfo pjci = new PjCameraInfo();
Camera.CameraInfo ci = new Camera.CameraInfo();
Camera.getCameraInfo(idx, ci);
pjci.facing = ci.facing;
pjci.orient = ci.orientation;
Camera.Parameters param = cam.getParameters();
cam.release();
cam = null;
pjci.supportedFormat = IntegerListToIntArray(
param.getSupportedPreviewFormats());
pjci.supportedFps1000 = IntArrayListToIntArray(
param.getSupportedPreviewFpsRange());
pjci.supportedSize = CameraSizeListToIntArray(
param.getSupportedPreviewSizes());
return pjci;
}
示例5: Calibrate
import android.hardware.Camera; //导入方法依赖的package包/类
public static void Calibrate() {
Camera camera = Camera.open();
Camera.Parameters localParameters = camera.getParameters();
localParameters.set("ois-re-calibration", "true");
camera.setParameters(localParameters);
camera.release();
}
示例6: releaseCameraInstance
import android.hardware.Camera; //导入方法依赖的package包/类
public void releaseCameraInstance(int type) {
// Release seems async and creates race conditions. Remove from map first before releasing.
Camera releasingCamera = _cameras.get(type);
if (null != releasingCamera) {
_cameras.remove(type);
releasingCamera.release();
}
}
示例7: stopPreview
import android.hardware.Camera; //导入方法依赖的package包/类
@Override
protected synchronized void stopPreview() {
if (mCamera != null) {
mCamera.setPreviewCallback(null);
mCamera.stopPreview();
Camera c = mCamera;
mCamera = null;
c.release();
mRunning = false;
}
}
示例8: isSupported
import android.hardware.Camera; //导入方法依赖的package包/类
public boolean isSupported(Context context) {
int sdkVersion = Integer.parseInt(Build.VERSION.SDK);
Camera camera = null;
try {
camera = Camera.open();
return sdkVersion >= 8 /*froyo*/ && camera.getParameters().getFlashMode() != null; /*flash is supported*/
} catch (Exception e) {
Log.e(TAG, "isSupported", e);
return false;
} finally {
if (camera != null) {
camera.release();
}
}
}
示例9: onPictureTaken
import android.hardware.Camera; //导入方法依赖的package包/类
@Override
public void onPictureTaken(byte[] data, Camera camera) {
Intent intent = new Intent();
File image = createImageFile(data);
intent.putExtra("picture", image.toURI().toString());
setResult(RESULT_OK, intent);
camera.release();
finish();
}
示例10: 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;
}