diff --git a/app/src/main/java/com/example/ueberwachungssystem/Detection/VideoDetector.java b/app/src/main/java/com/example/ueberwachungssystem/Detection/VideoDetector.java index 1f1a759..51faec1 100644 --- a/app/src/main/java/com/example/ueberwachungssystem/Detection/VideoDetector.java +++ b/app/src/main/java/com/example/ueberwachungssystem/Detection/VideoDetector.java @@ -79,9 +79,11 @@ public class VideoDetector extends Detector { // Parameters - private static final float ALARM_THRESHOLD = 0.5f; // Percent of pixels changed + private static final float ALARM_THRESHOLD = 0f; // Percent of pixels changed + private static final float AREA_THRESHOLD = 10f; + private static final int DILATE_ITERATIONS = 2; private static final float START_DELAY = 20000; // milliseconds - private static final android.util.Size IMAGE_RES = new android.util.Size(480, 360); + private static final android.util.Size IMAGE_RES = new android.util.Size(640, 480); @@ -236,7 +238,7 @@ public class VideoDetector extends Detector { // Violation Condition if (percentChanged * 100 > ALARM_THRESHOLD) { if (allowReportViolation) - reportViolation("Video", n); + reportViolation("Video", percentChanged); } } imageProxy.close(); @@ -273,9 +275,11 @@ public class VideoDetector extends Detector { // Process Image Mat processed = preprocessed.clone(); processed = OpenCVHelper.thresholdPixels(processed, previousImage, 25); - processed = OpenCVHelper.dilateBinaryMat(processed, new Size(3,3)); - processed = OpenCVHelper.dilateBinaryMat(processed, new Size(3,3)); - processed = OpenCVHelper.thresholdContourArea(processed, 500); + + for(int i = 0; i < DILATE_ITERATIONS; i++) + processed = OpenCVHelper.dilateBinaryMat(processed, new Size(3,3)); + + processed = OpenCVHelper.thresholdContourArea(processed, AREA_THRESHOLD); // Output previousImage = preprocessed.clone(); // Show Output Image