Compare commits

...

2 Commits

Author SHA1 Message Date
5d31f0bb46 Adapted Parameters 2023-06-19 15:47:40 +02:00
ea0e88ed89 Refactor in DetectorService class 2023-06-19 14:51:04 +02:00

View File

@ -79,9 +79,11 @@ public class VideoDetector extends Detector {
// Parameters // 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 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);
@ -141,7 +143,6 @@ public class VideoDetector extends Detector {
public void startRecording() { public void startRecording() {
// Check States // Check States
if (isRecording){ if (isRecording){
extendViolation();
return; return;
} }
// Return On Request Permissions // Return On Request Permissions
@ -237,7 +238,7 @@ public class VideoDetector extends Detector {
// Violation Condition // Violation Condition
if (percentChanged * 100 > ALARM_THRESHOLD) { if (percentChanged * 100 > ALARM_THRESHOLD) {
if (allowReportViolation) if (allowReportViolation)
reportViolation("Video", n); reportViolation("Video", percentChanged);
} }
} }
imageProxy.close(); imageProxy.close();
@ -274,9 +275,11 @@ public class VideoDetector extends Detector {
// Process Image // Process Image
Mat processed = preprocessed.clone(); Mat processed = preprocessed.clone();
processed = OpenCVHelper.thresholdPixels(processed, previousImage, 25); processed = OpenCVHelper.thresholdPixels(processed, previousImage, 25);
for(int i = 0; i < DILATE_ITERATIONS; i++)
processed = OpenCVHelper.dilateBinaryMat(processed, new Size(3,3)); processed = OpenCVHelper.dilateBinaryMat(processed, new Size(3,3));
processed = OpenCVHelper.dilateBinaryMat(processed, new Size(3,3));
processed = OpenCVHelper.thresholdContourArea(processed, 500); processed = OpenCVHelper.thresholdContourArea(processed, AREA_THRESHOLD);
// Output // Output
previousImage = preprocessed.clone(); previousImage = preprocessed.clone();
// Show Output Image // Show Output Image