diff --git a/ios/RN/OpenCVProcessor.hpp b/ios/RN/OpenCVProcessor.hpp index c351256..3e31e29 100644 --- a/ios/RN/OpenCVProcessor.hpp +++ b/ios/RN/OpenCVProcessor.hpp @@ -7,6 +7,9 @@ using namespace cv; #import +@protocol OpenCVProcessorFaceDetectorDelegate +- (void)onFacesDetected:(NSArray *)faces; +@end @class OpenCVProcessor; @@ -16,9 +19,11 @@ using namespace cv; std::vector objects; cv::CascadeClassifier cascade; #endif + id delegate; } - (id) init; + +- (id) initWithDelegate:(id )delegateObj; @end - diff --git a/ios/RN/OpenCVProcessor.mm b/ios/RN/OpenCVProcessor.mm index 2279669..663cdc2 100644 --- a/ios/RN/OpenCVProcessor.mm +++ b/ios/RN/OpenCVProcessor.mm @@ -18,14 +18,16 @@ return self; } +- (id) initWithDelegate:(id)delegateObj { + delegate = delegateObj; + return self; +} + # pragma mark - OpenCV-Processing #ifdef __cplusplus - (void)processImage:(Mat&)image; { - // Scalar average = mean(image); - NSLog(@"---- Processing Frame"); - cv::Mat grayMat; cv::cvtColor(image, grayMat, CV_BGR2GRAY); @@ -38,23 +40,8 @@ cv::Size(40, 40)); for(size_t i = 0; i < objects.size(); ++i) { - // cv::Point center; - // int radius; - // const cv::Rect& r = objects[i]; - // center.x = cv::saturate_cast((r.x + r.width*0.5)); - // center.y = cv::saturate_cast((r.y + r.height*0.5)); - // radius = cv::saturate_cast((r.width + r.height)*0.25); - // cv::circle(image, center, radius, cv::Scalar(80,80,255), 3, 8, 0 ); - // [self onFacesDetected: [NSDictionary new]]; + [delegate onFacesDetected:[NSArray new]]; } - - // // Do some OpenCV stuff with the image - // Mat image_copy; - // cvtColor(image, image_copy, CV_BGRA2BGR); - // - // // invert image - // bitwise_not(image_copy, image_copy); - // cvtColor(image_copy, image, CV_BGR2BGRA); } @@ -210,5 +197,3 @@ #endif @end - - diff --git a/ios/RN/RNCamera.h b/ios/RN/RNCamera.h index 6ea5ab5..9a540bc 100644 --- a/ios/RN/RNCamera.h +++ b/ios/RN/RNCamera.h @@ -1,3 +1,4 @@ +#import "OpenCVProcessor.hpp" #import #import #import @@ -12,7 +13,7 @@ @class RNCamera; -@interface RNCamera : UIView +@interface RNCamera : UIView @property(nonatomic, strong) dispatch_queue_t sessionQueue; @property(nonatomic, strong) AVCaptureSession *session; diff --git a/ios/RN/RNCamera.m b/ios/RN/RNCamera.m index 284adf7..55db0e0 100644 --- a/ios/RN/RNCamera.m +++ b/ios/RN/RNCamera.m @@ -1,4 +1,3 @@ -#import "OpenCVProcessor.hpp" #import "RNCamera.h" #import "RNCameraUtils.h" #import "RNImageUtils.h"