CameraCharacteristics

Obtain the characteristics of the corresponding camera equipment according to cameraId. Returns a CameraCharacteristics class, similar to the Camera.Parameter class in the old API, which encapsulates all the attributes inherent to the Camera device. Describes the properties of CameraDevice. These properties are fixed for a given CameraDevice and can be queried via the CameraManager#getCameraCharacteristics interface. Does not contain certain metadata values when obtained by a client that does not have CAMERA permissions. The list of keys requiring permissions is given by getKeysNeedingPermission(). The CameraCharacteristics object is immutable. \

get

public T get (Key<T> key)
Copy the code

Gets the camera property field value. The field definition can be found in Camera Aracteristics. Querying the value of the same key multiple times returns a value equal to the value of the previous query.

getAvailableCaptureRequestKeys

publicList<Key<? >> getAvailableCaptureRequestKeys ()Copy the code

Returns a list of keys supported by this CameraDevice for query using CaptureRequest. Returns a list of the immutable, so any attempt to modify it will throw an UnsupportedOperationException. Each key is listed only once in the list. The order of the keys is undefined. Please note that no getAvailableCameraCharacteristicsKeys (), use the getKeys ().

getAvailableCaptureResultKeys

publicList<Key<? >> getAvailableCaptureResultKeys ()Copy the code

Returns a list of keys supported by this CameraDevice for query using CaptureResult. Returns a list of the immutable, so any attempt to modify it will throw an UnsupportedOperationException. Each key is listed only once in the list. The order of the keys is undefined. Please note that no getAvailableCameraCharacteristicsKeys () – use getKeys (). \

getAvailablePhysicalCameraRequestKeys

publicList<Key<? >> getAvailablePhysicalCameraRequestKeys ()Copy the code

Return getAvailableCaptureRequestKeys () key subset of these keys can be covered for support logic camera more physical devices. This is android. Request. AvailableRequestKeys subset, which contains can use CaptureRequest. Builder# setPhysicalCameraKey covers the keys of the list. The corresponding value of such a request key can be obtained by calling CaptureRequest.Builder#getPhysicalCameraKey. Contains a single physical device requests the capture of the request must be through the CameraDevice. CreateCaptureRequest (int, Set) generated. Returns a list of the immutable, so any attempt to modify it will throw an UnsupportedOperationException. Each key is listed only once in the list. The order of the keys is undefined. \

Gets the available session key

publicList<Key<? >> getAvailableSessionKeys ()Copy the code

Returns the camera equipment can be passed as part of the capture session initialization of getAvailableCaptureRequestKeys () key subset. This list contains keys that are difficult to apply by frame and can cause unexpected delays when capturing changes during the lifetime of the session. Typical examples include parameters that require time-consuming hardware reconfiguration or internal camera piping changes. For performance reasons, we recommend that the client pass its initial value as part of SessionConfiguration#setSessionParameters. It is also recommended to avoid changing the initial value set in SessionConfiguration#setSessionParameters when camera capture sessions are enabled. Control over session parameters can still be used in capturing requests, but the client should be aware and expect delays during application. Example usage scenarios might look like the following:

  • The camera client passes firstgetAvailableSessionKeys()Example Query the session parameter key list.
  • Must pass before triggering the capture session creation sequenceCameraDevice#createCaptureRequestBuild the capture request using the appropriate template that matches the specific use case.
  • The client should check the session parameter list and check that some of the listed keys match the parameters they intend to modify as part of the first capture request.
  • If there is no such match, the capture request can be passed unmodified toSessionConfiguration#setSessionParameters.
  • If a match does exist, the client should update the corresponding value and pass the request toSessionConfiguration#setSessionParameters.
  • After the capture session initialization is complete, the session parameter key list can continue to be used as a reference when publishing or updating further requests. As mentioned above, further changes to session parameters should ideally be avoided if updates are needed, but the client may experience delays/failures during parameter switching.

Returns a list of the immutable, so any attempt to modify it will throw an UnsupportedOperationException. Each key is listed only once in the list. The order of the keys is undefined. \

To get the key

publicList<Key<? >> getKeys ()Copy the code

