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


Java Camera.CameraInfo方法代码示例

本文整理汇总了Java中android.hardware.Camera.CameraInfo方法的典型用法代码示例。如果您正苦于以下问题:Java Camera.CameraInfo方法的具体用法?Java Camera.CameraInfo怎么用?Java Camera.CameraInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.hardware.Camera的用法示例。


在下文中一共展示了Camera.CameraInfo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCurrentCamera

import android.hardware.Camera; //导入方法依赖的package包/类
/**
 * Returns current camera identifier.
 *
 * @return Camera id.
 */
private int getCurrentCamera() {
    Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
    int cameraCount = Camera.getNumberOfCameras();
    for(int camIdx = 0; camIdx < cameraCount; camIdx++) {
        Camera.getCameraInfo(camIdx, cameraInfo);
        if(mFrontCamera && cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
            logi("returning front camera");
            return camIdx;
        } else if(!mFrontCamera && cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_BACK) {
            logi("returning back camera");
            return camIdx;
        }

    }
    return -1;
}
 
开发者ID:Samsung,项目名称:microbit,代码行数:22,代码来源:CameraActivity_OldAPI.java

示例2: configureRecorder

import android.hardware.Camera; //导入方法依赖的package包/类
protected void configureRecorder(int quality, MediaRecorder recorder) {
    Camera.CameraInfo info = new Camera.CameraInfo();
    Camera.getCameraInfo(cameraInfo.cameraId, info);
    int displayOrientation = getDisplayOrientation(info, false);
    recorder.setOrientationHint(displayOrientation);

    int highProfile = getHigh();
    boolean canGoHigh = CamcorderProfile.hasProfile(cameraInfo.cameraId, highProfile);
    boolean canGoLow = CamcorderProfile.hasProfile(cameraInfo.cameraId, CamcorderProfile.QUALITY_LOW);
    if (canGoHigh && (quality == 1 || !canGoLow)) {
        recorder.setProfile(CamcorderProfile.get(cameraInfo.cameraId, highProfile));
    } else if (canGoLow) {
        recorder.setProfile(CamcorderProfile.get(cameraInfo.cameraId, CamcorderProfile.QUALITY_LOW));
    } else {
        throw new IllegalStateException("cannot find valid CamcorderProfile");
    }
    isVideo = true;
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:19,代码来源:CameraSession.java

示例3: CameraPreview

import android.hardware.Camera; //导入方法依赖的package包/类
public CameraPreview(Context context, Camera camera, Camera.CameraInfo cameraInfo,
                     int displayOrientation) {
    super(context);

    // Do not initialise if no camera has been set
    if (camera == null || cameraInfo == null) {
        return;
    }
    mCamera = camera;
    mCameraInfo = cameraInfo;
    mDisplayOrientation = displayOrientation;

    // Install a SurfaceHolder.Callback so we get notified when the
    // underlying surface is created and destroyed.
    mHolder = getHolder();
    mHolder.addCallback(this);
}
 
开发者ID:GeekyShiva,项目名称:Self-Driving-Car,代码行数:18,代码来源:CameraPreview.java

示例4: setDefaultCameraId

import android.hardware.Camera; //导入方法依赖的package包/类
private void setDefaultCameraId(){
  // Find the total number of cameras available
  numberOfCameras = Camera.getNumberOfCameras();

  int camId = defaultCamera.equals("front") ? Camera.CameraInfo.CAMERA_FACING_FRONT : Camera.CameraInfo.CAMERA_FACING_BACK;

  // Find the ID of the default camera
  Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
  for (int i = 0; i < numberOfCameras; i++) {
    Camera.getCameraInfo(i, cameraInfo);
    if (cameraInfo.facing == camId) {
      defaultCameraId = camId;
      break;
    }
  }
}
 
开发者ID:MrShakes,项目名称:cameraPreviewStream,代码行数:17,代码来源:CameraActivity.java

示例5: CameraManager

import android.hardware.Camera; //导入方法依赖的package包/类
private CameraManager() {
    for (int i = 0; i < Camera.getNumberOfCameras(); i++) {
        Camera.CameraInfo info = new Camera.CameraInfo();
        Camera.getCameraInfo(i, info);
        mCameraInfoHashMap.put(i, info);

        if (info.facing == Camera.CameraInfo.CAMERA_FACING_BACK) {
            mTypeToIndex.put(TYPE_CAMERA_BACK, i);
        } else {
            mTypeToIndex.put(TYPE_CAMERA_FRONT, i);
        }
    }
}
 
开发者ID:cuonghuynhvan,项目名称:react-native-camera-android-simple,代码行数:14,代码来源:CameraManager.java

示例6: getDisplayOrientation

import android.hardware.Camera; //导入方法依赖的package包/类
public int getDisplayOrientation() {
    Camera.CameraInfo info = new Camera.CameraInfo();
    Camera.getCameraInfo(Camera.CameraInfo.CAMERA_FACING_BACK, info);
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();

    int rotation = display.getRotation();
    int degrees = 0;
    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;
    }

    int result;
    if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
        result = (info.orientation + degrees) % 360;
        result = (360 - result) % 360;
    } else {
        result = (info.orientation - degrees + 360) % 360;
    }
    return result;
}
 
