@capgo/camera-preview 7.21.3 → 7.21.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -932,6 +932,8 @@ public class CameraXView implements LifecycleOwner, LifecycleObserver {
932
932
  );
933
933
  }
934
934
 
935
+ resetExposureCompensationToDefault();
936
+
935
937
  // Log details about the active camera
936
938
  Log.d(TAG, "Use cases bound. Inspecting active camera and use cases.");
937
939
  CameraInfo cameraInfo = camera.getCameraInfo();
@@ -2591,6 +2593,29 @@ public class CameraXView implements LifecycleOwner, LifecycleObserver {
2591
2593
  camera.getCameraControl().setExposureCompensationIndex(idx);
2592
2594
  }
2593
2595
 
2596
+ private void resetExposureCompensationToDefault() {
2597
+ if (camera == null) {
2598
+ return;
2599
+ }
2600
+ try {
2601
+ ExposureState state = camera.getCameraInfo().getExposureState();
2602
+ Range<Integer> range = state.getExposureCompensationRange();
2603
+ int neutralIdx = 0;
2604
+ if (!range.contains(0)) {
2605
+ int lower = range.getLower();
2606
+ int upper = range.getUpper();
2607
+ neutralIdx = Math.abs(lower) <= Math.abs(upper) ? lower : upper;
2608
+ }
2609
+ camera.getCameraControl().setExposureCompensationIndex(neutralIdx);
2610
+ } catch (Exception e) {
2611
+ Log.w(
2612
+ TAG,
2613
+ "resetExposureCompensationToDefault: Failed to reset exposure compensation",
2614
+ e
2615
+ );
2616
+ }
2617
+ }
2618
+
2594
2619
  private long showFocusIndicator(float x, float y) {
2595
2620
  // If preview is gone (e.g., stopping/closing), bail out safely
2596
2621
  if (previewContainer == null) {
@@ -621,6 +621,11 @@ extension CameraController {
621
621
  finalDevice.exposurePointOfInterest = CGPoint(x: 0.5, y: 0.5)
622
622
  }
623
623
  }
624
+ // Reset exposure compensation so sessions start neutral
625
+ let minBias = finalDevice.minExposureTargetBias
626
+ let maxBias = finalDevice.maxExposureTargetBias
627
+ let neutralBias = max(minBias, min(0.0, maxBias))
628
+ finalDevice.setExposureTargetBias(neutralBias) { _ in }
624
629
  finalDevice.unlockForConfiguration()
625
630
  } catch {
626
631
  // Non-fatal; continue without setting default exposure
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/camera-preview",
3
- "version": "7.21.3",
3
+ "version": "7.21.5",
4
4
  "description": "Camera preview",
5
5
  "license": "MIT",
6
6
  "repository": {