feat(Android): event will also be fired if no object was found

This commit is contained in:
Malte Peters 2018-03-21 19:00:35 +01:00
parent 5dfa6d2d43
commit 519fe42f07
2 changed files with 4 additions and 3 deletions

View File

@ -286,7 +286,7 @@ public class RNCameraView extends CameraView implements LifecycleEventListener,
}
public void onFacesDetected(SparseArray<Map<String, Float>> facesReported, int sourceWidth, int sourceHeight, int sourceRotation) {
if (facesReported.size() != 0) {
if (facesReported != null) {
RNCameraViewHelper.emitFacesDetectedEvent(this, facesReported, new ImageDimensions(sourceWidth, sourceHeight, sourceRotation, getFacing()));
}
}

View File

@ -141,8 +141,8 @@ public class OpenCVProcessor {
}
public SparseArray<Map<String, Float>> detect(byte[] imageData, int width, int height, int rotation) {
SparseArray<Map<String, Float>> objects = new SparseArray();
if (this.frame % 15 == 0) {
SparseArray<Map<String, Float>> objects = new SparseArray();
Mat mat = new Mat((height / 2) + height, width, CvType.CV_8UC1);
mat.put(0, 0, imageData);
@ -158,9 +158,10 @@ public class OpenCVProcessor {
break;
}
return objects;
}
this.frame++;
return objects;
return null;
}
private SparseArray<Map<String, Float>> detectFaces(Mat image, int rotation) {