开发者ID:RuanXiaoHui,项目名称:ZxingScan,代码行数:33,代码来源:CameraConfigurationManager.java

示例7: getCameraId

import android.hardware.Camera; //导入方法依赖的package包/类
public static int getCameraId(int requestedId) {
    int numCameras = Camera.getNumberOfCameras();
    if (numCameras == 0) {
        Log.w(TAG, "No cameras!");
        return -1;
    }

    int cameraId = requestedId;

    boolean explicitRequest = cameraId >= 0;

    if (!explicitRequest) {
        // Select a camera if no explicit camera requested
        int index = 0;
        while (index < numCameras) {
            Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
            Camera.getCameraInfo(index, cameraInfo);
            if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_BACK) {
                break;
            }
            index++;
        }

        cameraId = index;
    }

    if (cameraId < numCameras) {
        return cameraId;
    } else {
        if (explicitRequest) {
            return -1;
        } else {
            return 0;
        }
    }
}
 
开发者ID:yinhaojun,项目名称:ZxingForAndroid,代码行数:37,代码来源:OpenCameraInterface.java

示例8: startCamera

import android.hardware.Camera; //导入方法依赖的package包/类
/**
 * 打开指定摄像头开始预览,但是并未开始识别
 *
 * @param cameraFacing
 */
public void startCamera(int cameraFacing) {
    if (mCamera != null) {
        return;
    }
    Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
    for (int cameraId = 0; cameraId < Camera.getNumberOfCameras(); cameraId++) {
        Camera.getCameraInfo(cameraId, cameraInfo);
        if (cameraInfo.facing == cameraFacing) {
            startCameraById(cameraId);
            break;
        }
    }
}
 
开发者ID:devzwy,项目名称:NeiHanDuanZiTV,代码行数:19,代码来源:QRCodeView.java

示例9: getDisplayOrientation

import android.hardware.Camera; //导入方法依赖的package包/类
public static int getDisplayOrientation(int degrees, Camera.CameraInfo info) {

    int result;
    if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
      result = (info.orientation + degrees) % 360;
      result = (360 - result) % 360;  // compensate the mirror
    } else {  // back-facing
      result = (info.orientation - degrees + 360) % 360;
    }
    return result;
  }
 
开发者ID:windwang,项目名称:react-native-face-detect,代码行数:12,代码来源:Converter.java

示例10: getBackCamera

import android.hardware.Camera; //导入方法依赖的package包/类
private Pair<Camera.CameraInfo, Integer> getBackCamera() {
    Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
    final int numberOfCameras = Camera.getNumberOfCameras();

    // Iterates through each camera and, if camera id is for back camera, returns its index and info
    for (int i = 0; i < numberOfCameras; ++i) {
        Camera.getCameraInfo(i, cameraInfo);
        if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_BACK) {
            return new Pair<Camera.CameraInfo, Integer>(cameraInfo,
                    Integer.valueOf(i));
        }
    }
    return null;
}
 
