以下是我写的使用Camera Parameters 获取相机相关参数的例子,展示如何
逐个获取所需的参数,在此记录下,为方便自己Review,也希望能帮到其他人。
其中,picture 相关的,Preview相关的都是大家比较关心的。
(貌似对其没弄好,不知道是Eclipse配置问题,还是这个CSDN粘贴代码有问题,或者二者兼有?? )
- Camera.Parameters parameters = mcamera.getParameters();
- int CurPreFmt = parameters.getPreviewFormat();
-
- Log.d("LeoHDRTest", "Enter SurfaceChanged Function ");
- Log.d("LeoHDRTest", "PreviewFormat =" + CurPreFmt);
- switch(CurPreFmt)
- {
- case ImageFormat.JPEG:
- Log.d("LeoHDRTest", "Current Preview Format is JPEG");
- break;
- case ImageFormat.NV16:
- Log.d("LeoHDRTest", "Current Preview Format is NV16");
- break;
- case ImageFormat.NV21:
- Log.d("LeoHDRTest", "Current Preview Format is NV21");
- break;
- case ImageFormat.RGB_565:
- Log.d("LeoHDRTest", "Current Preview Format is RGB_565");
- break;
- case ImageFormat.YUY2:
- Log.d("LeoHDRTest", "Current Preview Format is YUY2");
- break;
- case ImageFormat.YV12:
- Log.d("LeoHDRTest", "Current Preview Format is YV12");
- break;
- case ImageFormat.UNKNOWN:
- Log.d("LeoHDRTest", "Current Preview Format is UNKNOWN");
- break;
- default:
- Log.d("LeoHDRTest", "Current Preview Format is default : UNKNOWN");
- break;
-
- }
-
-
- Size CurpreSize = parameters.getPreviewSize();
- Log.d("LeoHDRTest", "current Preview Size :" + CurpreSize.width + " x " + CurpreSize.height);
-
-
- Size curPicSize = parameters.getPictureSize();
- Log.d("LeoHDRTest", "current Picture Size :" + curPicSize.width + " x " + curPicSize.height);
-
- int CurPicFmt = parameters.getPictureFormat();
- switch(CurPicFmt)
- {
- case ImageFormat.JPEG:
- Log.d("LeoHDRTest", "Picture Format is JPEG");
- break;
- case ImageFormat.NV16:
- Log.d("LeoHDRTest", "Picture Format is NV16");
- break;
- case ImageFormat.NV21:
- Log.d("LeoHDRTest", "Picture Format is NV21");
- break;
- case ImageFormat.RGB_565:
- Log.d("LeoHDRTest", "Picture Format is RGB_565");
- break;
- case ImageFormat.YUY2:
- Log.d("LeoHDRTest", "Picture Format is YUY2");
- break;
- case ImageFormat.YV12:
- Log.d("LeoHDRTest", "Picture Format is YV12");
- break;
- case ImageFormat.UNKNOWN:
- Log.d("LeoHDRTest", "Picture Format is UNKNOWN");
- break;
- default:
- Log.d("LeoHDRTest", "Picture Format is default : UNKNOWN");
- break;
-
- }
-
- int CurPreRange[];
- CurPreRange = new int[2];
- parameters.getPreviewFpsRange(CurPreRange);
- Log.d("LeoHDRTest", "Current Preview MinFps = " + CurPreRange[0]
- + " MaxFps = " + CurPreRange[1]);
-
-
- Log.d("LeoHDRTest", "Current EV setting is " +
- parameters.getExposureCompensation() * parameters.getExposureCompensationStep());
-
- Log.d("LeoHDRTest", "Jpeg Quality = " + parameters.getJpegQuality());
-
-
- Log.d("LeoHDRTest", " Min Exposure Comp = " + parameters.getMinExposureCompensation()
- + " Max Exposure Com = " + parameters.getMaxExposureCompensation());
-
- String strCurFocusMode = parameters.getFocusMode();
- if (strCurFocusMode.equalsIgnoreCase(Camera.Parameters.FOCUS_MODE_AUTO)) {
-
- Log.d("LeoHDRTest", "Current Focus Mode is FOCUS_MODE_AUTO");
-
- }else if (strCurFocusMode.equalsIgnoreCase(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)) {
-
- Log.d("LeoHDRTest", "Current Focus Mode is FOCUS_MODE_CONTINUOUS_PICTURE");
-
- }else if (strCurFocusMode.equalsIgnoreCase(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO)) {
-
- Log.d("LeoHDRTest", "Current Focus Mode is FOCUS_MODE_CONTINUOUS_VIDEO");
-
- }else if (strCurFocusMode.equalsIgnoreCase(Camera.Parameters.FOCUS_MODE_INFINITY)) {
-
- Log.d("LeoHDRTest", "Current Focus Mode is FOCUS_MODE_INFINITY");
-
- }else if (strCurFocusMode.equalsIgnoreCase(Camera.Parameters.FOCUS_MODE_MACRO)) {
-
- Log.d("LeoHDRTest", "Current Focus Mode is FOCUS_MODE_MACRO");
-
- }else if (strCurFocusMode.equalsIgnoreCase(Camera.Parameters.FOCUS_MODE_FIXED)) {
-
- Log.d("LeoHDRTest", "Current Focus Mode is FOCUS_MODE_FIXED");
-
- }else if (strCurFocusMode.equalsIgnoreCase(Camera.Parameters.FOCUS_MODE_EDOF)) {
-
- Log.d("LeoHDRTest", "Current Focus Mode is FOCUS_MODE_EDOF");
- }
-
-
- List<int[]> SupPreFpsRangeList = parameters.getSupportedPreviewFpsRange();
- int SupPreRange[] = new int[2];
-
- Log.d("LeoHDRTest", "Support Preview FPS Range List : " );
- for(int num = 0; num < SupPreFpsRangeList.size(); num++)
- {
- SupPreRange = SupPreFpsRangeList.get(num);
- Log.d("LeoHDRTest", "< " + num + " >" + " Min = " + SupPreRange[0]
- + " Max = " + SupPreRange[1]);
- }
-
-
- if(parameters.isAutoExposureLockSupported() )
- {
- if(parameters.getAutoExposureLock())
- {
- Log.d("LeoHDRTest", "Auto Exposure is Locked");
- }
- else
- {
- Log.d("LeoHDRTest", "Auto Exposure is not Locked");
- }
- }
-
-
-
-
- List<String> focusModesList = parameters.getSupportedFocusModes();
- if (focusModesList.contains(Camera.Parameters.FOCUS_MODE_AUTO)) {
-
- Log.d("LeoHDRTest", "Camera Support AUTO FOCUS MODE");
-
- }else if (focusModesList.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)) {
-
- Log.d("LeoHDRTest", "Current Focus Mode is FOCUS_MODE_CONTINUOUS_PICTURE");
-
- }else if (focusModesList.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO)) {
-
- Log.d("LeoHDRTest", "Current Focus Mode is FOCUS_MODE_CONTINUOUS_VIDEO");
-
- }else if (focusModesList.contains(Camera.Parameters.FOCUS_MODE_INFINITY)) {
-
- Log.d("LeoHDRTest", "Current Focus Mode is FOCUS_MODE_INFINITY");
-
- }else if (focusModesList.contains(Camera.Parameters.FOCUS_MODE_MACRO)) {
-
- Log.d("LeoHDRTest", "Current Focus Mode is FOCUS_MODE_MACRO");
-
- }else if (focusModesList.contains(Camera.Parameters.FOCUS_MODE_FIXED)) {
-
- Log.d("LeoHDRTest", "Current Focus Mode is FOCUS_MODE_FIXED");
-
- }else if (focusModesList.contains(Camera.Parameters.FOCUS_MODE_EDOF)) {
-
- Log.d("LeoHDRTest", "Current Focus Mode is FOCUS_MODE_EDOF");
- }
-
- List<Integer> supPicFmtList = parameters.getSupportedPictureFormats();
- Log.d("LeoHDRTest", "Supported Picutre Format :" );
-
- for(int num = 0; num < supPicFmtList.size(); num++)
- {
- Integer ISupPicFmt = supPicFmtList.get(num);
- Log.d("LeoHDRTest", "" + ISupPicFmt.intValue());
-
- }
-
-
- List<Integer> supPreFmtList = parameters.getSupportedPreviewFormats();
- Log.d("LeoHDRTest", "Supported Preview Format :");
-
- for(int num = 0; num < supPreFmtList.size(); num++)
- {
- Integer ISupPreFmt = supPreFmtList.get(num);
- Log.d("LeoHDRTest", "" + ISupPreFmt.intValue());
-
- }
-
-
- List<Size> PicSupSizeList = parameters.getSupportedPictureSizes();
-
- Log.d("LeoHDRTest", "Camera Supported Pic Size are :");
- for(int num = 0; num < PicSupSizeList.size(); num++)
- {
- Size PicSupSize = PicSupSizeList.get(num);
- Log.d("LeoHDRTest", "< " + num +" >" + PicSupSize.width + " x " + PicSupSize.height);
- }
-
- Log.d("LeoHDRTest", "Camera Supported Preview Size are :");
- List<Size> supPreviewList = parameters.getSupportedPreviewSizes();
- for(int num = 0; num < supPreviewList.size(); num++)
- {
- Size PicPreSupSize = supPreviewList.get(num);
- Log.d("LeoHDRTest", "< " + num +" >" + PicPreSupSize.width + " x " + PicPreSupSize.height);
- }
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报。