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

Commit

Permalink
revert: check if face or text detector libraries are included indepen…
Browse files Browse the repository at this point in the history
…dently (#1882)
  • Loading branch information
reime005 authored and sibelius committed Oct 24, 2018
1 parent 9261524 commit 9efd755
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions ios/RN/RNCamera.m
Original file line number Diff line number Diff line change
Expand Up @@ -343,28 +343,28 @@ - (void)updatePictureSize

- (void)updateFaceDetecting:(id)faceDetecting
{
#if __has_include("RNFaceDetectorManager.h")
#if __has_include(<GoogleMobileVision/GoogleMobileVision.h>)
[_faceDetectorManager setIsEnabled:faceDetecting];
#endif
}

- (void)updateFaceDetectionMode:(id)requestedMode
{
#if __has_include("RNFaceDetectorManager.h")
#if __has_include(<GoogleMobileVision/GoogleMobileVision.h>)
[_faceDetectorManager setMode:requestedMode];
#endif
}

- (void)updateFaceDetectionLandmarks:(id)requestedLandmarks
{
#if __has_include("RNFaceDetectorManager.h")
#if __has_include(<GoogleMobileVision/GoogleMobileVision.h>)
[_faceDetectorManager setLandmarksDetected:requestedLandmarks];
#endif
}

- (void)updateFaceDetectionClassifications:(id)requestedClassifications
{
#if __has_include("RNFaceDetectorManager.h")
#if __has_include(<GoogleMobileVision/GoogleMobileVision.h>)
[_faceDetectorManager setClassificationsDetected:requestedClassifications];
#endif
}
Expand Down Expand Up @@ -491,10 +491,8 @@ - (void)record:(NSDictionary *)options resolve:(RCTPromiseResolveBlock)resolve r
// At the time of writing AVCaptureMovieFileOutput and AVCaptureVideoDataOutput (> GMVDataOutput)
// cannot coexist on the same AVSession (see: https://stackoverflow.com/a/4986032/1123156).
// We stop face detection here and restart it in when AVCaptureMovieFileOutput finishes recording.
#if __has_include("RNFaceDetectorManager.h")
#if __has_include(<GoogleMobileVision/GoogleMobileVision.h>)
[_faceDetectorManager stopFaceDetection];
#endif
#if __has_include("TextDetectorManager.h")
[self stopTextRecognition];
#endif
[self setupMovieFileCapture];
Expand Down Expand Up @@ -605,10 +603,11 @@ - (void)startSession
self.stillImageOutput = stillImageOutput;
}

#if __has_include("RNFaceDetectorManager.h")
#if __has_include(<GoogleMobileVision/GoogleMobileVision.h>)
[_faceDetectorManager maybeStartFaceDetectionOnSession:_session withPreviewLayer:_previewLayer];
#elif __has_include("TextDetectorManager.h")
[self setupOrDisableTextDetector];
if ([self.textDetector isRealDetector]) {
[self setupOrDisableTextDetector];
}
#else
// If AVCaptureVideoDataOutput is not required because of Google Vision
// (see comment in -record), we go ahead and add the AVCaptureMovieFileOutput
Expand Down Expand Up @@ -641,7 +640,7 @@ - (void)stopSession
return;
#endif
dispatch_async(self.sessionQueue, ^{
#if __has_include("RNFaceDetectorManager.h")
#if __has_include(<GoogleMobileVision/GoogleMobileVision.h>)
[_faceDetectorManager stopFaceDetection];
#endif
if ([self.textDetector isRealDetector]) {
Expand Down Expand Up @@ -937,7 +936,7 @@ - (void)cleanupCamera {
self.videoRecordedReject = nil;
self.videoCodecType = nil;

#if __has_include("RNFaceDetectorManager.h")
#if __has_include(<GoogleMobileVision/GoogleMobileVision.h>)
[self cleanupMovieFileCapture];

// If face detection has been running prior to recording to file
Expand Down Expand Up @@ -1006,7 +1005,7 @@ - (id)createFaceDetectorManager
Class faceDetectorManagerClass = NSClassFromString(@"RNFaceDetectorManager");
Class faceDetectorManagerStubClass = NSClassFromString(@"RNFaceDetectorManagerStub");

#if __has_include("RNFaceDetectorManager.h")
#if __has_include(<GoogleMobileVision/GoogleMobileVision.h>)
if (faceDetectorManagerClass) {
return [[faceDetectorManagerClass alloc] initWithSessionQueue:_sessionQueue delegate:self];
} else if (faceDetectorManagerStubClass) {
Expand Down Expand Up @@ -1035,7 +1034,7 @@ -(id)createTextDetector
Class textDetectorManagerStubClass =
NSClassFromString(@"TextDetectorManagerStub");

#if __has_include("TextDetectorManager.h")
#if __has_include(<GoogleMobileVision/GoogleMobileVision.h>)
if (textDetectorManagerClass) {
return [[textDetectorManagerClass alloc] init];
} else if (textDetectorManagerStubClass) {
Expand Down

0 comments on commit 9efd755

Please sign in to comment.