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


Java OpenCameraManager类代码示例

本文整理汇总了Java中com.google.zxing.client.android.camera.open.OpenCameraManager的典型用法代码示例。如果您正苦于以下问题:Java OpenCameraManager类的具体用法?Java OpenCameraManager怎么用?Java OpenCameraManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


OpenCameraManager类属于com.google.zxing.client.android.camera.open包,在下文中一共展示了OpenCameraManager类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkCameraAccess

import com.google.zxing.client.android.camera.open.OpenCameraManager; //导入依赖的package包/类
public static boolean checkCameraAccess(Context ctx) {
    boolean ret = ContextCompat.checkSelfPermission(ctx, Manifest.permission.CAMERA)
            == PackageManager.PERMISSION_GRANTED;

    if (ret) {
        //we still can't be sure, android misreport permission when revoked through settings
        try {
            Camera xCamera = new OpenCameraManager().build().open();
            xCamera.release();
        } catch (RuntimeException ex) {
            ret = false;
        }
    }
    return ret;
}
 
开发者ID:oversecio,项目名称:oversec_crypto,代码行数:16,代码来源:Util.java

示例2: openDriver

import com.google.zxing.client.android.camera.open.OpenCameraManager; //导入依赖的package包/类
/**
 * Opens the camera driver and initializes the hardware parameters.
 *
 * @param holder The surface object which the camera will draw preview frames into.
 * @throws IOException Indicates the camera driver failed to open.
 */
public synchronized void openDriver(SurfaceHolder holder) throws IOException {
  Camera theCamera = camera;
  if (theCamera == null) {
    theCamera = new OpenCameraManager().build().open();
    if (theCamera == null) {
      throw new IOException();
    }
    camera = theCamera;
  }
  theCamera.setPreviewDisplay(holder);

  if (!initialized) {
    initialized = true;
    configManager.initFromCameraParameters(theCamera);
    if (requestedFramingRectWidth > 0 && requestedFramingRectHeight > 0) {
      setManualFramingRect(requestedFramingRectWidth, requestedFramingRectHeight);
      requestedFramingRectWidth = 0;
      requestedFramingRectHeight = 0;
    }
  }

  Camera.Parameters parameters = theCamera.getParameters();
  String parametersFlattened = parameters == null ? null : parameters.flatten(); // Save these, temporarily
  try {
    configManager.setDesiredCameraParameters(theCamera, false);
  } catch (RuntimeException re) {
    // Driver failed
    Log.w(TAG, "Camera rejected parameters. Setting only minimal safe-mode parameters");
    Log.i(TAG, "Resetting to saved camera params: " + parametersFlattened);
    // Reset:
    if (parametersFlattened != null) {
      parameters = theCamera.getParameters();
      parameters.unflatten(parametersFlattened);
      try {
        theCamera.setParameters(parameters);
        configManager.setDesiredCameraParameters(theCamera, true);
      } catch (RuntimeException re2) {
        // Well, darn. Give up
        Log.w(TAG, "Camera rejected even safe-mode parameters! No configuration");
      }
    }
  }

}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:51,代码来源:CameraManager.java

示例3: openDriver

import com.google.zxing.client.android.camera.open.OpenCameraManager; //导入依赖的package包/类
/**
 * Opens the camera driver and initializes the hardware parameters.
 *
 * @param holder The surface object which the camera will draw preview frames into.
 * @throws IOException Indicates the camera driver failed to open.
 */
public synchronized void openDriver(SurfaceHolder holder) throws IOException {
    Camera theCamera = camera;
    if (theCamera == null) {
        theCamera = new OpenCameraManager().build().open();
        if (theCamera == null) {
            throw new IOException();
        }
        camera = theCamera;
    }
    theCamera.setPreviewDisplay(holder);

    if (!initialized) {
        initialized = true;
        configManager.initFromCameraParameters(theCamera);
        if (requestedFramingRectWidth > 0 && requestedFramingRectHeight > 0) {
            setManualFramingRect(requestedFramingRectWidth, requestedFramingRectHeight);
            requestedFramingRectWidth = 0;
            requestedFramingRectHeight = 0;
        }
    }

    Camera.Parameters parameters = theCamera.getParameters();
    String parametersFlattened = parameters == null ? null : parameters.flatten(); // Save these, temporarily
    try {
        configManager.setDesiredCameraParameters(theCamera, false);
    } catch (RuntimeException re) {
        // Driver failed
        Log.w(TAG, "Camera rejected parameters. Setting only minimal safe-mode parameters");
        Log.i(TAG, "Resetting to saved camera params: " + parametersFlattened);
        // Reset:
        if (parametersFlattened != null) {
            parameters = theCamera.getParameters();
            parameters.unflatten(parametersFlattened);
            try {
                theCamera.setParameters(parameters);
                configManager.setDesiredCameraParameters(theCamera, true);
            } catch (RuntimeException re2) {
                // Well, darn. Give up
                Log.w(TAG, "Camera rejected even safe-mode parameters! No configuration");
            }
        }
    }

}
 
