打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Android Camera Parameters 获取

以下是我写的使用Camera Parameters 获取相机相关参数的例子,展示如何

逐个获取所需的参数,在此记录下,为方便自己Review,也希望能帮到其他人。


其中,picture 相关的,Preview相关的都是大家比较关心的。


(貌似对其没弄好,不知道是Eclipse配置问题,还是这个CSDN粘贴代码有问题,或者二者兼有?? )



  1. Camera.Parameters parameters = mcamera.getParameters();   
  2.         int    CurPreFmt = parameters.getPreviewFormat();  
  3.           
  4.         Log.d("LeoHDRTest""Enter SurfaceChanged Function ");  
  5.         Log.d("LeoHDRTest""PreviewFormat =" + CurPreFmt);  
  6.         switch(CurPreFmt)  
  7.         {  
  8.         case ImageFormat.JPEG:  
  9.             Log.d("LeoHDRTest""Current Preview Format is JPEG");  
  10.             break;  
  11.         case ImageFormat.NV16:  
  12.             Log.d("LeoHDRTest""Current Preview Format is NV16");  
  13.             break;  
  14.         case ImageFormat.NV21:  
  15.             Log.d("LeoHDRTest""Current Preview Format is NV21");  
  16.             break;  
  17.         case ImageFormat.RGB_565:  
  18.             Log.d("LeoHDRTest""Current Preview Format is RGB_565");  
  19.             break;  
  20.         case ImageFormat.YUY2:  
  21.             Log.d("LeoHDRTest""Current Preview Format is YUY2");  
  22.             break;  
  23.         case ImageFormat.YV12:  
  24.             Log.d("LeoHDRTest""Current Preview Format is YV12");  
  25.             break;    
  26.         case ImageFormat.UNKNOWN:  
  27.             Log.d("LeoHDRTest""Current Preview Format is UNKNOWN");  
  28.             break;    
  29.         default:  
  30.             Log.d("LeoHDRTest""Current Preview Format is default : UNKNOWN");  
  31.             break;                
  32.               
  33.         }  
  34.           
  35.           
  36.         Size CurpreSize = parameters.getPreviewSize();   
  37.         Log.d("LeoHDRTest""current Preview Size :" + CurpreSize.width + " x " + CurpreSize.height);  
  38.           
  39.           
  40.         Size curPicSize = parameters.getPictureSize();  
  41.         Log.d("LeoHDRTest""current Picture Size :" + curPicSize.width + " x " + curPicSize.height);  
  42.           
  43.         int  CurPicFmt = parameters.getPictureFormat();  
  44.         switch(CurPicFmt)  
  45.         {  
  46.         case ImageFormat.JPEG:  
  47.             Log.d("LeoHDRTest""Picture Format is JPEG");  
  48.             break;  
  49.         case ImageFormat.NV16:  
  50.             Log.d("LeoHDRTest""Picture Format is NV16");  
  51.             break;  
  52.         case ImageFormat.NV21:  
  53.             Log.d("LeoHDRTest""Picture Format is NV21");  
  54.             break;  
  55.         case ImageFormat.RGB_565:  
  56.             Log.d("LeoHDRTest""Picture Format is RGB_565");  
  57.             break;  
  58.         case ImageFormat.YUY2:  
  59.             Log.d("LeoHDRTest""Picture Format is YUY2");  
  60.             break;  
  61.         case ImageFormat.YV12:  
  62.             Log.d("LeoHDRTest""Picture Format is YV12");  
  63.             break;    
  64.         case ImageFormat.UNKNOWN:  
  65.             Log.d("LeoHDRTest""Picture Format is UNKNOWN");  
  66.             break;    
  67.         default:  
  68.             Log.d("LeoHDRTest""Picture Format is default : UNKNOWN");  
  69.             break;    
  70.               
  71.         }  
  72.                   
  73.         int CurPreRange[];  
  74.         CurPreRange = new int[2];  
  75.         parameters.getPreviewFpsRange(CurPreRange);  
  76.         Log.d("LeoHDRTest""Current Preview MinFps = " + CurPreRange[0]  
  77.                 + "  MaxFps = " + CurPreRange[1]);  
  78.           
  79.           
  80.         Log.d("LeoHDRTest""Current EV setting is " +   
  81.         parameters.getExposureCompensation() * parameters.getExposureCompensationStep());  
  82.           
  83.         Log.d("LeoHDRTest""Jpeg Quality = " + parameters.getJpegQuality());  
  84.           
  85.           
  86.         Log.d("LeoHDRTest"" Min Exposure Comp  = " + parameters.getMinExposureCompensation()  
  87.             + "  Max Exposure Com = " + parameters.getMaxExposureCompensation());  
  88.           
  89.         String strCurFocusMode = parameters.getFocusMode();  
  90.         if (strCurFocusMode.equalsIgnoreCase(Camera.Parameters.FOCUS_MODE_AUTO)) {  
  91.               
  92.             Log.d("LeoHDRTest""Current Focus Mode is FOCUS_MODE_AUTO");  
  93.               
  94.         }else if (strCurFocusMode.equalsIgnoreCase(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)) {  
  95.               
  96.             Log.d("LeoHDRTest""Current Focus Mode is FOCUS_MODE_CONTINUOUS_PICTURE");  
  97.           
  98.         }else if (strCurFocusMode.equalsIgnoreCase(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO)) {  
  99.               
  100.             Log.d("LeoHDRTest""Current Focus Mode is FOCUS_MODE_CONTINUOUS_VIDEO");  
  101.           
  102.         }else if (strCurFocusMode.equalsIgnoreCase(Camera.Parameters.FOCUS_MODE_INFINITY)) {  
  103.               
  104.             Log.d("LeoHDRTest""Current Focus Mode is FOCUS_MODE_INFINITY");  
  105.           
  106.         }else if (strCurFocusMode.equalsIgnoreCase(Camera.Parameters.FOCUS_MODE_MACRO)) {  
  107.               
  108.             Log.d("LeoHDRTest""Current Focus Mode is FOCUS_MODE_MACRO");  
  109.           
  110.         }else if (strCurFocusMode.equalsIgnoreCase(Camera.Parameters.FOCUS_MODE_FIXED)) {  
  111.               
  112.             Log.d("LeoHDRTest""Current Focus Mode is FOCUS_MODE_FIXED");  
  113.           
  114.         }else if (strCurFocusMode.equalsIgnoreCase(Camera.Parameters.FOCUS_MODE_EDOF)) {  
  115.               
  116.             Log.d("LeoHDRTest""Current Focus Mode is FOCUS_MODE_EDOF");  
  117.         }  
  118.           
  119.           
  120.         List<int[]> SupPreFpsRangeList = parameters.getSupportedPreviewFpsRange();  
  121.         int SupPreRange[] = new int[2];  
  122.   
  123.         Log.d("LeoHDRTest""Support Preview FPS Range List :  " );  
  124.         for(int num = 0; num < SupPreFpsRangeList.size(); num++)  
  125.         {  
  126.             SupPreRange = SupPreFpsRangeList.get(num);    
  127.             Log.d("LeoHDRTest""< " + num + " >" + " Min = " + SupPreRange[0]  
  128.                     + "  Max = " + SupPreRange[1]);            
  129.         }  
  130.           
  131.           
  132.         if(parameters.isAutoExposureLockSupported() )  
  133.         {  
  134.             if(parameters.getAutoExposureLock())  
  135.             {  
  136.                 Log.d("LeoHDRTest""Auto Exposure is Locked");   
  137.             }  
  138.             else   
  139.             {  
  140.                 Log.d("LeoHDRTest""Auto Exposure is not Locked");   
  141.             }  
  142.         }  
  143.           
  144.           
  145.               
  146.               
  147.         List<String> focusModesList = parameters.getSupportedFocusModes();  
  148.         if (focusModesList.contains(Camera.Parameters.FOCUS_MODE_AUTO)) {  
  149.               
  150.             Log.d("LeoHDRTest""Camera Support AUTO FOCUS MODE");  
  151.           
  152.         }else if (focusModesList.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)) {  
  153.               
  154.             Log.d("LeoHDRTest""Current Focus Mode is FOCUS_MODE_CONTINUOUS_PICTURE");  
  155.           
  156.         }else if (focusModesList.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO)) {  
  157.               
  158.             Log.d("LeoHDRTest""Current Focus Mode is FOCUS_MODE_CONTINUOUS_VIDEO");  
  159.           
  160.         }else if (focusModesList.contains(Camera.Parameters.FOCUS_MODE_INFINITY)) {  
  161.               
  162.             Log.d("LeoHDRTest""Current Focus Mode is FOCUS_MODE_INFINITY");  
  163.           
  164.         }else if (focusModesList.contains(Camera.Parameters.FOCUS_MODE_MACRO)) {  
  165.               
  166.             Log.d("LeoHDRTest""Current Focus Mode is FOCUS_MODE_MACRO");  
  167.           
  168.         }else if (focusModesList.contains(Camera.Parameters.FOCUS_MODE_FIXED)) {  
  169.               
  170.             Log.d("LeoHDRTest""Current Focus Mode is FOCUS_MODE_FIXED");  
  171.           
  172.         }else if (focusModesList.contains(Camera.Parameters.FOCUS_MODE_EDOF)) {  
  173.               
  174.             Log.d("LeoHDRTest""Current Focus Mode is FOCUS_MODE_EDOF");  
  175.         }  
  176.           
  177.         List<Integer> supPicFmtList = parameters.getSupportedPictureFormats();  
  178.         Log.d("LeoHDRTest""Supported Picutre Format :" );  
  179.           
  180.         for(int num = 0; num < supPicFmtList.size(); num++)  
  181.         {  
  182.             Integer ISupPicFmt = supPicFmtList.get(num);      
  183.             Log.d("LeoHDRTest""" + ISupPicFmt.intValue());  
  184.               
  185.         }  
  186.           
  187.           
  188.         List<Integer> supPreFmtList = parameters.getSupportedPreviewFormats();   
  189.         Log.d("LeoHDRTest""Supported Preview Format :");  
  190.           
  191.         for(int num = 0; num < supPreFmtList.size(); num++)  
  192.         {  
  193.             Integer ISupPreFmt = supPreFmtList.get(num);      
  194.             Log.d("LeoHDRTest""" + ISupPreFmt.intValue());  
  195.               
  196.         }  
  197.           
  198.           
  199.         List<Size> PicSupSizeList = parameters.getSupportedPictureSizes();  
  200.   
  201.         Log.d("LeoHDRTest""Camera Supported Pic Size are :");  
  202.         for(int num = 0; num < PicSupSizeList.size(); num++)  
  203.         {  
  204.             Size PicSupSize = PicSupSizeList.get(num);    
  205.             Log.d("LeoHDRTest""< " + num +" >" + PicSupSize.width + " x " + PicSupSize.height);  
  206.         }  
  207.           
  208.         Log.d("LeoHDRTest""Camera Supported Preview Size are :");  
  209.         List<Size> supPreviewList = parameters.getSupportedPreviewSizes();  
  210.         for(int num = 0; num < supPreviewList.size(); num++)  
  211.         {  
  212.             Size PicPreSupSize = supPreviewList.get(num);     
  213.             Log.d("LeoHDRTest""< " + num +" >" + PicPreSupSize.width + " x " + PicPreSupSize.height);  
  214.         }  


本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
高通平台如何抓取死机定屏log
火炬打开时奇怪的Android相机行为
我从未见过如此优雅的 Markdown 编辑器
交谊舞曲系列精选50首
RT8060A应用电路及封装图
去除C语言注释
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服