Skip to content
This repository has been archived by the owner on Jun 16, 2023. It is now read-only.

Commit

Permalink
chore(face-detector): make face detection stoppage smoother
Browse files Browse the repository at this point in the history
  • Loading branch information
jgfidelis committed Feb 19, 2018
1 parent 19b958d commit 3b3c38d
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions ios/FaceDetector/RNFaceDetectorManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,13 @@ - (void)setIsEnabled:(id)json
_faceDetecting = newFaceDetecting;
[self _runBlockIfQueueIsPresent:^{
if ([self isDetectingFaces]) {
[self tryEnablingFaceDetection];
if (_dataOutput) {
[self _setConnectionsEnabled:true];
} else {
[self tryEnablingFaceDetection];
}
} else {
[self stopFaceDetection];
[self _setConnectionsEnabled:false];
}
}];
}
Expand Down Expand Up @@ -155,6 +159,16 @@ - (void)stopFaceDetection

# pragma mark Private API

- (void)_setConnectionsEnabled:(BOOL)enabled
{
if (!_dataOutput) {
return;
}
for (AVCaptureConnection *connection in _dataOutput.connections) {
connection.enabled = enabled;
}
}

- (void)_resetFaceDetector
{
[self stopFaceDetection];
Expand Down

0 comments on commit 3b3c38d

Please sign in to comment.