Compare commits
No commits in common. "5b042611a5148c8b4be050f2b723b4348cd8eba3" and "5f1f127e6221398a1f238a7351834ae2f9c6bee2" have entirely different histories.
5b042611a5
...
5f1f127e62
@ -1,13 +1,8 @@
|
|||||||
package com.example.ueberwachungssystem.Detection;
|
package com.example.ueberwachungssystem.Detection;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.example.ueberwachungssystem.WifiCommunication;
|
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/** Detection Report Class */
|
/** Detection Report Class */
|
||||||
public class DetectionReport {
|
public class DetectionReport {
|
||||||
@ -17,11 +12,7 @@ public class DetectionReport {
|
|||||||
public boolean detectionState;
|
public boolean detectionState;
|
||||||
|
|
||||||
public DetectionReport(boolean detectionState, String detectionType, float detectedAmplitude) {
|
public DetectionReport(boolean detectionState, String detectionType, float detectedAmplitude) {
|
||||||
// New Date Format
|
this.timeStamp = String.valueOf(Calendar.getInstance().getTime());
|
||||||
@SuppressLint("SimpleDateFormat") SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
|
|
||||||
Date curDate = new Date(System.currentTimeMillis());
|
|
||||||
this.timeStamp = formatter.format(curDate);
|
|
||||||
//Old Date Format: this.timeStamp = String.valueOf(Calendar.getInstance().getTime());
|
|
||||||
this.detectionType = detectionType;
|
this.detectionType = detectionType;
|
||||||
this.detectedValue = detectedAmplitude;
|
this.detectedValue = detectedAmplitude;
|
||||||
this.detectionState = detectionState;
|
this.detectionState = detectionState;
|
||||||
@ -40,16 +31,6 @@ public class DetectionReport {
|
|||||||
return String.join("\t", state, time, type, value);
|
return String.join("\t", state, time, type, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toMessage() {
|
|
||||||
String state;
|
|
||||||
if(detectionState)
|
|
||||||
state = "An";
|
|
||||||
else
|
|
||||||
state = "Aus";
|
|
||||||
|
|
||||||
return String.join(",", "1", timeStamp, "Gruppe2", WifiCommunication.getLocalIpAddress(), state, detectionType, String.valueOf(detectedValue));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Debug Report */
|
/** Debug Report */
|
||||||
public void log(String tag) {
|
public void log(String tag) {
|
||||||
Log.d(tag, this.toString());
|
Log.d(tag, this.toString());
|
||||||
|
@ -22,16 +22,14 @@ public class DetectorService extends LifecycleService {
|
|||||||
private DetectorService.OnDetectionListener listener;
|
private DetectorService.OnDetectionListener listener;
|
||||||
private boolean isServiceRunning = false;
|
private boolean isServiceRunning = false;
|
||||||
|
|
||||||
// Used Objects:
|
VideoDetector videoDetector = null;
|
||||||
public VideoDetector videoDetector = null;
|
AudioRecorder audioRecorder = null;
|
||||||
public AudioRecorder audioRecorder = null;
|
|
||||||
public Accelerometer motionDetector = null;
|
/** Communication **/
|
||||||
public MicrophoneDetector audioDetector = null;
|
|
||||||
|
|
||||||
WifiCommunication wifiCommunication;
|
WifiCommunication wifiCommunication;
|
||||||
|
|
||||||
String dataFromWifi;
|
String dataFromWifi;
|
||||||
StringBuffer stringBufferFromWifi;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||||
@ -39,57 +37,30 @@ public class DetectorService extends LifecycleService {
|
|||||||
return START_NOT_STICKY;
|
return START_NOT_STICKY;
|
||||||
|
|
||||||
|
|
||||||
/** Wifi Instanz Starten und Listener **/
|
// Setup Service classes:
|
||||||
|
videoDetector = new VideoDetector(this);
|
||||||
|
videoDetector.setOnDetectionListener(new Detector.OnDetectionListener() {
|
||||||
|
@Override
|
||||||
|
public void onDetection(@NonNull DetectionReport detectionReport) {
|
||||||
|
passToServiceListener(detectionReport);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
audioRecorder = new AudioRecorder(this);
|
||||||
|
|
||||||
|
|
||||||
|
isServiceRunning = true;
|
||||||
|
|
||||||
wifiCommunication = new WifiCommunication (1234);
|
wifiCommunication = new WifiCommunication (1234);
|
||||||
wifiCommunication.setOnConnectionListener(new WifiCommunication.OnConnectionListener() {
|
wifiCommunication.setOnConnectionListener(new WifiCommunication.OnConnectionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onConnection(String data) {
|
public void onConnection(String data) {
|
||||||
dataFromWifi = data;
|
dataFromWifi = data;
|
||||||
stringToStringbuffer(data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** Video Detection/Recorder **/
|
|
||||||
videoDetector = new VideoDetector(this);
|
|
||||||
videoDetector.setOnDetectionListener(new Detector.OnDetectionListener() {
|
|
||||||
@Override
|
|
||||||
public void onDetection(@NonNull DetectionReport detectionReport) {
|
|
||||||
//passToServiceListener(detectionReport);
|
|
||||||
wifiCommunication.sendTrue(detectionReport.toMessage());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
/** Motion Detection**/
|
|
||||||
motionDetector = new Accelerometer(this);
|
|
||||||
motionDetector.getSensor();
|
|
||||||
motionDetector.setOnDetectionListener(new Detector.OnDetectionListener() {
|
|
||||||
@Override
|
|
||||||
public void onDetection(@NonNull DetectionReport detectionReport) {
|
|
||||||
//passToServiceListener(detectionReport);
|
|
||||||
wifiCommunication.sendTrue(detectionReport.toMessage());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
/** Audio Detection **/
|
|
||||||
audioDetector = new MicrophoneDetector(this);
|
|
||||||
audioDetector.setOnDetectionListener(new Detector.OnDetectionListener() {
|
|
||||||
@Override
|
|
||||||
public void onDetection(@NonNull DetectionReport detectionReport) {
|
|
||||||
//passToServiceListener(detectionReport);
|
|
||||||
wifiCommunication.sendTrue(detectionReport.toMessage());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
/** Audio Recorder**/
|
|
||||||
audioRecorder = new AudioRecorder(this);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
isServiceRunning = true;
|
|
||||||
return super.onStartCommand(intent, flags, startId);
|
return super.onStartCommand(intent, flags, startId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
@ -111,26 +82,93 @@ public class DetectorService extends LifecycleService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Pass Detection Report to Service Detection Listener and trigger it */
|
/** Video Detection */
|
||||||
public void passToServiceListener(StringBuffer stringBuffer) {
|
public void startVideoDetection() {
|
||||||
|
if(videoDetector != null)
|
||||||
|
videoDetector.startDetection();
|
||||||
|
}
|
||||||
|
public void stopVideoDetection() {
|
||||||
|
if(videoDetector != null)
|
||||||
|
videoDetector.stopDetection();
|
||||||
|
}
|
||||||
|
public boolean isVideoDetectionRunning() {
|
||||||
|
if(videoDetector != null)
|
||||||
|
return videoDetector.isDetecting();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
public void debugVideoProcessing(ImageView input, ImageView output) {
|
||||||
|
if(videoDetector != null)
|
||||||
|
videoDetector.debugProcessing(input, output);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Audio Detection */
|
||||||
|
public void startAudioDetection() {
|
||||||
|
|
||||||
|
}
|
||||||
|
public void stopAudioDetection() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Motion Detection */
|
||||||
|
public void startMotionDetection() {
|
||||||
|
|
||||||
|
}
|
||||||
|
public void stopMotionDetection() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Video Recording */
|
||||||
|
public void startVideoRecording() {
|
||||||
|
if(videoDetector != null)
|
||||||
|
videoDetector.startRecording();
|
||||||
|
}
|
||||||
|
public void stopVideoRecording() {
|
||||||
|
if(videoDetector != null)
|
||||||
|
videoDetector.stopRecording();
|
||||||
|
}
|
||||||
|
public boolean isVideoRecordingRunning() {
|
||||||
|
if(videoDetector != null)
|
||||||
|
return videoDetector.isRecording();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
public void setVideoRecordingDir(File outputDir) {
|
||||||
|
if (videoDetector != null)
|
||||||
|
videoDetector.setOutputDir(outputDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Audio Recording */
|
||||||
|
public void startAudioRecording() {
|
||||||
|
if(audioRecorder != null)
|
||||||
|
audioRecorder.startRecording();
|
||||||
|
}
|
||||||
|
public void stopAudioRecording() {
|
||||||
|
if(audioRecorder != null)
|
||||||
|
audioRecorder.stopRecording();
|
||||||
|
}
|
||||||
|
public boolean isAudioRecordingRunning() {
|
||||||
|
if(videoDetector != null)
|
||||||
|
return audioRecorder.isRecording();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
public void setAudioRecordingDir(File outputDir) {
|
||||||
|
if (audioRecorder != null)
|
||||||
|
audioRecorder.setOutputDir(outputDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** pass Detection Report to Service Detection Listener and trigger it */
|
||||||
|
public void passToServiceListener(DetectionReport detectionReport) {
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
listener.onDetection(stringBuffer);
|
listener.onDetection(detectionReport);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** On Detection Listener - runs when violation is reported */
|
/** On Detection Listener - runs when violation is reported */
|
||||||
public interface OnDetectionListener {
|
public interface OnDetectionListener {
|
||||||
void onDetection(@NonNull StringBuffer stringBuffer);
|
void onDetection(@NonNull DetectionReport detectionReport);
|
||||||
}
|
}
|
||||||
public void setOnDetectionListener(@NonNull DetectorService.OnDetectionListener listener) {
|
public void setOnDetectionListener(@NonNull DetectorService.OnDetectionListener listener) {
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** string to stringbuffer **/
|
|
||||||
public void stringToStringbuffer(String dataString){
|
|
||||||
stringBufferFromWifi.append(dataString).append("\n");
|
|
||||||
passToServiceListener(stringBufferFromWifi);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -2,16 +2,24 @@ package com.example.ueberwachungssystem.Detection;
|
|||||||
|
|
||||||
import static java.lang.Math.*;
|
import static java.lang.Math.*;
|
||||||
|
|
||||||
|
import android.Manifest;
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
import android.media.AudioFormat;
|
import android.media.AudioFormat;
|
||||||
import android.media.AudioRecord;
|
import android.media.AudioRecord;
|
||||||
import android.media.MediaRecorder;
|
import android.media.MediaRecorder;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import androidx.core.app.ActivityCompat;
|
||||||
|
import androidx.core.content.ContextCompat;
|
||||||
|
|
||||||
import com.example.ueberwachungssystem.Detection.Signalverarbeitung.Complex;
|
import com.example.ueberwachungssystem.Detection.Signalverarbeitung.Complex;
|
||||||
import com.example.ueberwachungssystem.Detection.Signalverarbeitung.FFT;
|
import com.example.ueberwachungssystem.Detection.Signalverarbeitung.FFT;
|
||||||
|
import com.example.ueberwachungssystem.Detection.DetectionReport;
|
||||||
|
import com.example.ueberwachungssystem.Detection.Detector;
|
||||||
|
|
||||||
public class MicrophoneDetector extends Detector {
|
public class MicrophoneDetector extends Detector {
|
||||||
/**
|
/**
|
||||||
@ -20,9 +28,11 @@ public class MicrophoneDetector extends Detector {
|
|||||||
* @param context
|
* @param context
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
private static final int RECHTEANFORDERUNG_MIKROFON = 1;
|
||||||
|
|
||||||
private AufnahmeTask aufnahmeTask;
|
private AufnahmeTask aufnahmeTask;
|
||||||
public boolean armed = false;
|
public boolean armed = false;
|
||||||
public int schwellwertAlarm = 100;
|
public int Schwellwert_Alarm = 100;
|
||||||
private Context context;
|
private Context context;
|
||||||
|
|
||||||
public MicrophoneDetector(Context context) {
|
public MicrophoneDetector(Context context) {
|
||||||
@ -48,17 +58,12 @@ public class MicrophoneDetector extends Detector {
|
|||||||
private final int sampleRateInHz = 44100;
|
private final int sampleRateInHz = 44100;
|
||||||
private final int channelConfig = AudioFormat.CHANNEL_IN_MONO;
|
private final int channelConfig = AudioFormat.CHANNEL_IN_MONO;
|
||||||
private final int audioFormat = AudioFormat.ENCODING_PCM_16BIT;
|
private final int audioFormat = AudioFormat.ENCODING_PCM_16BIT;
|
||||||
|
|
||||||
private final int startDelay = 20000;
|
|
||||||
private final int threadSleeptime = 10;
|
|
||||||
private int minPufferGroesseInBytes;
|
private int minPufferGroesseInBytes;
|
||||||
private int pufferGroesseInBytes;
|
private int pufferGroesseInBytes;
|
||||||
private RingPuffer ringPuffer = new RingPuffer(10);
|
private RingPuffer ringPuffer = new RingPuffer(10);
|
||||||
private float kalibierWert;
|
private float kalibierWert;
|
||||||
private com.example.ueberwachungssystem.Detection.DetectionReport detectionReport;
|
private com.example.ueberwachungssystem.Detection.DetectionReport detectionReport;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@SuppressLint("MissingPermission")
|
@SuppressLint("MissingPermission")
|
||||||
AufnahmeTask() {
|
AufnahmeTask() {
|
||||||
minPufferGroesseInBytes = AudioRecord.getMinBufferSize(sampleRateInHz, channelConfig, audioFormat);
|
minPufferGroesseInBytes = AudioRecord.getMinBufferSize(sampleRateInHz, channelConfig, audioFormat);
|
||||||
@ -107,6 +112,8 @@ public class MicrophoneDetector extends Detector {
|
|||||||
|
|
||||||
Log.d("0","Konfiguration: "+ s);
|
Log.d("0","Konfiguration: "+ s);
|
||||||
|
|
||||||
|
int pufferGroesseInAnzahlAbtastwerten = pufferGroesseInBytes / anzahlBytesProAbtastwert;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -122,7 +129,7 @@ public class MicrophoneDetector extends Detector {
|
|||||||
|
|
||||||
//Kalibrierung
|
//Kalibrierung
|
||||||
try {
|
try {
|
||||||
Thread.sleep(startDelay); // Time to lay down the phone
|
Thread.sleep(3000); // Time to lay down the phone
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -132,7 +139,7 @@ public class MicrophoneDetector extends Detector {
|
|||||||
Verarbeitungsergebnis kalibrierErgebnis = verarbeiten(puffer, n);
|
Verarbeitungsergebnis kalibrierErgebnis = verarbeiten(puffer, n);
|
||||||
kalibierWert += kalibrierErgebnis.maxAmp;
|
kalibierWert += kalibrierErgebnis.maxAmp;
|
||||||
try {
|
try {
|
||||||
Thread.sleep(threadSleeptime);
|
Thread.sleep(50);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -186,7 +193,7 @@ public class MicrophoneDetector extends Detector {
|
|||||||
publishProgress(ergebnis);
|
publishProgress(ergebnis);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Thread.sleep(threadSleeptime);
|
Thread.sleep(10);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -214,7 +221,7 @@ public class MicrophoneDetector extends Detector {
|
|||||||
|
|
||||||
ringPuffer.hinzufuegen(max);
|
ringPuffer.hinzufuegen(max);
|
||||||
maxAmp = ringPuffer.maximum();
|
maxAmp = ringPuffer.maximum();
|
||||||
if (maxAmp <= schwellwertAlarm + kalibierWert) {
|
if (maxAmp <= Schwellwert_Alarm+kalibierWert) {
|
||||||
armed = true;
|
armed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -227,10 +234,10 @@ public class MicrophoneDetector extends Detector {
|
|||||||
super.onProgressUpdate(progress);
|
super.onProgressUpdate(progress);
|
||||||
float maxAmpPrint = round(20*log10(abs(progress[0].maxAmp/1.0)));
|
float maxAmpPrint = round(20*log10(abs(progress[0].maxAmp/1.0)));
|
||||||
float kalibierWertPrint = round(20*log10(abs(kalibierWert)));
|
float kalibierWertPrint = round(20*log10(abs(kalibierWert)));
|
||||||
Log.d("alarmAudio","VR: " + progress[0].verarbeitungsrate + ", Amp: " + maxAmpPrint
|
Log.d("0","VR, Max, Kal:" + progress[0].verarbeitungsrate + ", " + maxAmpPrint
|
||||||
+ " dB, Kal: " + kalibierWertPrint + " dB");
|
+ " dB, " + kalibierWertPrint + " dB");
|
||||||
|
|
||||||
if (progress[0].maxAmp >= schwellwertAlarm + kalibierWert && armed == true) {
|
if (progress[0].maxAmp >= Schwellwert_Alarm+kalibierWert && armed == true) {
|
||||||
armed = false;
|
armed = false;
|
||||||
detectionReport = new DetectionReport(true, "Audio", maxAmpPrint);
|
detectionReport = new DetectionReport(true, "Audio", maxAmpPrint);
|
||||||
reportViolation("Audio", maxAmpPrint);
|
reportViolation("Audio", maxAmpPrint);
|
||||||
@ -352,6 +359,16 @@ public class MicrophoneDetector extends Detector {
|
|||||||
this.wichtungAlterWert = 1 - this.wichtungNeuerWert;
|
this.wichtungAlterWert = 1 - this.wichtungNeuerWert;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float MittelwertPuffer(short[] puffer) {
|
||||||
|
|
||||||
|
for (int i = 0; i < puffer.length; i++) {
|
||||||
|
mittelwert = Math.abs(puffer[i]);
|
||||||
|
}
|
||||||
|
mittelwert = mittelwert/puffer.length;
|
||||||
|
|
||||||
|
return mittelwert;
|
||||||
|
}
|
||||||
|
|
||||||
float mittel(float wert) {
|
float mittel(float wert) {
|
||||||
if (istMittelwertGesetzt) {
|
if (istMittelwertGesetzt) {
|
||||||
mittelwert = wert * wichtungNeuerWert + mittelwert * wichtungAlterWert;
|
mittelwert = wert * wichtungNeuerWert + mittelwert * wichtungAlterWert;
|
||||||
|
@ -42,6 +42,8 @@ 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);
|
||||||
* */
|
* */
|
||||||
|
|
||||||
|
|
||||||
@ -173,9 +175,6 @@ public class VideoDetector extends Detector {
|
|||||||
public void stopDetection() {
|
public void stopDetection() {
|
||||||
if (!isDetecting || imageAnalysis == null)
|
if (!isDetecting || imageAnalysis == null)
|
||||||
return;
|
return;
|
||||||
if (!isRecording)
|
|
||||||
cameraProvider.unbindAll();
|
|
||||||
else
|
|
||||||
cameraProvider.unbind(imageAnalysis);
|
cameraProvider.unbind(imageAnalysis);
|
||||||
isDetecting = false;
|
isDetecting = false;
|
||||||
allowReportViolation = false;
|
allowReportViolation = false;
|
||||||
@ -188,10 +187,6 @@ public class VideoDetector extends Detector {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
videoCapture.stopRecording();
|
videoCapture.stopRecording();
|
||||||
|
|
||||||
if (!isDetecting())
|
|
||||||
cameraProvider.unbindAll();
|
|
||||||
else
|
|
||||||
cameraProvider.unbind(videoCapture);
|
cameraProvider.unbind(videoCapture);
|
||||||
isRecording = false;
|
isRecording = false;
|
||||||
}
|
}
|
||||||
@ -224,10 +219,10 @@ 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) * 100;
|
float percentChanged = (float) n / pixelCount;
|
||||||
|
|
||||||
// Violation Condition
|
// Violation Condition
|
||||||
if (percentChanged> ALARM_THRESHOLD) {
|
if (percentChanged * 100 > ALARM_THRESHOLD) {
|
||||||
if (allowReportViolation)
|
if (allowReportViolation)
|
||||||
reportViolation("Video", percentChanged);
|
reportViolation("Video", percentChanged);
|
||||||
}
|
}
|
||||||
@ -315,7 +310,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) (setupTime), 100) {
|
new CountDownTimer((long) (START_DELAY), 100) {
|
||||||
@Override
|
@Override
|
||||||
public void onTick(long millisUntilFinished) {
|
public void onTick(long millisUntilFinished) {
|
||||||
}
|
}
|
||||||
|
@ -1,48 +0,0 @@
|
|||||||
package com.example.ueberwachungssystem.Fragments;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import androidx.fragment.app.Fragment;
|
|
||||||
|
|
||||||
import com.example.ueberwachungssystem.R;
|
|
||||||
|
|
||||||
public class Fragment1 extends Fragment {
|
|
||||||
private String text;
|
|
||||||
private final static String KEY_TEXT = "KEY_TEXT";
|
|
||||||
|
|
||||||
private void log(String nachricht) {
|
|
||||||
Log.d(this.getClass().getSimpleName(), nachricht);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
|
|
||||||
log("onCreateView");
|
|
||||||
View view = inflater.inflate(R.layout.fragment1, container, false);
|
|
||||||
TextView Sensor = (TextView) view.findViewById(R.id.Sensor);
|
|
||||||
Sensor.setText(text);
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
public static Fragment1 erstellen(String text) {
|
|
||||||
Fragment1 fragment = new Fragment1();
|
|
||||||
Bundle b = new Bundle();
|
|
||||||
b.putString(KEY_TEXT, text);
|
|
||||||
fragment.setArguments(b);
|
|
||||||
return fragment;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void onCreate(Bundle bundle) {
|
|
||||||
super .onCreate(bundle);
|
|
||||||
Bundle args = getArguments();
|
|
||||||
if (args != null ) {
|
|
||||||
text = args.getString(KEY_TEXT);
|
|
||||||
log("onCreate: text=" + text);
|
|
||||||
} else {
|
|
||||||
log("onCreate");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,46 +0,0 @@
|
|||||||
package com.example.ueberwachungssystem.Fragments;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import androidx.fragment.app.Fragment;
|
|
||||||
|
|
||||||
import com.example.ueberwachungssystem.R;
|
|
||||||
|
|
||||||
public class Fragment2 extends Fragment {
|
|
||||||
private String text;
|
|
||||||
private final static String KEY_TEXT = "KEY_TEXT" ;
|
|
||||||
private void log(String nachricht) {
|
|
||||||
Log.d(this.getClass().getSimpleName(), nachricht);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
|
|
||||||
log( "onCreateView" );
|
|
||||||
View view = inflater.inflate(R.layout.fragment2, container, false );
|
|
||||||
TextView Sensor = (TextView) view.findViewById(R.id.Sensor);
|
|
||||||
Sensor.setText(text);
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
public static Fragment2 erstellen(String text) {
|
|
||||||
Fragment2 fragment = new Fragment2();
|
|
||||||
Bundle b = new Bundle();
|
|
||||||
b.putString(KEY_TEXT, text);
|
|
||||||
fragment.setArguments(b);
|
|
||||||
return fragment;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void onCreate(Bundle bundle) {
|
|
||||||
super.onCreate(bundle);
|
|
||||||
Bundle args = getArguments();
|
|
||||||
if (args != null) {
|
|
||||||
text = args.getString(KEY_TEXT);
|
|
||||||
log("onCreate: text=" + text);
|
|
||||||
} else {
|
|
||||||
log("onCreate");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,46 +0,0 @@
|
|||||||
package com.example.ueberwachungssystem.Fragments;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import androidx.fragment.app.Fragment;
|
|
||||||
|
|
||||||
import com.example.ueberwachungssystem.R;
|
|
||||||
|
|
||||||
public class Fragment3 extends Fragment {
|
|
||||||
private String text;
|
|
||||||
private final static String KEY_TEXT = "KEY_TEXT" ;
|
|
||||||
private void log(String nachricht) {
|
|
||||||
Log.d(this.getClass().getSimpleName(), nachricht);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
|
|
||||||
log( "onCreateView" );
|
|
||||||
View view = inflater.inflate(R.layout.fragment2, container, false );
|
|
||||||
TextView Sensor = (TextView) view.findViewById(R.id.Sensor);
|
|
||||||
Sensor.setText(text);
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
public static Fragment3 erstellen(String text) {
|
|
||||||
Fragment3 fragment = new Fragment3();
|
|
||||||
Bundle b = new Bundle();
|
|
||||||
b.putString(KEY_TEXT, text);
|
|
||||||
fragment.setArguments(b);
|
|
||||||
return fragment;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void onCreate(Bundle bundle) {
|
|
||||||
super.onCreate(bundle);
|
|
||||||
Bundle args = getArguments();
|
|
||||||
if (args != null) {
|
|
||||||
text = args.getString(KEY_TEXT);
|
|
||||||
log("onCreate: text=" + text);
|
|
||||||
} else {
|
|
||||||
log("onCreate");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,44 +0,0 @@
|
|||||||
package com.example.ueberwachungssystem.Logger;
|
|
||||||
|
|
||||||
import android.util.Log;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import java.io.PrintWriter;
|
|
||||||
import java.io.StringWriter;
|
|
||||||
|
|
||||||
public class Logger {
|
|
||||||
private TextView textView;
|
|
||||||
private StringBuffer sb = new StringBuffer();
|
|
||||||
private String tag;
|
|
||||||
|
|
||||||
public Logger(String tag, TextView textView, String logInitText) {
|
|
||||||
this.tag = tag;
|
|
||||||
this.textView = textView;
|
|
||||||
sb.append(logInitText);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void log(String s) {
|
|
||||||
Log.d(tag, s);
|
|
||||||
sb.append(s).append("\n");
|
|
||||||
if (textView != null) {
|
|
||||||
textView.setText(sb.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void log(Exception e) {
|
|
||||||
StringWriter sw = new StringWriter();
|
|
||||||
e.printStackTrace(new PrintWriter(sw));
|
|
||||||
log(sw.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clearLog() {
|
|
||||||
sb.setLength(0);
|
|
||||||
if (textView != null) {
|
|
||||||
textView.setText("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLoggedText() {
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
}
|
|
@ -3,16 +3,11 @@ package com.example.ueberwachungssystem;
|
|||||||
import static android.content.ContentValues.TAG;
|
import static android.content.ContentValues.TAG;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.ComponentName;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.ServiceConnection;
|
|
||||||
import android.net.wifi.WifiInfo;
|
import android.net.wifi.WifiInfo;
|
||||||
import android.net.wifi.WifiManager;
|
import android.net.wifi.WifiManager;
|
||||||
import android.net.wifi.WifiInfo;
|
import android.net.wifi.WifiInfo;
|
||||||
import android.net.wifi.WifiManager;
|
import android.net.wifi.WifiManager;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.IBinder;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
@ -23,19 +18,13 @@ import android.widget.Button;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.camera.core.ExperimentalGetImage;
|
|
||||||
|
|
||||||
import com.example.ueberwachungssystem.Detection.DetectionReport;
|
|
||||||
import com.example.ueberwachungssystem.Detection.DetectorService;
|
|
||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.ByteOrder;
|
import java.nio.ByteOrder;
|
||||||
|
|
||||||
@ExperimentalGetImage
|
@SuppressLint("SetTextI18n")
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
WifiCommunication communication;
|
WifiCommunication communication;
|
||||||
@ -43,47 +32,20 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
boolean communicationRunning = true;
|
boolean communicationRunning = true;
|
||||||
TextView textview1;
|
TextView textview1;
|
||||||
|
|
||||||
private DetectorService detectorService = new DetectorService();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
|
textview1 = findViewById(R.id.textView1);
|
||||||
|
|
||||||
Intent serviceIntent = new Intent(this, DetectorService.class);
|
Button button1 = findViewById(R.id.buttonSend);
|
||||||
bindService(serviceIntent, serviceConnection, Context.BIND_AUTO_CREATE);
|
button1.setOnClickListener(new View.OnClickListener() {
|
||||||
startService(serviceIntent);
|
|
||||||
//textview1 = findViewById(R.id.textView1);
|
|
||||||
|
|
||||||
//Button button1 = findViewById(R.id.buttonSend);
|
|
||||||
/*button1.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
communication.sendTrue("Testmessage");
|
communication.sendTrue("Testmessage");
|
||||||
}
|
}
|
||||||
});*/
|
|
||||||
}
|
|
||||||
|
|
||||||
private ServiceConnection serviceConnection = new ServiceConnection() {
|
|
||||||
@Override
|
|
||||||
public void onServiceConnected(ComponentName name, IBinder service) {
|
|
||||||
DetectorService.ServiceBinder binder = (DetectorService.ServiceBinder) service;
|
|
||||||
detectorService = binder.getBoundService();
|
|
||||||
|
|
||||||
detectorService.setOnDetectionListener(new DetectorService.OnDetectionListener() {
|
|
||||||
@Override
|
|
||||||
public void onDetection(StringBuffer stringBuffer) {
|
|
||||||
//textview für oli
|
|
||||||
Log.d("Debugger", stringBuffer.toString());
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onServiceDisconnected(ComponentName name) {
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
@ -116,7 +78,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
getMenuInflater().inflate(R.menu.options_menu, menu);
|
getMenuInflater().inflate(R.menu.options_menu, menu);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
/*public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
Toast.makeText(this, "Selected Item: " + item.getTitle(), Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, "Selected Item: " + item.getTitle(), Toast.LENGTH_SHORT).show();
|
||||||
PopUpClass popUpClass;
|
PopUpClass popUpClass;
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
@ -138,7 +100,6 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
default:
|
default:
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
@ -38,4 +38,16 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textView1"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="TextView" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/buttonSend"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Button" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
@ -1,22 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:gravity="center_horizontal"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:background="@android:color/holo_green_light">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/Sensor"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/Alarm"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_below="@id/Sensor"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"/>
|
|
||||||
|
|
||||||
</RelativeLayout>
|
|
@ -1,22 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:gravity="center_horizontal"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:background="@android:color/holo_blue_light" >
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/Sensor"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/Alarm"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_below="@id/Sensor"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
@ -1,22 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:gravity="center_horizontal"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:background="@android:color/holo_blue_light" >
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/Sensor"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/Alarm"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_below="@id/Sensor"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,4 +1,4 @@
|
|||||||
#Thu May 11 15:19:24 CEST 2023
|
#Thu May 11 15:04:30 CEST 2023
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
|
Loading…
x
Reference in New Issue
Block a user