开发者ID:csarron,项目名称:renderscript_examples,代码行数:15,代码来源:CameraHandler.java

示例11: DecoderWrapper

import android.hardware.Camera; //导入方法依赖的package包/类
public DecoderWrapper(@NonNull Camera camera, @NonNull Camera.CameraInfo cameraInfo, @NonNull Decoder decoder,
        @NonNull Point imageSize, @NonNull Point previewSize, @NonNull Point viewSize, int displayOrientation,
        boolean autoFocusSupported, boolean flashSupported) {
    mCamera = camera;
    mCameraInfo = cameraInfo;
    mDecoder = decoder;
    mImageSize = imageSize;
    mPreviewSize = previewSize;
    mViewSize = viewSize;
    mDisplayOrientation = displayOrientation;
    mReverseHorizontal = cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT;
    mAutoFocusSupported = autoFocusSupported;
    mFlashSupported = flashSupported;
}
 
开发者ID:yuriy-budiyev,项目名称:code-scanner,代码行数:15,代码来源:DecoderWrapper.java

示例12: open

import android.hardware.Camera; //导入方法依赖的package包/类
/**
 * Opens the requested camera with {@link Camera#open(int)}, if one exists.
 *
 * @param cameraId camera ID of the camera to use. A negative value
 *                 or {@link #NO_REQUESTED_CAMERA} means "no preference", in which case a rear-facing
 *                 camera is returned if possible or else any camera
 * @return handle to {@link OpenCamera} that was opened
 */
public static OpenCamera open(int cameraId) {

    int numCameras = Camera.getNumberOfCameras();
    if (numCameras == 0) {
        Log.w(TAG, "No cameras!");
        return null;
    }

    boolean explicitRequest = cameraId >= 0;

    Camera.CameraInfo selectedCameraInfo = null;
    int index;
    if (explicitRequest) {
        index = cameraId;
        selectedCameraInfo = new Camera.CameraInfo();
        Camera.getCameraInfo(index, selectedCameraInfo);
    } else {
        index = 0;
        while (index < numCameras) {
            Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
            Camera.getCameraInfo(index, cameraInfo);
            CameraFacing reportedFacing = CameraFacing.values()[cameraInfo.facing];
            if (reportedFacing == CameraFacing.BACK) {
                selectedCameraInfo = cameraInfo;
                break;
            }
            index++;
        }
    }

    Camera camera;
    if (index < numCameras) {
        Log.i(TAG, "Opening camera #" + index);
        camera = Camera.open(index);
    } else {
        if (explicitRequest) {
            Log.w(TAG, "Requested camera does not exist: " + cameraId);
            camera = null;
        } else {
            Log.i(TAG, "No camera facing " + CameraFacing.BACK + "; returning camera #0");
            camera = Camera.open(0);
            selectedCameraInfo = new Camera.CameraInfo();
            Camera.getCameraInfo(0, selectedCameraInfo);
        }
    }

    if (camera == null) {
        return null;
    }
    return new OpenCamera(index,
            camera,
            CameraFacing.values()[selectedCameraInfo.facing],
            selectedCameraInfo.orientation);
}
 
开发者ID:xiong-it,项目名称:ZXingAndroidExt,代码行数:63,代码来源:OpenCameraInterface.java

示例13: getCameraInfo

