本文整理汇总了Java中android.hardware.Camera.CameraInfo类的典型用法代码示例。如果您正苦于以下问题:Java CameraInfo类的具体用法?Java CameraInfo怎么用?Java CameraInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CameraInfo类属于android.hardware.Camera包,在下文中一共展示了CameraInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCameraInfo
import android.hardware.Camera.CameraInfo; //导入依赖的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: findBackFacingCamera
import android.hardware.Camera.CameraInfo; //导入依赖的package包/类
private int findBackFacingCamera()
{
int cameraId = -1;
int numberOfCameras = Camera.getNumberOfCameras();
for (int i = 0; i < numberOfCameras; i++)
{
CameraInfo info = new CameraInfo();
Camera.getCameraInfo(i, info);
if (info.facing == CameraInfo.CAMERA_FACING_BACK)
{
Log.d(TAG_NAME, "Camera found");
cameraId = i;
break;
}
}
return cameraId;
}
示例3: getCameraDisplayOrientation
import android.hardware.Camera.CameraInfo; //导入依赖的package包/类
public static int getCameraDisplayOrientation(@NonNull Activity activity,
@NonNull CameraInfo info)
{
int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
int degrees = 0;
DisplayMetrics dm = new DisplayMetrics();
activity.getWindowManager().getDefaultDisplay().getMetrics(dm);
switch (rotation) {
case Surface.ROTATION_0: degrees = 0; break;
case Surface.ROTATION_90: degrees = 90; break;
case Surface.ROTATION_180: degrees = 180; break;
case Surface.ROTATION_270: degrees = 270; break;
}
if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
return (360 - ((info.orientation + degrees) % 360)) % 360;
} else {
return (info.orientation - degrees + 360) % 360;
}
}
示例4: setDisplayOrientation
import android.hardware.Camera.CameraInfo; //导入依赖的package包/类
@UiThread
private void setDisplayOrientation(int rotationDegrees) {
int orientation;
CameraInfo info = new CameraInfo();
Camera.getCameraInfo(0, info);
if (info.facing == CAMERA_FACING_FRONT) {
orientation = (info.orientation + rotationDegrees) % 360;
orientation = (360 - orientation) % 360;
} else {
orientation = (info.orientation - rotationDegrees + 360) % 360;
}
if (LOG.isLoggable(INFO))
LOG.info("Display orientation " + orientation + " degrees");
try {
camera.setDisplayOrientation(orientation);
} catch (RuntimeException e) {
LOG.log(WARNING, "Error setting display orientation", e);
}
displayOrientation = orientation;
}
示例5: determineDisplayOrientation
import android.hardware.Camera.CameraInfo; //导入依赖的package包/类
public static int determineDisplayOrientation(Activity activity, int defaultCameraId) {
int displayOrientation = 0;
if(Build.VERSION.SDK_INT > Build.VERSION_CODES.FROYO)
{
CameraInfo cameraInfo = new CameraInfo();
Camera.getCameraInfo(defaultCameraId, cameraInfo);
int degrees = getRotationAngle(activity);
if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
displayOrientation = (cameraInfo.orientation + degrees) % 360;
displayOrientation = (360 - displayOrientation) % 360;
} else {
displayOrientation = (cameraInfo.orientation - degrees + 360) % 360;
}
}
return displayOrientation;
}
示例6: onCreate
import android.hardware.Camera.CameraInfo; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Create a container that will hold a SurfaceView for camera previews
mPreview = new Preview(this.getActivity());
// Find the total number of cameras available
mNumberOfCameras = Camera.getNumberOfCameras();
// Find the ID of the rear-facing ("default") camera
CameraInfo cameraInfo = new CameraInfo();
for (int i = 0; i < mNumberOfCameras; i++) {
Camera.getCameraInfo(i, cameraInfo);
if (cameraInfo.facing == CameraInfo.CAMERA_FACING_BACK) {
mCurrentCamera = mDefaultCameraId = i;
}
}
setHasOptionsMenu(mNumberOfCameras > 1);
}
示例7: init
import android.hardware.Camera.CameraInfo; //导入依赖的package包/类
private void init() {
setEGLContextClientVersion(2);
setEGLConfigChooser(8, 8, 8, 8, 16, 0);
getHolder().setFormat(PixelFormat.RGBA_8888);
setRenderer(this);
setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
float[] cube = OpenGLUtils.CUBE;
mCubeBuffer = ByteBuffer.allocateDirect(cube.length * 4).order(ByteOrder.nativeOrder()).asFloatBuffer();
mCubeBuffer.put(cube);
float[] textureCords = OpenGLUtils.getTextureCords(90, mCameraId == CameraInfo.CAMERA_FACING_FRONT, true);
mTextureBuffer = ByteBuffer.allocateDirect(textureCords.length * 4).order(ByteOrder.nativeOrder()).asFloatBuffer();
mTextureBuffer.put(textureCords);
List<CameraFilter> filters = new ArrayList<>();
filters.add(mCameraInputFilter);
filters.addAll(initFilters());
mCameraFilterGroup = new CameraFilterGroup(filters);
}
示例8: getDisplayOrientation
import android.hardware.Camera.CameraInfo; //导入依赖的package包/类
public int getDisplayOrientation() {
CameraInfo info = new CameraInfo();
Camera.getCameraInfo(0, info);
int degrees = 0;
switch (((WindowManager) getContext().getSystemService("window")).getDefaultDisplay().getRotation()) {
case 0:
degrees = 0;
break;
case 1:
degrees = 90;
break;
case 2:
degrees = 180;
break;
case 3:
degrees = 270;
break;
}
if (info.facing == 1) {
return (360 - ((info.orientation + degrees) % 360)) % 360;
}
return ((info.orientation - degrees) + 360) % 360;
}
示例9: flipCamera
import android.hardware.Camera.CameraInfo; //导入依赖的package包/类
public void flipCamera() {
if (Camera.getNumberOfCameras() > 1) {
cameraId = cameraId == CameraInfo.CAMERA_FACING_BACK
? CameraInfo.CAMERA_FACING_FRONT
: CameraInfo.CAMERA_FACING_BACK;
onPause();
onResume();
TextSecurePreferences.setDirectCaptureCameraId(getContext(), cameraId);
}
}
示例10: determineCameraId
import android.hardware.Camera.CameraInfo; //导入依赖的package包/类
private int determineCameraId() {
final int cameraCount = Camera.getNumberOfCameras();
final CameraInfo cameraInfo = new CameraInfo();
// prefer back-facing camera
for (int i = 0; i < cameraCount; i++) {
Camera.getCameraInfo(i, cameraInfo);
if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_BACK)
return i;
}
// fall back to front-facing camera
for (int i = 0; i < cameraCount; i++) {
Camera.getCameraInfo(i, cameraInfo);
if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT)
return i;
}
return -1;
}
示例11: initCamera
import android.hardware.Camera.CameraInfo; //导入依赖的package包/类
@SuppressLint("NewApi")
private boolean initCamera() {
try {
if (frontCamera == 0) {
mCamera = Camera.open(CameraInfo.CAMERA_FACING_BACK);
} else {
mCamera = Camera.open(CameraInfo.CAMERA_FACING_FRONT);
}
Parameters camParams = mCamera.getParameters();
mCamera.lock();
mSurfaceHolder = mVideoView.getHolder();
mSurfaceHolder.addCallback(this);
mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
mCamera.setDisplayOrientation(90);
} catch (RuntimeException ex) {
EMLog.e("video", "init Camera fail " + ex.getMessage());
return false;
}
return true;
}
示例12: findBackFacingCamera
import android.hardware.Camera.CameraInfo; //导入依赖的package包/类
private int findBackFacingCamera() {
cameraId = -1;
// Search for the back facing camera
// get the number of cameras
int numberOfCameras = Camera.getNumberOfCameras();
// for every camera check
for (int i = 0; i < numberOfCameras; i++) {
CameraInfo info = new CameraInfo();
Camera.getCameraInfo(i, info);
if (info.facing == CameraInfo.CAMERA_FACING_BACK) {
cameraId = i;
cameraFront = false;
break;
}
}
return cameraId;
}
示例13: setUpCamera
import android.hardware.Camera.CameraInfo; //导入依赖的package包/类
private void setUpCamera(final int id) {
mCameraInstance = getCameraInstance(id);
Parameters parameters = mCameraInstance.getParameters();
// TODO adjust by getting supportedPreviewSizes and then choosing
// the best one for screen size (best fill screen)
if (parameters.getSupportedFocusModes().contains(
Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)) {
parameters.setFocusMode(Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
}
mCameraInstance.setParameters(parameters);
int orientation = mCameraHelper.getCameraDisplayOrientation(
ActivityCamera.this, mCurrentCameraId);
CameraInfo2 cameraInfo = new CameraInfo2();
mCameraHelper.getCameraInfo(mCurrentCameraId, cameraInfo);
boolean flipHorizontal = cameraInfo.facing == CameraInfo.CAMERA_FACING_FRONT;
mGPUImage.setUpCamera(mCameraInstance, orientation, flipHorizontal, false);
}
示例14: switchCamera
import android.hardware.Camera.CameraInfo; //导入依赖的package包/类
@SuppressLint("NewApi")
public void switchCamera(SurfaceHolder mHolder) {
if(mCamera != null)
{
mCamera.stopPreview();
mCamera.release();
if (currentCamera == CameraInfo.CAMERA_FACING_BACK) {
currentCamera = CameraInfo.CAMERA_FACING_FRONT;
} else {
currentCamera = CameraInfo.CAMERA_FACING_BACK;
}
mCamera = Camera.open(currentCamera);
try {
mCamera.setPreviewDisplay(mHolder);
cameraDisplayOrientation = CameraHelper.getCameraDisplayOrientation(
(Activity)mContext, currentCamera);
mCamera.setDisplayOrientation(cameraDisplayOrientation);
mCamera.startPreview();
} catch (Exception e) {
e.printStackTrace();
}
}
}
示例15: initCamera
import android.hardware.Camera.CameraInfo; //导入依赖的package包/类
@SuppressLint("NewApi")
private boolean initCamera() {
try {
if (frontCamera == 0) {
mCamera = Camera.open(CameraInfo.CAMERA_FACING_BACK);
} else {
mCamera = Camera.open(CameraInfo.CAMERA_FACING_FRONT);
}
Camera.Parameters camParams = mCamera.getParameters();
mCamera.lock();
mSurfaceHolder = mVideoView.getHolder();
mSurfaceHolder.addCallback(this);
mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
mCamera.setDisplayOrientation(90);
} catch (RuntimeException ex) {
EMLog.e("video", "init Camera fail " + ex.getMessage());
return false;
}
return true;
}