Skip to content
Open
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
27 changes: 14 additions & 13 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,19 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
child: Padding(
padding: const EdgeInsets.all(1.0),
child: Center(
child: ZoomableWidget(
child: _cameraPreviewWidget(),
onTapUp: (scaledPoint) {
//controller.setPointOfInterest(scaledPoint);
},
onZoom: (zoom) {
print('zoom');
if (zoom < 11) {
controller.zoom(zoom);
}
})),
child: ZoomableWidget(
child: _cameraPreviewWidget(),
onTapUp: (scaledPoint) {
controller.setPointOfInterest(scaledPoint);
},
onZoom: (zoom) {
print('zoom');
if (zoom < 11) {
controller.zoom(zoom);
}
},
),
),
),
decoration: BoxDecoration(
color: Colors.black,
Expand Down Expand Up @@ -623,8 +625,7 @@ class _ZoomableWidgetState extends State<ZoomableWidget> {
final Offset localPoint = box.globalToLocal(det.globalPosition);
final Offset scaledPoint =
localPoint.scale(1 / box.size.width, 1 / box.size.height);
// TODO IMPLIMENT
// widget.onTapUp(scaledPoint);
widget.onTapUp(scaledPoint);
},
child: Stack(children: [
Column(
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: camera_example
description: Demonstrates how to use the camera plugin.

dependencies:
camera:
flutter_better_camera:
path: ../
path_provider: ^0.5.0
flutter:
Expand Down
19 changes: 19 additions & 0 deletions ios/Classes/CameraPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,20 @@ - (void)setAutoFocus:(BOOL)enable
[_captureDevice unlockForConfiguration];
}

-(void) setPointOfInterest:(CGPoint)point {
if ([_captureDevice isFocusPointOfInterestSupported]) {

NSError *error;

if ([_captureDevice lockForConfiguration:&error]) {
[_captureDevice setFocusPointOfInterest:point];
[_captureDevice setFocusMode:AVCaptureFocusModeAutoFocus];
[_captureDevice unlockForConfiguration];
} else {
NSLog(@"Error in Focus Mode");
}
}

- (void)zoom:(double)zoom {

NSError *error = nil;
Expand Down Expand Up @@ -997,6 +1011,11 @@ - (void)handleMethodCallAsync:(FlutterMethodCall *)call result:(FlutterResult)re
result(nil);
} else if ([@"autoExposureOff" isEqualToString:call.method]) {
[_camera setAutoExposureMode:false];
} else if([@"setPointOfInterest" isEqualToString:call.method]) {
NSNumber *dx = call.arguments[@"offsetX"];
NSNumber *dy = call.arguments[@"offsetY"];
CGPoint point = CGPointMake(dx.floatValue, dy.floatValue);
[_camera setPointOfInterest:point];
} else if ([@"zoom" isEqualToString:call.method]){
NSNumber *step = call.arguments[@"step"];
[_camera zoom:[step doubleValue]];
Expand Down