开发者ID:yakovenkodenis,项目名称:Discounty,代码行数:51,代码来源:CameraManager.java

示例4: openDriver

import com.google.zxing.client.android.camera.open.OpenCameraManager; //导入依赖的package包/类
/**
 * Opens the camera driver and initializes the hardware parameters.
 *
 * @param holder The surface object which the camera will draw preview frames into.
 * @throws java.io.IOException Indicates the camera driver failed to open.
 */
public synchronized void openDriver(SurfaceHolder holder) throws IOException {
  Camera theCamera = camera;
  if (theCamera == null) {
    theCamera = new OpenCameraManager().build().open();
    if (theCamera == null) {
      throw new IOException();
    }
    camera = theCamera;
  }
  theCamera.setPreviewDisplay(holder);

  if (!initialized) {
    initialized = true;
    configManager.initFromCameraParameters(theCamera);
    if (requestedFramingRectWidth > 0 && requestedFramingRectHeight > 0) {
      setManualFramingRect(requestedFramingRectWidth, requestedFramingRectHeight);
      requestedFramingRectWidth = 0;
      requestedFramingRectHeight = 0;
    }
  }

  Camera.Parameters parameters = theCamera.getParameters();
  String parametersFlattened = parameters == null ? null : parameters.flatten(); // Save these, temporarily
  try {
    configManager.setDesiredCameraParameters(theCamera, false);
  } catch (RuntimeException re) {
    // Driver failed
    Log.w(TAG, "Camera rejected parameters. Setting only minimal safe-mode parameters");
    Log.i(TAG, "Resetting to saved camera params: " + parametersFlattened);
    // Reset:
    if (parametersFlattened != null) {
      parameters = theCamera.getParameters();
      parameters.unflatten(parametersFlattened);
      try {
        theCamera.setParameters(parameters);
        configManager.setDesiredCameraParameters(theCamera, true);
      } catch (RuntimeException re2) {
        // Well, darn. Give up
        Log.w(TAG, "Camera rejected even safe-mode parameters! No configuration");
      }
    }
  }

}
 
开发者ID:bushidowallet,项目名称:bushido-android-app,代码行数:51,代码来源:CameraManager.java

示例5: openDriver

import com.google.zxing.client.android.camera.open.OpenCameraManager; //导入依赖的package包/类
/**
 * Opens the camera driver and initializes the hardware parameters.
 *
 * @param holder The surface object which the camera will draw preview frames into.
 * @throws IOException Indicates the camera driver failed to open.
 */
public synchronized void openDriver(SurfaceHolder holder) throws IOException
{
	Camera theCamera = camera;
	if (theCamera == null)
	{
		theCamera = new OpenCameraManager().build().open();
		if (theCamera == null)
		{
			throw new IOException();
		}
		camera = theCamera;
	}
	theCamera.setPreviewDisplay(holder);

	if (!initialized)
	{
		initialized = true;
		configManager.initFromCameraParameters(theCamera);
		if (requestedFramingRectWidth > 0 && requestedFramingRectHeight > 0)
		{
			setManualFramingRect(requestedFramingRectWidth, requestedFramingRectHeight);
			requestedFramingRectWidth = 0;
			requestedFramingRectHeight = 0;
		}
	}

	Camera.Parameters parameters = theCamera.getParameters();
	String parametersFlattened = parameters == null ? null : parameters.flatten(); // Save these, temporarily
	try
	{
		configManager.setDesiredCameraParameters(theCamera, false);
	}
	catch (RuntimeException re)
	{
		// Driver failed
		Log.w(TAG, "Camera rejected parameters. Setting only minimal safe-mode parameters");
		Log.i(TAG, "Resetting to saved camera params: " + parametersFlattened);
		// Reset:
		if (parametersFlattened != null)
		{
			parameters = theCamera.getParameters();
			parameters.unflatten(parametersFlattened);
			try
			{
				theCamera.setParameters(parameters);
				configManager.setDesiredCameraParameters(theCamera, true);
			}
			catch (RuntimeException re2)
			{
				// Well, darn. Give up
				Log.w(TAG, "Camera rejected even safe-mode parameters! No configuration");
			}
		}
	}

}
 
开发者ID:Abolitionist-Project,项目名称:MediModo-Android,代码行数:63,代码来源:CameraManager.java


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