import android.hardware.Camera; //导入方法依赖的package包/类
private @NonNull CameraInfo getCameraInfo() {
  final CameraInfo info = new Camera.CameraInfo();
  Camera.getCameraInfo(cameraId, info);
  return info;
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:6,代码来源:CameraView.java

示例14: open

import android.hardware.Camera; //导入方法依赖的package包/类
/**
 * Opens the requested camera with {@link Camera#open(int)}, if one exists.
 *
 * @param cameraId camera ID of the camera to use. A negative value
 *  or {@link #NO_REQUESTED_CAMERA} means "no preference", in which case a rear-facing
 *  camera is returned if possible or else any camera
 * @return handle to {@link OpenCamera} that was opened
 */
public static OpenCamera open(int cameraId) {

  int numCameras = Camera.getNumberOfCameras();
  if (numCameras == 0) {
    Log.w(TAG, "No cameras!");
    return null;
  }

  boolean explicitRequest = cameraId >= 0;

  Camera.CameraInfo selectedCameraInfo = null;
  int index;
  if (explicitRequest) {
    index = cameraId;
    selectedCameraInfo = new Camera.CameraInfo();
    Camera.getCameraInfo(index, selectedCameraInfo);
  } else {
    index = 0;
    while (index < numCameras) {
      Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
      Camera.getCameraInfo(index, cameraInfo);
      CameraFacing reportedFacing = CameraFacing.values()[cameraInfo.facing];
      if (reportedFacing == CameraFacing.BACK) {
        selectedCameraInfo = cameraInfo;
        break;
      }
      index++;
    }
  }

  Camera camera;
  if (index < numCameras) {
    Log.i(TAG, "Opening camera #" + index);
    camera = Camera.open(index);
  } else {
    if (explicitRequest) {
      Log.w(TAG, "Requested camera does not exist: " + cameraId);
      camera = null;
    } else {
      Log.i(TAG, "No camera facing " + CameraFacing.BACK + "; returning camera #0");
      camera = Camera.open(0);
      selectedCameraInfo = new Camera.CameraInfo();
      Camera.getCameraInfo(0, selectedCameraInfo);
    }
  }

  if (camera == null) {
    return null;
  }
  return new OpenCamera(index,
                        camera,
                        CameraFacing.values()[selectedCameraInfo.facing],
                        selectedCameraInfo.orientation);
}
 
开发者ID:Zmingxu,项目名称:ZxingScanner,代码行数:63,代码来源:OpenCameraInterface.java

示例15: switchCamara

import android.hardware.Camera; //导入方法依赖的package包/类
private void switchCamara() {
    //切换前后摄像头
    int cameraCount = 0;
    Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
    cameraCount = Camera.getNumberOfCameras();//得到摄像头的个数

    for (int i = 0; i < cameraCount; i++) {
        Camera.getCameraInfo(i, cameraInfo);//得到每一个摄像头的信息
        if (cameraPosition == 1) {
            //现在是后置,变更为前置
            if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_BACK) {//代表摄像头的方位,CAMERA_FACING_FRONT前置      CAMERA_FACING_BACK后置
                if (surfaceView != null && surfaceView.getHolder() != null && previewCallBack != null) {
                    surfaceView.getHolder().removeCallback(previewCallBack);
                }
                mCamera.setPreviewCallback(null);
                mCamera.stopPreview();//停掉原来摄像头的预览
                mCamera.lock();
                mCamera.release();//释放资源
                mCamera = null;//取消原来摄像头
                mCamera = Camera.open(i);//打开当前选中的摄像头
               /* try {
                    if (null != mholder)
                        mCamera.setPreviewDisplay(mholder);//通过surfaceview显示取景画面
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                mCamera.startPreview();//开始预览*/
                if (null != mholder)
                    setParams(mholder, Camera.CameraInfo.CAMERA_FACING_BACK);
                cameraPosition = 0;
                break;
            }
        } else {
            //现在是前置, 变更为后置
            if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {//代表摄像头的方位,CAMERA_FACING_FRONT前置      CAMERA_FACING_BACK后置
                if (surfaceView != null && surfaceView.getHolder() != null && previewCallBack != null) {
                    surfaceView.getHolder().removeCallback(previewCallBack);
                }
                mCamera.setPreviewCallback(null);
                mCamera.stopPreview();//停掉原来摄像头的预览
                mCamera.lock();
                mCamera.release();//释放资源
                mCamera = null;//取消原来摄像头
                mCamera = Camera.open(i);//打开当前选中的摄像头
                /*try {
                    if (null != mholder)
                        mCamera.setPreviewDisplay(mholder);//通过surfaceview显示取景画面
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                mCamera.startPreview();//开始预览*/
                if (null != mholder)
                    setParams(mholder, Camera.CameraInfo.CAMERA_FACING_FRONT);
                cameraPosition = 1;
                break;
            }
        }

    }
}
 
开发者ID:yzzslow0,项目名称:Ec2m,代码行数:63,代码来源:CamaraActivity.java


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