在 Android 手機內的相機功能是很強大,相機功能參數也很豐富,用 android.hardware.Camera 的 API(Camera1)便可以讀取相機參數(Camera Parameters),筆者編寫了簡單的相機參數程式(Camera Parameters Program)。
Android Studio 相機參數程式(Camera Parameters Program) |
- 操作系統:Windows 7 64-bit 版本
- 開發環境:Android Studio 4.0.1 版本
- 原程式:C:\Development\Development_Android\Android_Project\DIY-Android-018-13 Camera Bugworkshop
- 程式:C:\Development\Development_Android\Android_Project\DIY-Android-018-13 Camera Bugworkshop
- 測試環境:Vivo(維沃)X5Max Android 4.4.4(KitKat)版本
Android 相機參數程式(Camera Parameters Program)編程步驟:
- 設定 Camera 參數
- 設置 layout ScrollView 參數 - activity_camera.xml
- 讀取手機相機參數
AndroidManifest.xml獲取Camera許可權:
<uses-permission android:name="android.permission.CAMERA" /> |
activity_camera.xml:
<?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:padding="10dp" tools:context=".MainActivity">
<LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical">
<TextView android:id="@+id/textView" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Camera" /> </LinearLayout>
</ScrollView> |
MainActivity.java:
package bugworkshop.blogspot.com.cameraparameters;
import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.widget.TextView; import android.hardware.Camera;
public class MainActivity extends AppCompatActivity {
private TextView mTv_camea; private Camera mCamera;
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_camera); mTv_camea = (TextView) findViewById(R.id.textView);
mCamera = Camera.open(); Camera.Parameters p = mCamera.getParameters();
String params = p.flatten().replace(";", "\n"); mTv_camea.setText(params); } } |
Camera Parameters - Vivo(維沃)X5Max:
flash-duty-max=1 mnr-e=0 zoom=0 fb-smooth-level-max=4 max-num-detected-faces-hw=15 mtk-awb-s=true cap-mode=normal fb-touch-pos=-2000:-2000 aflamp-mode-values=off,on,auto whitebalance=auto fb-slim-face-min=-4 afeng-min-focus-step=0 preview-format-values=yuv420sp,yuv420p,yuv420i-yyuvyy-3plane rotation=0 jpeg-thumbnail-quality=100 preview-format=yuv420sp mnr-s=true video-hdr-values=off pip-fps-zsd-on=24 dynamic-frame-rate=true vrd-mfr-low=15 iso-speed=auto face-beauty=false video-hdr=off hsvr-size-fps=640x480x120 flash-mode-values=off,on,auto,red-eye,torch hue-values=low,middle,high aflamp-mode=off cshot-indicator-supported=true preview-frame-rate=30 3dnr-mode-values=on,off vrd-mfr-max=30 jpeg-thumbnail-width=160 video-size=640x480 scene-mode-values=auto,portrait,landscape,night,night-portrait,theatre,beach,snow,sunset,steadyphoto,fireworks,sports,party, candlelight,hdr,normal
mtk-shad-s=true feature-max-fps=24@VFB+EIS preview-fps-range-values=(5000,60000) fb-slim-face-max=4 contrast-values=low,middle,high fb-face-pos=-2000:-2000 preview-size-values=176x144,320x240,352x288,480x320,480x368,640x480,720x480,800x480,800x600,864x480,960x540, 1280x720,1280x960,1440x1080,1920x1080,1920x1088
fb-enlarge-eye-max=4 preview-fps-range=5000,60000 fb-enlarge-eye-min=-4 min-exposure-compensation=-12 antibanding=50hz max-num-focus-areas=1 vertical-view-angle=49 fb-smooth-level-min=-4 flash-duty-min=0 fb-skin-color=0 video-stabilization-supported=true brightness_value=0 vdr-cc2m-s=false saturation-values=low,middle,high eng-mfll-s=true stereo-image-refocus-values=on,off eng-mfll-e=false vdr-r4k2k-s=false mtk-123-shad-s=true flash-duty-value=-1 vrd-mfr-e=true sv2-s=3 vrd-mfr-high=30 edge=middle picture-format-values=jpeg iso-speed-values=auto,100,200,400,800,1600 sr-shad-s=true m-ss=0 exposure-compensation-step=0.25 eng-s-shad-t=0 m-sr-g=0 stereo-depth-af-values=on,off picture-size=2560x1920 vrd-mfr-s=true saturation=middle whitebalance-values=auto,incandescent,fluorescent,warm-fluorescent,daylight,cloudy-daylight,twilight,shade picture-format=jpeg cshot-indicator=true fb-enlarge-eye=0 pip-fps-zsd-off=30 afeng-max-focus-step=1023 preferred-preview-size-for-video=1920x1080 flash-step-min=0 hue=middle video-stabilization=false zoom-supported=true fb-smooth-level=0 vrd-mfr-min=15 fb-sharp=0 contrast=middle vdr-r2m-s=true scene-mode=auto jpeg-quality=100 face-beauty-supported=true stereo-distance-measurement=off burst-num=1 dynamic-frame-rate-supported=true vdr-r=0 video-size-values=176x144,480x320,640x480,864x480,1280x720,1920x1080,3840x2160 preview-size=640x480 focal-length=2.97692e+07 stereo-depth-af=off cap-mode-values=normal,face_beauty,continuousshot,smileshot,bestshot,autorama,mav,asd,motiontrack preview-frame-rate-values=20,15,24,30,60,120 max-num-metering-areas=9 fb-sharp-max=4 sr-awb-s=true sensor-type=252 focus-fs-fi=0 3dnr-mode=on focus-mode-values=auto,macro,infinity,continuous-picture,continuous-video,manual,fullscan vhdr-s=0 focus-fs-fi-min=0 fb-sharp-min=-4 jpeg-thumbnail-size-values=0x0,256x144,128x96,160x128 sen-mode-s=0 zoom-ratios=100,102,104,107,110,112,114,117,120,123,125,128,131,135,138,141,144,148,151,155,158,162,166,170,174,178,182,186, 190,195,200,204,209,214,219,224,229,235,240,246,251,257,263,270,276,282,289,296,303,310,317,324,332,340,348,356,364,373,381,390,400
flash-step-max=0 eng-shad-t=0 picture-size-values=320x240,640x480,1024x768,1280x720,1280x768,1280x960,1600x1200,1920x1088,2048x1536,2560x1440, 2560x1920,3264x2448,3328x1872,2880x1728,3600x2160,4096x2304,4096x3072,4160x3120
edge-values=low,middle,high hsvr-size-fps-values=640x480x120 horizontal-view-angle=63 fb-extreme-beauty-supported=false brightness=middle jpeg-thumbnail-height=128 fb-slim-face=0 mfb-values=off,mfll,ais smooth-zoom-supported=true capfname=/sdcard/DCIM/cap00 zsd-mode=on focus-mode=auto fb-skin-color-max=4 auto-whitebalance-lock-supported=true fb-skin-color-min=-4 video-frame-format=yuv420p max-num-detected-faces-sw=0 sv1-s=3 max-exposure-compensation=12 mfb=off max-num-ot=1 video-snaps |
沒有留言:
張貼留言