Advertisement
Guest User

Untitled

a guest
Jan 24th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.04 KB | None | 0 0
  1. ### TextureView
  2. You need to initialize `TextureView` before opening a camera.
  3. `TextureView` is for displaying the image from camera on the device.
  4. However, you cannot use it unless the texture is ready, either because the screen is turn off or it is initializing.
  5.  
  6. You should check mTextureView.isAvailable() before opening your camera. Else you will `mTextureView.setSurfaceTextureListner()`.
  7. And open your camera in the callback method `onSurfaceTextureListener`.
  8.  
  9. ### Camera
  10. Before opening your camera you should check for a camera permission first.
  11.  
  12. Next, you initialize a cameraManager through
  13. `CameraManager manager = (CameraManager) activity.getSystemService(Context.CAMERA_SERVICE);`
  14.  
  15. This manager is freakingly the most powerful.
  16. * It gives us metadata of your camera devices.
  17. * It can initialize camera.
  18.  
  19. #### Metadata
  20. ##### E.g., How many camera you have?
  21. `manager.getCameraIdList();`
  22. Usually, it will return 0 and 1. 0 means it is your back camera. 1 for your front camera.
  23. ##### What is the characteristics of your camera?
  24. `CameraCharacteristics characteristics = manager.getCameraCharacteristics(cameraId);`
  25.  
  26. Available characteristics including:
  27.  
  28. CameraCharacteristics.Key(android.colorCorrection.availableAberrationModes)
  29. CameraCharacteristics.Key(android.control.aeAvailableAntibandingModes)
  30. CameraCharacteristics.Key(android.control.aeAvailableModes)
  31. CameraCharacteristics.Key(android.control.aeAvailableTargetFpsRanges)
  32. CameraCharacteristics.Key(android.control.aeCompensationRange)
  33. CameraCharacteristics.Key(android.control.aeCompensationStep)
  34. CameraCharacteristics.Key(android.control.aeLockAvailable)
  35. CameraCharacteristics.Key(android.control.afAvailableModes)
  36. CameraCharacteristics.Key(android.control.availableEffects)
  37. CameraCharacteristics.Key(android.control.availableModes)
  38. CameraCharacteristics.Key(android.control.availableSceneModes)
  39. CameraCharacteristics.Key(android.control.availableVideoStabilizationModes)
  40. CameraCharacteristics.Key(android.control.awbAvailableModes)
  41. CameraCharacteristics.Key(android.control.awbLockAvailable)
  42. CameraCharacteristics.Key(android.control.maxRegionsAe)
  43. CameraCharacteristics.Key(android.control.maxRegionsAf)
  44. CameraCharacteristics.Key(android.control.maxRegionsAwb)
  45. CameraCharacteristics.Key(android.flash.info.available)
  46. CameraCharacteristics.Key(android.info.supportedHardwareLevel)
  47. CameraCharacteristics.Key(android.jpeg.availableThumbnailSizes)
  48. CameraCharacteristics.Key(android.lens.facing)
  49. CameraCharacteristics.Key(android.lens.info.availableFocalLengths)
  50. CameraCharacteristics.Key(android.noiseReduction.availableNoiseReductionModes)
  51. CameraCharacteristics.Key(android.request.availableCapabilities)
  52. CameraCharacteristics.Key(android.request.maxNumOutputProc)
  53. CameraCharacteristics.Key(android.request.maxNumOutputProcStalling)
  54. CameraCharacteristics.Key(android.request.maxNumOutputRaw)
  55. CameraCharacteristics.Key(android.request.partialResultCount)
  56. CameraCharacteristics.Key(android.request.pipelineMaxDepth)
  57. CameraCharacteristics.Key(android.scaler.availableMaxDigitalZoom)
  58. CameraCharacteristics.Key(android.scaler.croppingType)
  59. CameraCharacteristics.Key(android.scaler.streamConfigurationMap)
  60. CameraCharacteristics.Key(android.sensor.availableTestPatternModes)
  61. CameraCharacteristics.Key(android.sensor.info.activeArraySize)
  62. CameraCharacteristics.Key(android.sensor.info.physicalSize)
  63. CameraCharacteristics.Key(android.sensor.info.pixelArraySize)
  64. CameraCharacteristics.Key(android.sensor.info.timestampSource)
  65. CameraCharacteristics.Key(android.sensor.orientation)
  66. CameraCharacteristics.Key(android.statistics.info.availableFaceDetectModes)
  67. CameraCharacteristics.Key(android.statistics.info.maxFaceCount)
  68. CameraCharacteristics.Key(android.sync.maxLatency)
  69. > you can get this key list from `characteristics.getKeys();`
  70.  
  71. #### How good is your hardware can be obtained by
  72. `characteristics.get(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL)`
  73. You can check it by comparing with built-in integer. e.g.,
  74. `characteristics.get(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL) == CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_FULL`
  75. From my observation, Pixel Phone 2016 is `CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_3`.
  76. My OnePlus One is `CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY`.
  77.  
  78. Various hardware supports allow different capabilities.
  79. * __LEGACY__ devices operate in a backwards-compatibility mode for older Android devices, and have very limited capabilities.
  80. * __LIMITED__ devices represent the baseline feature set, and may also include additional capabilities that are subsets of FULL.
  81. * __FULL__ devices additionally support per-frame manual control of sensor, flash, lens and post-processing settings, and image capture at a high rate.
  82. * __LEVEL_3__ devices additionally support YUV reprocessing and RAW image capture, along with additional output stream configurations.
  83.  
  84.  
  85. #### Image size
  86. `StreamConfigurationMap map = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);`
  87. StreamConfiguration(
  88. Outputs(
  89. [w: 4160, h: 3120, format: JPEG(256), min_duration: 0, stall: 1121523200],
  90. [w: 4160, h: 2340, format: JPEG(256), min_duration: 0, stall: 891142400],
  91. [w: 4000, h: 3000, format: JPEG(256), min_duration: 0, stall: 1052000000],
  92. [w: 4096, h: 2160, format: JPEG(256), min_duration: 0, stall: 828162560],
  93. [w: 3200, h: 2400, format: JPEG(256), min_duration: 0, stall: 745280000],
  94. [w: 3200, h: 1800, format: JPEG(256), min_duration: 0, stall: 608960000],
  95. [w: 2592, h: 1944, format: JPEG(256), min_duration: 0, stall: 557758208],
  96. [w: 2048, h: 1536, format: JPEG(256), min_duration: 0, stall: 423346688],
  97. [w: 1920, h: 1080, format: JPEG(256), min_duration: 0, stall: 347225600],
  98. [w: 1600, h: 1200, format: JPEG(256), min_duration: 0, stall: 336320000],
  99. [w: 1280, h: 768, format: JPEG(256), min_duration: 0, stall: 269795840],
  100. [w: 1280, h: 720, format: JPEG(256), min_duration: 0, stall: 265433600],
  101. [w: 1024, h: 768, format: JPEG(256), min_duration: 0, stall: 255836672],
  102. [w: 800, h: 600, format: JPEG(256), min_duration: 0, stall: 234080000],
  103. [w: 800, h: 480, format: JPEG(256), min_duration: 0, stall: 227264000],
  104. [w: 720, h: 480, format: JPEG(256), min_duration: 0, stall: 224537600],
  105. [w: 640, h: 480, format: JPEG(256), min_duration: 0, stall: 221811200],
  106. [w: 320, h: 240, format: JPEG(256), min_duration: 0, stall: 205452800],
  107. [w: 1440, h: 1080, format: PRIVATE(34), min_duration: 0, stall: 0],
  108. [w: 1280, h: 720, format: PRIVATE(34), min_duration: 0, stall: 0],
  109. [w: 720, h: 480, format: PRIVATE(34), min_duration: 0, stall: 0],
  110. [w: 640, h: 480, format: PRIVATE(34), min_duration: 0, stall: 0],
  111. [w: 320, h: 240, format: PRIVATE(34), min_duration: 0, stall: 0],
  112. [w: 1440, h: 1080, format: YUV_420_888(35), min_duration: 0, stall: 0],
  113. [w: 1280, h: 720, format: YUV_420_888(35), min_duration: 0, stall: 0],
  114. [w: 720, h: 480, format: YUV_420_888(35), min_duration: 0, stall: 0],
  115. [w: 640, h: 480, format: YUV_420_888(35), min_duration: 0, stall: 0],
  116. [w: 320, h: 240, format: YUV_420_888(35), min_duration: 0, stall: 0],
  117. [w: 1440, h: 1080, format: YV12(842094169), min_duration: 0, stall: 0],
  118. [w: 1280, h: 720, format: YV12(842094169), min_duration: 0, stall: 0],
  119. [w: 720, h: 480, format: YV12(842094169), min_duration: 0, stall: 0],
  120. [w: 640, h: 480, format: YV12(842094169), min_duration: 0, stall: 0],
  121. [w: 320, h: 240, format: YV12(842094169), min_duration: 0, stall: 0]),
  122. HighResolutionOutputs(),
  123. Inputs(),
  124. ValidOutputFormatsForInput(),
  125. HighSpeedVideoConfigurations()
  126. )
  127.  
  128.  
  129. #### other various things
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement