bk_video #4

Manually merged
kohlerba68671 merged 30 commits from bk_video into master 2023-06-02 15:51:57 +00:00
2 changed files with 7 additions and 28 deletions
Showing only changes of commit 62a528d33b - Show all commits

View File

@ -1,6 +1,5 @@
package com.example.ueberwachungssystem;
import android.content.Context;
import androidx.annotation.NonNull;
@ -8,7 +7,7 @@ abstract public class Detector {
private OnDetectionListener listener;
/** Constructor - takes context of current activity */
public Detector(Context context) {};
public Detector() {};
/** On Detection Listener - runs when violation is reported */

View File

@ -17,14 +17,14 @@ import androidx.camera.view.PreviewView;
import androidx.core.content.ContextCompat;
import androidx.lifecycle.LifecycleOwner;
import com.example.ueberwachungssystem.DetectionReport;
import com.example.ueberwachungssystem.Detector;
import com.google.common.util.concurrent.ListenableFuture;
import java.nio.ByteBuffer;
import java.util.concurrent.ExecutionException;
@ExperimentalGetImage
public class VideoDetector {
public class VideoDetector extends Detector {
// Calling Activity
private final Context context;
@ -36,39 +36,18 @@ public class VideoDetector {
// Check Violation
private final float DELTA_LUMINOSITY_THRESHOLD = 1.5f;
private Float previousLuminosity = null;
// On Detection Listener
private OnDetectionListener listener;
/** Constructor */
public VideoDetector(Context context) {
super();
this.context = context;
}
/** On Detection Listener - runs when a violation is reported */
public interface OnDetectionListener {
void onDetection(DetectionReport detectionReport);
}
public void setOnDetectionListener(OnDetectionListener listener) {
this.listener = listener;
}
private void reportViolation(float amplitude) {
if (listener != null) {
DetectionReport detectionReport = new DetectionReport("123", "Video", amplitude);
listener.onDetection(detectionReport);
}
}
/** Return State of Video Detector */
public Boolean isRunning() {
return isDetectionRunning;
}
/** Starts Video Detection */
@Override
public void startDetection() {
if (isDetectionRunning)
return;
@ -91,6 +70,7 @@ public class VideoDetector {
/** Stops Video Detection */
@Override
public void stopDetection() {
if (!isDetectionRunning)
return;
@ -173,7 +153,7 @@ public class VideoDetector {
private void checkForViolation(float luminosity, float previousLuminosity) {
float deltaLuminosity = Math.abs(luminosity - previousLuminosity);
if (deltaLuminosity > DELTA_LUMINOSITY_THRESHOLD) {
reportViolation(luminosity);
reportViolation("1232", "Video",luminosity);
Log.d("Violation", "Violation");
}
Log.d("Delta", String.valueOf(Math.abs(previousLuminosity - luminosity)));