Bug Fixes on VideoDetector
This commit is contained in:
parent
39295f9780
commit
43eac872ed
@ -42,8 +42,6 @@ import java.util.concurrent.ExecutionException;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Video Detector inherits some methods from abstract Detector class (more info there)
|
* 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() {
|
public void stopDetection() {
|
||||||
if (!isDetecting || imageAnalysis == null)
|
if (!isDetecting || imageAnalysis == null)
|
||||||
return;
|
return;
|
||||||
cameraProvider.unbind(imageAnalysis);
|
if (!isRecording)
|
||||||
|
cameraProvider.unbindAll();
|
||||||
|
else
|
||||||
|
cameraProvider.unbind(imageAnalysis);
|
||||||
isDetecting = false;
|
isDetecting = false;
|
||||||
allowReportViolation = false;
|
allowReportViolation = false;
|
||||||
}
|
}
|
||||||
@ -187,7 +188,11 @@ public class VideoDetector extends Detector {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
videoCapture.stopRecording();
|
videoCapture.stopRecording();
|
||||||
cameraProvider.unbind(videoCapture);
|
|
||||||
|
if (!isDetecting())
|
||||||
|
cameraProvider.unbindAll();
|
||||||
|
else
|
||||||
|
cameraProvider.unbind(videoCapture);
|
||||||
isRecording = false;
|
isRecording = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,12 +224,12 @@ public class VideoDetector extends Detector {
|
|||||||
|
|
||||||
int n = OpenCVHelper.countNonZeroPixels(processed);
|
int n = OpenCVHelper.countNonZeroPixels(processed);
|
||||||
int pixelCount = image.getWidth() * image.getHeight();
|
int pixelCount = image.getWidth() * image.getHeight();
|
||||||
float percentChanged = (float) n / pixelCount;
|
float percentChanged = (float) (n / pixelCount) * 100;
|
||||||
|
|
||||||
// Violation Condition
|
// Violation Condition
|
||||||
if (percentChanged * 100 > ALARM_THRESHOLD) {
|
if (percentChanged> ALARM_THRESHOLD) {
|
||||||
if (allowReportViolation)
|
if (allowReportViolation)
|
||||||
reportViolation("Video", percentChanged * 100);
|
reportViolation("Video", percentChanged);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
imageProxy.close();
|
imageProxy.close();
|
||||||
@ -310,7 +315,7 @@ public class VideoDetector extends Detector {
|
|||||||
|
|
||||||
/** Start delay until Violation Report is allowed */
|
/** Start delay until Violation Report is allowed */
|
||||||
private void startViolationTimer(float setupTime) {
|
private void startViolationTimer(float setupTime) {
|
||||||
new CountDownTimer((long) (START_DELAY), 100) {
|
new CountDownTimer((long) (setupTime), 100) {
|
||||||
@Override
|
@Override
|
||||||
public void onTick(long millisUntilFinished) {
|
public void onTick(long millisUntilFinished) {
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user