Returns a list of keys contained in this map. Returns a list of the immutable, so any attempt to modify it will throw an UnsupportedOperationException. All values #get retrieved from the key in this list are guaranteed to be non-NULL. Each key is listed only once in the list. The order of the keys is undefined

getKeysNeedingPermission

publicList<Key<? >> getKeysNeedingPermission ()Copy the code

Return getKeys () returns a list of subset, to get the Manifest contains requirements camera client. Permission. Camera access all of the key. If the application does not hold the Manifest. Permission. The powers of the CAMERA case, call CameraManager# getCameraCharacteristics, this list of all keys will be unavailable, And call get (CameraCharacteristics. Key) will be for the Key returns null. If the application is received the Manifest. Permission. CAMERA permission, then from the call to the subsequent CameraManager CameraCharacteristics# getCameraCharacteristics will have available key. Returns a list of the immutable, so any attempt to modify it will throw an UnsupportedOperationException. Each key is listed only once in the list. The order of the keys is undefined.

getPhysicalCameraIds

public Set<String> getPhysicalCameraIds (a)
Copy the code

Returns the set of physical camera ids that comprise this logical camera device. If the camera device has REQUEST_AVAILABLE_CAPABILITIES_LOGICAL_MULTI_CAMERA, it is a logical camera. If the camera device is not capable, the return value will be an empty set. Before the API level 29, all returns the ID of the guarantee by the CameraManager. GetCameraIdList () returns, and can be by CameraManager# openCamera open directly. Starting at API level 29, for each returned ID, CameraManager#openCamera can be used as a separate camera if it is also returned by CameraManager#getCameraIdList. Otherwise, the camera ID can only be used as part of the current logical camera. Returns a collection of immutable, so any attempt to modify it will throw an UnsupportedOperationException.

Gets the recommended flow configuration mapping

public RecommendedStreamConfigurationMap getRecommendedStreamConfigurationMap (int usecase)
Copy the code

RecommendedStreamConfigurationMap for a given use case retrieval camera equipment recommended flow configuration mapping. For common use cases such as preview, video, snapshot, etc., the flow configuration advertised here is efficient in terms of power and performance. The recommended mappings are usually only a small part of the exhaustive list provided in the SCALER_STREAM_CONFIGURATION_MAP, and are suggested for specific use cases by the camera device implementation. \

For example, how a camera client might use it to find the recommended maximum preview and snapshot resolution, consider the following pseudocode:

 public static Size getMaxSize(Size... sizes) {
     if (sizes == null || sizes.length == 0) {
         throw new IllegalArgumentException("sizes was empty");
     }

     Size sz = sizes[0];
     for (Size size : sizes) {
         if(size.getWidth() * size.getHeight() > sz.getWidth() * sz.getHeight()) { sz = size; }}return sz;
 }

 CameraCharacteristics characteristics =
         cameraManager.getCameraCharacteristics(cameraId);
 RecommendedStreamConfigurationMap previewConfig =
         characteristics.getRecommendedStreamConfigurationMap(
                  RecommendedStreamConfigurationMap.USECASE_PREVIEW);
 RecommendedStreamConfigurationMap snapshotConfig =
         characteristics.getRecommendedStreamConfigurationMap(
                  RecommendedStreamConfigurationMap.USECASE_SNAPSHOT);

 if((previewConfig ! =null) && (snapshotConfig ! =null)) {

      Set snapshotSizeSet = snapshotConfig.getOutputSizes(
              ImageFormat.JPEG);
      Size[] snapshotSizes = new Size[snapshotSizeSet.size()];
      snapshotSizes = snapshotSizeSet.toArray(snapshotSizes);
      Size suggestedMaxJpegSize = getMaxSize(snapshotSizes);

      Set previewSizeSet = snapshotConfig.getOutputSizes(
              ImageFormat.PRIVATE);
      Size[] previewSizes = new Size[previewSizeSet.size()];
      previewSizes = previewSizeSet.toArray(previewSizes);
      Size suggestedMaxPreviewSize = getMaxSize(previewSizes);
 }
Copy the code

Similar logic can be applied to other use cases. Support for recommended flow configurations is optional. If there is no recommended configuration for a specific use case, see SCALER_STREAM_CONFIGURATION_MAP for an exhaustive list of available configurations. \