Skip to content

Commit 4c2d5eb

Browse files
committed
Fixed event name conflicting with react-native-camera
1 parent 1324a5d commit 4c2d5eb

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -266,11 +266,11 @@ In conjunction with the `onDetectFaces` property the properties `faceClassifier`
266266

267267
Only the classifiers in the CvFaceDetection sample app have currently been tested.
268268

269-
The `landmarksModel` property should be used for the 68 face landmarks in conjunction with a face classifier. Currently it can only be set to `lbfmodel` because there is only one landmarks data file supported `lbfmodel.yaml`. As for face boxes, face landmarks should also be used in conjunction with the same `onFacesDetected` callback. As for face detection For the json format of the landmarks data returned to the callback method see below.
269+
The `landmarksModel` property should be used for the 68 face landmarks in conjunction with a face classifier. Currently it can only be set to `lbfmodel` because there is only one landmarks data file supported `lbfmodel.yaml`. As for face boxes, face landmarks should also be used in conjunction with the same `onFacesDetectedCv` callback. As for face detection For the json format of the landmarks data returned to the callback method see below.
270270

271271
Face Detection Example:
272272
```javascript
273-
onFacesDetected = (e) => {
273+
onFacesDetectedCv = (e) => {
274274
//alert('payload: ' + JSON.stringify(e.payload))
275275
if (Platform.OS === 'ios') {
276276
if ((!e.nativeEvent.payload && this.state.faces) || (e.nativeEvent.payload && !this.state.faces) || (e.nativeEvent.payload && this.state.faces)) {
@@ -292,13 +292,13 @@ Face Detection Example:
292292
eyesClassifier='haarcascade_eye_tree_eyeglasses'
293293
noseClassifier='nose'
294294
mouthClassifier='mouth'
295-
onFacesDetected={this.onFacesDetected}
295+
onFacesDetectedCv={this.onFacesDetectedCv}
296296
/>
297297
```
298298

299299
Face Landmarks Example:
300300
```javascript
301-
onFacesDetected = (e) => {
301+
onFacesDetectedCv = (e) => {
302302
//alert('payload: ' + JSON.stringify(e.payload))
303303
if (Platform.OS === 'ios') {
304304
if ((!e.nativeEvent.payload && this.state.faces) || (e.nativeEvent.payload && !this.state.faces) || (e.nativeEvent.payload && this.state.faces)) {
@@ -318,15 +318,15 @@ Face Landmarks Example:
318318
facing='back'
319319
faceClassifier='haarcascade_frontalface_alt2'
320320
landmarksModel='lbfmodel'
321-
onFacesDetected={this.onFacesDetected}
321+
onFacesDetectedCv={this.onFacesDetectedCv}
322322
/>
323323
```
324324

325325
Including facing='back' sets the camera view towards the user so you can test it using your own face. To specify the other direction set facing='front' or leave out the facing property.
326326

327327
#### Face detection data format
328328

329-
The data returned to the callback method `onFacesDetected` will have the json dictionary format:
329+
The data returned to the callback method `onFacesDetectedCv` will have the json dictionary format:
330330
```javascript
331331
{ "payload" : { "faces":
332332
[

android/src/main/java/com/adamfreeman/rnocv3/CvCameraView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
661661
//Log.d(TAG, "payload is: " + faceInfo);
662662
response.putString("payload", faceInfo);
663663
mContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
664-
.emit("onFacesDetected", response);
664+
.emit("onFacesDetectedCv", response);
665665
}
666666

667667
boolean sendCallbackData = false;

ios/CvCamera.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ typedef void (^RecordVidBlock)(NSNumber*,NSNumber*,NSString*);
4545

4646
//@property (nonatomic, retain) CvVideoCamera* videoCamera;
4747

48-
@property (nonatomic, copy) RCTBubblingEventBlock onFacesDetected;
48+
@property (nonatomic, copy) RCTBubblingEventBlock onFacesDetectedCv;
4949

5050
@property (nonatomic, copy) RCTBubblingEventBlock onFrameSize;
5151

ios/CvCamera.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,8 +391,8 @@ - (void)processImage:(cv::Mat&)image {
391391
payloadJSON = [payloadJSON stringByAppendingString:@"]}"];
392392
}
393393

394-
if (self && self.onFacesDetected) {
395-
self.onFacesDetected(@{@"payload":payloadJSON});
394+
if (self && self.onFacesDetectedCv) {
395+
self.onFacesDetectedCv(@{@"payload":payloadJSON});
396396
}
397397
}
398398
dispatch_async(dispatch_get_main_queue(), ^{

ios/CvCameraView.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ @implementation CvCameraView
2020

2121
RCT_EXPORT_MODULE(CvCameraView)
2222

23-
RCT_EXPORT_VIEW_PROPERTY(onFacesDetected, RCTBubblingEventBlock)
23+
RCT_EXPORT_VIEW_PROPERTY(onFacesDetectedCv, RCTBubblingEventBlock)
2424

2525
RCT_EXPORT_VIEW_PROPERTY(onFrameSize, RCTBubblingEventBlock)
2626

0 commit comments

Comments
 (0)