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


Java Camera.release方法代码示例

本文整理汇总了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;
}
 
开发者ID:angellsl10,项目名称:react-native-webrtc,代码行数:27,代码来源:WebRTCModule.java

示例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);
    }
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:36,代码来源:CameraUtils9.java

示例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;
}
 
开发者ID:zhonglikui,项目名称:cardinalsSample,代码行数:31,代码来源:DevicesUtil.java

示例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;
   }
 
开发者ID:aksalj,项目名称:africastalking-android,代码行数:35,代码来源:PjCameraInfo.java

示例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();

    }
 
开发者ID:dobragab,项目名称:Mi5CameraCalibrate,代码行数:10,代码来源:CameraCalibrator.java

示例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();
    }
}
 
开发者ID:jonathan68,项目名称:react-native-camera,代码行数:9,代码来源:RCTCamera.java

示例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;
    }
}
 
开发者ID:vbier,项目名称:habpanelviewer,代码行数:14,代码来源:MotionDetector.java

示例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();
		}
	}
}
 
开发者ID:sdrausty,项目名称:buildAPKsApps,代码行数:16,代码来源:FroyoLedFlashlight.java

示例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();
}
 
开发者ID:Guaschman,项目名称:Graphrec,代码行数:10,代码来源:CameraActivity.java

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


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