Browse Source

Bug Fixes on VideoDetector

bk_service
Bastian Kohler 11 months ago
parent
commit
43eac872ed

+ 13
- 8
app/src/main/java/com/example/ueberwachungssystem/Detection/VideoDetector.java View File

@@ -42,8 +42,6 @@ import java.util.concurrent.ExecutionException;

/**
* Video Detector inherits some methods from abstract Detector class (more info there)
* USE FROM MAIN ACTIVITY:
* VideoDetector vd = new VideoDetector(this);
* */


@@ -175,7 +173,10 @@ public class VideoDetector extends Detector {
public void stopDetection() {
if (!isDetecting || imageAnalysis == null)
return;
cameraProvider.unbind(imageAnalysis);
if (!isRecording)
cameraProvider.unbindAll();
else
cameraProvider.unbind(imageAnalysis);
isDetecting = false;
allowReportViolation = false;
}
@@ -187,7 +188,11 @@ public class VideoDetector extends Detector {
return;

videoCapture.stopRecording();
cameraProvider.unbind(videoCapture);

if (!isDetecting())
cameraProvider.unbindAll();
else
cameraProvider.unbind(videoCapture);
isRecording = false;
}

@@ -219,12 +224,12 @@ public class VideoDetector extends Detector {

int n = OpenCVHelper.countNonZeroPixels(processed);
int pixelCount = image.getWidth() * image.getHeight();
float percentChanged = (float) n / pixelCount;
float percentChanged = (float) (n / pixelCount) * 100;

// Violation Condition
if (percentChanged * 100 > ALARM_THRESHOLD) {
if (percentChanged> ALARM_THRESHOLD) {
if (allowReportViolation)
reportViolation("Video", percentChanged * 100);
reportViolation("Video", percentChanged);
}
}
imageProxy.close();
@@ -310,7 +315,7 @@ public class VideoDetector extends Detector {

/** Start delay until Violation Report is allowed */
private void startViolationTimer(float setupTime) {
new CountDownTimer((long) (START_DELAY), 100) {
new CountDownTimer((long) (setupTime), 100) {
@Override
public void onTick(long millisUntilFinished) {
}

Loading…
Cancel
Save