Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/camera/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.4.2

* Add sensor orientation value to `CameraDescription`.

## 0.4.1

* Camera methods are ran in a background thread on iOS.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ public void onMethodCall(MethodCall call, final Result result) {
cameraManager.getCameraCharacteristics(cameraName);
details.put("name", cameraName);
@SuppressWarnings("ConstantConditions")
int sensorOrientation = characteristics.get(CameraCharacteristics.SENSOR_ORIENTATION);
details.put("sensorOrientation", sensorOrientation);

int lensFacing = characteristics.get(CameraCharacteristics.LENS_FACING);
switch (lensFacing) {
case CameraMetadata.LENS_FACING_FRONT:
Expand Down
1 change: 1 addition & 0 deletions packages/camera/ios/Classes/CameraPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,7 @@ - (void)handleMethodCallAsync:(FlutterMethodCall *)call result:(FlutterResult)re
[reply addObject:@{
@"name" : [device uniqueID],
@"lensFacing" : lensFacing,
@"sensorOrientation" : @90,
}];
}
result(reply);
Expand Down
14 changes: 12 additions & 2 deletions packages/camera/lib/camera.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Future<List<CameraDescription>> availableCameras() async {
return CameraDescription(
name: camera['name'],
lensDirection: _parseCameraLensDirection(camera['lensFacing']),
sensorOrientation: camera['sensorOrientation'],
);
}).toList();
} on PlatformException catch (e) {
Expand All @@ -66,11 +67,20 @@ Future<List<CameraDescription>> availableCameras() async {
}

class CameraDescription {
CameraDescription({this.name, this.lensDirection});
CameraDescription({this.name, this.lensDirection, this.sensorOrientation});

final String name;
final CameraLensDirection lensDirection;

/// Clockwise angle through which the output image needs to be rotated to be upright on the device screen in its native orientation.
///
/// **Range of valid values:**
/// 0, 90, 180, 270
///
/// On Android, also defines the direction of rolling shutter readout, which
/// is from top to bottom in the sensor's coordinate system.
final int sensorOrientation;

@override
bool operator ==(Object o) {
return o is CameraDescription &&
Expand All @@ -85,7 +95,7 @@ class CameraDescription {

@override
String toString() {
return '$runtimeType($name, $lensDirection)';
return '$runtimeType($name, $lensDirection, $sensorOrientation)';
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/camera/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: camera
description: A Flutter plugin for getting information about and controlling the
camera on Android and iOS. Supports previewing the camera feed, capturing images, capturing video,
and streaming image buffers to dart.
version: 0.4.1
version: 0.4.2
authors:
- Flutter Team <[email protected]>
- Luigi Agosti <[email protected]>
Expand Down