feat(ios): rectOfInterest (#1852)
This commit is contained in:
parent
b90c58b794
commit
b47b80d5a4
@ -293,6 +293,10 @@ By default a `Camera not authorized` message will be displayed when access to th
|
||||
|
||||
By default a <ActivityIndicator> will be displayed while the component is waiting for the user to grant/deny access to the camera, if set displays the passed react element instead of the default one.
|
||||
|
||||
#### `iOS` `rectOfInterest`
|
||||
|
||||
An `{x: , y:, width:, height: }` object which defines the rect of interst as normalized coordinates from `(0,0)` top left corner to `(1,1)` bottom right corner.
|
||||
|
||||
### `iOS` `videoStabilizationMode`
|
||||
|
||||
The video stabilization mode used for a video recording. The possible values are:
|
||||
|
||||
@ -40,6 +40,7 @@
|
||||
@property(nonatomic, assign) BOOL canReadText;
|
||||
@property(nonatomic, assign) BOOL canDetectFaces;
|
||||
@property(nonatomic, assign) BOOL canDetectBarcodes;
|
||||
@property(nonatomic, assign) CGRect rectOfInterest;
|
||||
@property(assign, nonatomic) AVVideoCodecType videoCodecType;
|
||||
@property(assign, nonatomic)
|
||||
AVCaptureVideoStabilizationMode videoStabilizationMode;
|
||||
@ -61,6 +62,7 @@
|
||||
- (void)updateFaceDetectionMode:(id)requestedMode;
|
||||
- (void)updateFaceDetectionLandmarks:(id)requestedLandmarks;
|
||||
- (void)updateFaceDetectionClassifications:(id)requestedClassifications;
|
||||
- (void)updateRectOfInterest;
|
||||
// google Barcode props
|
||||
- (void)updateGoogleVisionBarcodeType:(id)requestedTypes;
|
||||
|
||||
|
||||
@ -62,6 +62,7 @@ static NSDictionary *defaultFaceDetectorOptions = nil;
|
||||
self.previewLayer.needsDisplayOnBoundsChange = YES;
|
||||
#endif
|
||||
self.paused = NO;
|
||||
self.rectOfInterest = CGRectMake(0, 0, 1.0, 1.0);
|
||||
[self changePreviewOrientation:[UIApplication sharedApplication].statusBarOrientation];
|
||||
[self initializeCaptureSessionInput];
|
||||
[self startSession];
|
||||
@ -857,6 +858,14 @@ static NSDictionary *defaultFaceDetectorOptions = nil;
|
||||
[self _updateMetadataObjectsToRecognize];
|
||||
}
|
||||
|
||||
- (void)updateRectOfInterest
|
||||
{
|
||||
if (_metadataOutput == nil) {
|
||||
return;
|
||||
}
|
||||
[_metadataOutput setRectOfInterest: _rectOfInterest];
|
||||
}
|
||||
|
||||
- (void)_setupOrDisableMetadataOutput
|
||||
{
|
||||
if ([self isReadingBarCodes] && (_metadataOutput == nil || ![self.session.outputs containsObject:_metadataOutput])) {
|
||||
@ -889,6 +898,7 @@ static NSDictionary *defaultFaceDetectorOptions = nil;
|
||||
}
|
||||
|
||||
[_metadataOutput setMetadataObjectTypes:availableRequestedObjectTypes];
|
||||
[self updateRectOfInterest];
|
||||
}
|
||||
|
||||
- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputMetadataObjects:(NSArray *)metadataObjects
|
||||
|
||||
@ -269,6 +269,12 @@ RCT_CUSTOM_VIEW_PROPERTY(textRecognizerEnabled, BOOL, RNCamera)
|
||||
[view setupOrDisableTextDetector];
|
||||
}
|
||||
|
||||
RCT_CUSTOM_VIEW_PROPERTY(rectOfInterest, CGRect, RNCamera)
|
||||
{
|
||||
[view setRectOfInterest: [RCTConvert CGRect:json]];
|
||||
[view updateRectOfInterest];
|
||||
}
|
||||
|
||||
RCT_CUSTOM_VIEW_PROPERTY(defaultVideoQuality, NSInteger, RNCamera)
|
||||
{
|
||||
[view setDefaultVideoQuality: [NSNumber numberWithInteger:[RCTConvert NSInteger:json]]];
|
||||
|
||||
@ -231,6 +231,13 @@ type EventCallbackArgumentsType = {
|
||||
nativeEvent: Object,
|
||||
};
|
||||
|
||||
type Rect = {
|
||||
x: number,
|
||||
y: number,
|
||||
width: number,
|
||||
height: number,
|
||||
};
|
||||
|
||||
type PropsType = typeof View.props & {
|
||||
zoom?: number,
|
||||
ratio?: string,
|
||||
@ -260,6 +267,7 @@ type PropsType = typeof View.props & {
|
||||
playSoundOnCapture?: boolean,
|
||||
videoStabilizationMode?: number | string,
|
||||
pictureSize?: string,
|
||||
rectOfInterest: Rect,
|
||||
};
|
||||
|
||||
type StateType = {
|
||||
@ -401,6 +409,7 @@ export default class Camera extends React.Component<PropsType, StateType> {
|
||||
videoStabilizationMode: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
||||
pictureSize: PropTypes.string,
|
||||
mirrorVideo: PropTypes.bool,
|
||||
rectOfInterest: PropTypes.any,
|
||||
defaultVideoQuality: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user