Compare commits
13
Commits
bk_service
...
eb1629a700
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eb1629a700 | ||
|
|
b97c494427 | ||
|
|
6a251fbb27 | ||
|
|
076db89147 | ||
|
|
5007623acc | ||
|
|
3d9e6b7a3e | ||
|
|
61cad34931 | ||
|
|
e54322e3e2 | ||
|
|
edcf555b5b | ||
|
|
e571373fbb | ||
|
|
8e002107b5 | ||
|
|
1eba8e0f7c | ||
|
|
94970885cf |
No files matched your search
@@ -1,108 +0,0 @@
|
|||||||
package com.example.ueberwachungssystem.Detection;
|
|
||||||
|
|
||||||
import static java.lang.Math.sqrt;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.hardware.Sensor;
|
|
||||||
import android.hardware.SensorEvent;
|
|
||||||
import android.hardware.SensorEventListener;
|
|
||||||
import android.hardware.SensorManager;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Accelerometer inherits some methods from abstract Detector class (more info there)
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* USE FROM MAIN ACTIVITY:
|
|
||||||
*
|
|
||||||
* Accelerometer beschleunigungssensor = new Accelerometer(this);
|
|
||||||
* onCreate:
|
|
||||||
* //Accelerometer Setup
|
|
||||||
* beschleunigungssensor = new Accelerometer(this, logger, textViewLog); //logger and textview only for debugging necessary
|
|
||||||
* beschleunigungssensor.getSensor();
|
|
||||||
*
|
|
||||||
* //Starting Detection:
|
|
||||||
* beschleunigungssensor.startDetection();
|
|
||||||
* //Stopping Detection: also recommended at onPause to avoid unnecessary battery consumption
|
|
||||||
* beschleunigungssensor.stopDetection();
|
|
||||||
*
|
|
||||||
* */
|
|
||||||
|
|
||||||
public class Accelerometer extends Detector implements SensorEventListener {
|
|
||||||
|
|
||||||
public SensorManager sensorManager;
|
|
||||||
private static final int sensorType = Sensor.TYPE_LINEAR_ACCELERATION;
|
|
||||||
private Sensor accelerometer;
|
|
||||||
private Context context;
|
|
||||||
boolean alarm = false;
|
|
||||||
//Preallocate memory for the data of each axis of the acceleration sensor
|
|
||||||
float x;
|
|
||||||
float y;
|
|
||||||
float z;
|
|
||||||
float betrag; //Betrag aller drei Achsen sqrt(x*x + y*y + z*z)
|
|
||||||
private DetectionReport detectionReport;
|
|
||||||
|
|
||||||
// In constructor pass Activity, Context and TextView from MainActivity in Accelerometer class
|
|
||||||
public Accelerometer(Context context){
|
|
||||||
super(); //von Detektor
|
|
||||||
this.context = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void getSensor(){
|
|
||||||
sensorManager = (SensorManager)context.getSystemService(Context.SENSOR_SERVICE);
|
|
||||||
if(sensorManager.getSensorList(sensorType).size()==0) {
|
|
||||||
accelerometer = null;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
accelerometer = sensorManager.getSensorList(sensorType).get(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSensorChanged(SensorEvent event) {
|
|
||||||
try {
|
|
||||||
checkAlarm(event);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void checkAlarm (SensorEvent event) throws InterruptedException {
|
|
||||||
x = event.values[0];
|
|
||||||
y = event.values[1];
|
|
||||||
z = event.values[2];
|
|
||||||
betrag = (float) sqrt(x*x + y*y + z*z);
|
|
||||||
float threshold = 1.5F;
|
|
||||||
|
|
||||||
if (!alarm) {
|
|
||||||
if (betrag > threshold) {
|
|
||||||
alarm = true;
|
|
||||||
reportViolation("Bewegung", betrag);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (betrag < threshold) {
|
|
||||||
alarm = false;
|
|
||||||
} else {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAccuracyChanged(Sensor sensor, int accuracy) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void startDetection() {
|
|
||||||
// entspricht void start()
|
|
||||||
//getSensor();
|
|
||||||
if (accelerometer != null) {
|
|
||||||
sensorManager.registerListener(this, accelerometer, SensorManager.SENSOR_DELAY_GAME);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void stopDetection() {
|
|
||||||
// entspricht void stop()
|
|
||||||
sensorManager.unregisterListener(this, accelerometer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
package com.example.ueberwachungssystem.Detection;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.media.MediaPlayer;
|
|
||||||
import android.media.MediaRecorder;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
|
|
||||||
public class AudioRecorder {
|
|
||||||
private final Context context;
|
|
||||||
private MediaRecorder mediaRecorder = null;
|
|
||||||
private boolean isRecording = false;
|
|
||||||
private File outputDir; // Default: in app files directory
|
|
||||||
|
|
||||||
|
|
||||||
public AudioRecorder (Context context) {
|
|
||||||
this.context = context;
|
|
||||||
this.outputDir = context.getFilesDir();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void startRecording() {
|
|
||||||
// Handle logic
|
|
||||||
if (outputDir == null)
|
|
||||||
return;
|
|
||||||
if (isRecording)
|
|
||||||
return;
|
|
||||||
isRecording = true;
|
|
||||||
|
|
||||||
// Setup Audio Recorder for output Format: 3GP
|
|
||||||
mediaRecorder = new MediaRecorder();
|
|
||||||
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
|
|
||||||
mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
|
|
||||||
mediaRecorder.setOutputFile(outputDir + "/" + generateFileName() + ".3gp");
|
|
||||||
mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
|
|
||||||
try {
|
|
||||||
mediaRecorder.prepare();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
mediaRecorder.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void stopRecording() {
|
|
||||||
if (mediaRecorder != null) {
|
|
||||||
mediaRecorder.stop();
|
|
||||||
mediaRecorder.reset();
|
|
||||||
mediaRecorder.release();
|
|
||||||
mediaRecorder = null;
|
|
||||||
isRecording = false;
|
|
||||||
Toast.makeText(context, "audio recording saved", Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isRecording(){
|
|
||||||
return isRecording;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOutputDir(File outputDir) {
|
|
||||||
this.outputDir = outputDir;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String generateFileName(){
|
|
||||||
// Get the current timestamp
|
|
||||||
LocalDateTime currentTime = LocalDateTime.now();
|
|
||||||
// Define the format for the timestamp
|
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd_HHmmss");
|
|
||||||
// Return the timestamp as a string
|
|
||||||
return currentTime.format(formatter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,76 +0,0 @@
|
|||||||
package com.example.ueberwachungssystem.Detection;
|
|
||||||
|
|
||||||
import android.os.CountDownTimer;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.camera.core.ExperimentalGetImage;
|
|
||||||
|
|
||||||
|
|
||||||
abstract public class Detector {
|
|
||||||
private OnDetectionListener listener;
|
|
||||||
private boolean isDetecting = false;
|
|
||||||
private boolean extendViolation = false;
|
|
||||||
|
|
||||||
// Countdown parameters
|
|
||||||
private final int COUNTDOWN_TIME = 10000; // milliseconds
|
|
||||||
private final int COUNTDOWN_POLLING_TIME = 100; // milliseconds
|
|
||||||
|
|
||||||
/** Constructor - takes context of current activity */
|
|
||||||
public Detector() {}
|
|
||||||
|
|
||||||
|
|
||||||
/** On Detection Listener - runs when violation is reported */
|
|
||||||
public interface OnDetectionListener {
|
|
||||||
void onDetection(@NonNull DetectionReport detectionReport);
|
|
||||||
}
|
|
||||||
public void setOnDetectionListener(@NonNull OnDetectionListener listener) {
|
|
||||||
this.listener = listener;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Triggers onDetectionListener - call this to trigger violation/alarm */
|
|
||||||
public void reportViolation(String detectionType, float amplitude) {
|
|
||||||
if (listener != null) {
|
|
||||||
if (!isDetecting) {
|
|
||||||
isDetecting = true;
|
|
||||||
DetectionReport detectionReport = new DetectionReport(true, detectionType, amplitude);
|
|
||||||
listener.onDetection(detectionReport);
|
|
||||||
startDetectionTimer(detectionType, amplitude);
|
|
||||||
} else {
|
|
||||||
extendViolation = true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
isDetecting = false;
|
|
||||||
extendViolation = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void startDetectionTimer(String detectionType, float amplitude) {
|
|
||||||
isDetecting = true;
|
|
||||||
new CountDownTimer((long) COUNTDOWN_TIME, COUNTDOWN_POLLING_TIME) {
|
|
||||||
@Override
|
|
||||||
public void onTick(long millisUntilFinished) {
|
|
||||||
if (extendViolation) {
|
|
||||||
extendViolation = false;
|
|
||||||
startDetectionTimer(detectionType, amplitude);
|
|
||||||
this.cancel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void onFinish() {
|
|
||||||
isDetecting = false;
|
|
||||||
DetectionReport detectionReport = new DetectionReport(false, detectionType, amplitude);
|
|
||||||
listener.onDetection(detectionReport);
|
|
||||||
}
|
|
||||||
}.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void extendViolation(){
|
|
||||||
this.extendViolation = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Starts Detection (abstract method: needs to be overridden in child class) */
|
|
||||||
public abstract void startDetection();
|
|
||||||
|
|
||||||
/** Stops Detection (abstract method: needs to be overridden in child class) */
|
|
||||||
public abstract void stopDetection();
|
|
||||||
}
|
|
||||||
@@ -3,6 +3,7 @@ package com.example.ueberwachungssystem.Detection;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
|
import android.util.Log;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
@@ -10,6 +11,8 @@ import androidx.annotation.Nullable;
|
|||||||
import androidx.camera.core.ExperimentalGetImage;
|
import androidx.camera.core.ExperimentalGetImage;
|
||||||
import androidx.lifecycle.LifecycleService;
|
import androidx.lifecycle.LifecycleService;
|
||||||
|
|
||||||
|
import com.example.ueberwachungssystem.WifiCommunication;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
@ExperimentalGetImage
|
@ExperimentalGetImage
|
||||||
@@ -24,12 +27,38 @@ public class DetectorService extends LifecycleService {
|
|||||||
public Accelerometer motionDetector = null;
|
public Accelerometer motionDetector = null;
|
||||||
public MicrophoneDetector audioDetector = null;
|
public MicrophoneDetector audioDetector = null;
|
||||||
|
|
||||||
|
public WifiCommunication wifiCommunication;
|
||||||
|
|
||||||
|
String wifiData;
|
||||||
|
StringBuffer stringBufferWifi = new StringBuffer();
|
||||||
|
|
||||||
|
String typOfAlarm;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||||
if (isServiceRunning)
|
if (isServiceRunning)
|
||||||
return START_NOT_STICKY;
|
return START_NOT_STICKY;
|
||||||
|
|
||||||
|
/** Wifi Instanz **/
|
||||||
|
wifiCommunication = new WifiCommunication(1234);
|
||||||
|
wifiCommunication.sendTrue("TEst");
|
||||||
|
|
||||||
|
wifiCommunication.setOnConnectionListener(new WifiCommunication.OnConnectionListener() {
|
||||||
|
@Override
|
||||||
|
public void onConnection(String data) {
|
||||||
|
Log.d("Listener", data);
|
||||||
|
wifiData = data;
|
||||||
|
stringToStringbuffer(data);
|
||||||
|
Log.d("buffer",stringBufferWifi.toString());
|
||||||
|
passToServiceListener(stringBufferWifi);
|
||||||
|
checkState(data);
|
||||||
|
checkTyp(data);
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -38,7 +67,8 @@ public class DetectorService extends LifecycleService {
|
|||||||
videoDetector.setOnDetectionListener(new Detector.OnDetectionListener() {
|
videoDetector.setOnDetectionListener(new Detector.OnDetectionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onDetection(@NonNull DetectionReport detectionReport) {
|
public void onDetection(@NonNull DetectionReport detectionReport) {
|
||||||
passToServiceListener(detectionReport);
|
//passToServiceListener(detectionReport);
|
||||||
|
wifiCommunication.sendTrue(detectionReport.toMessage());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
/** Motion Detection**/
|
/** Motion Detection**/
|
||||||
@@ -47,7 +77,8 @@ public class DetectorService extends LifecycleService {
|
|||||||
motionDetector.setOnDetectionListener(new Detector.OnDetectionListener() {
|
motionDetector.setOnDetectionListener(new Detector.OnDetectionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onDetection(@NonNull DetectionReport detectionReport) {
|
public void onDetection(@NonNull DetectionReport detectionReport) {
|
||||||
passToServiceListener(detectionReport);
|
//passToServiceListener(detectionReport);
|
||||||
|
wifiCommunication.sendTrue(detectionReport.toMessage());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
/** Audio Detection **/
|
/** Audio Detection **/
|
||||||
@@ -55,7 +86,8 @@ public class DetectorService extends LifecycleService {
|
|||||||
audioDetector.setOnDetectionListener(new Detector.OnDetectionListener() {
|
audioDetector.setOnDetectionListener(new Detector.OnDetectionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onDetection(@NonNull DetectionReport detectionReport) {
|
public void onDetection(@NonNull DetectionReport detectionReport) {
|
||||||
passToServiceListener(detectionReport);
|
//passToServiceListener(detectionReport);
|
||||||
|
wifiCommunication.sendTrue(detectionReport.toMessage());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
/** Audio Recorder**/
|
/** Audio Recorder**/
|
||||||
@@ -92,18 +124,44 @@ public class DetectorService extends LifecycleService {
|
|||||||
|
|
||||||
|
|
||||||
/** Pass Detection Report to Service Detection Listener and trigger it */
|
/** Pass Detection Report to Service Detection Listener and trigger it */
|
||||||
public void passToServiceListener(DetectionReport detectionReport) {
|
public void passToServiceListener(StringBuffer stringBuffer) {
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
listener.onDetection(detectionReport);
|
listener.onDetection(stringBuffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** 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 DetectionReport detectionReport);
|
void onDetection(@NonNull StringBuffer stringBuffer);
|
||||||
}
|
}
|
||||||
public void setOnDetectionListener(@NonNull DetectorService.OnDetectionListener listener) {
|
public void setOnDetectionListener(@NonNull DetectorService.OnDetectionListener listener) {
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void stringToStringbuffer(String string){
|
||||||
|
if(string != null) {
|
||||||
|
stringBufferWifi.insert(0,string + "\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String[] splitString(String string){
|
||||||
|
String[] splitrxString = string.split(",");
|
||||||
|
return splitrxString; //splitrxString[0] = "1",splitrxString[1] = "HH:MM:SS", splitrxString[0].equals("1")
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean checkState(String string){
|
||||||
|
Log.d("state", String.valueOf(splitString(string)[4].equals("An")));
|
||||||
|
return splitString(string)[4].equals("An");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String checkTyp(String string){
|
||||||
|
if (splitString(string)[5] != null) {
|
||||||
|
typOfAlarm = splitString(string)[5];
|
||||||
|
Log.d("Type", typOfAlarm);
|
||||||
|
}
|
||||||
|
return typOfAlarm;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+13
-30
@@ -2,24 +2,16 @@ 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 {
|
||||||
/**
|
/**
|
||||||
@@ -28,11 +20,9 @@ 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 Schwellwert_Alarm = 100;
|
public int schwellwertAlarm = 100;
|
||||||
private Context context;
|
private Context context;
|
||||||
|
|
||||||
public MicrophoneDetector(Context context) {
|
public MicrophoneDetector(Context context) {
|
||||||
@@ -58,12 +48,17 @@ 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);
|
||||||
@@ -112,8 +107,6 @@ public class MicrophoneDetector extends Detector {
|
|||||||
|
|
||||||
Log.d("0","Konfiguration: "+ s);
|
Log.d("0","Konfiguration: "+ s);
|
||||||
|
|
||||||
int pufferGroesseInAnzahlAbtastwerten = pufferGroesseInBytes / anzahlBytesProAbtastwert;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -129,7 +122,7 @@ public class MicrophoneDetector extends Detector {
|
|||||||
|
|
||||||
//Kalibrierung
|
//Kalibrierung
|
||||||
try {
|
try {
|
||||||
Thread.sleep(3000); // Time to lay down the phone
|
Thread.sleep(startDelay); // Time to lay down the phone
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -139,7 +132,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(50);
|
Thread.sleep(threadSleeptime);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -193,7 +186,7 @@ public class MicrophoneDetector extends Detector {
|
|||||||
publishProgress(ergebnis);
|
publishProgress(ergebnis);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Thread.sleep(10);
|
Thread.sleep(threadSleeptime);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -221,7 +214,7 @@ public class MicrophoneDetector extends Detector {
|
|||||||
|
|
||||||
ringPuffer.hinzufuegen(max);
|
ringPuffer.hinzufuegen(max);
|
||||||
maxAmp = ringPuffer.maximum();
|
maxAmp = ringPuffer.maximum();
|
||||||
if (maxAmp <= Schwellwert_Alarm+kalibierWert) {
|
if (maxAmp <= schwellwertAlarm + kalibierWert) {
|
||||||
armed = true;
|
armed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -234,10 +227,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("0","VR, Max, Kal:" + progress[0].verarbeitungsrate + ", " + maxAmpPrint
|
Log.d("alarmAudio","VR: " + progress[0].verarbeitungsrate + ", Amp: " + maxAmpPrint
|
||||||
+ " dB, " + kalibierWertPrint + " dB");
|
+ " dB, Kal: " + kalibierWertPrint + " dB");
|
||||||
|
|
||||||
if (progress[0].maxAmp >= Schwellwert_Alarm+kalibierWert && armed == true) {
|
if (progress[0].maxAmp >= schwellwertAlarm + 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);
|
||||||
@@ -359,16 +352,6 @@ 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;
|
||||||
|
|||||||
@@ -1,109 +0,0 @@
|
|||||||
package com.example.ueberwachungssystem.Detection;
|
|
||||||
|
|
||||||
import android.graphics.Bitmap;
|
|
||||||
import android.media.Image;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.camera.core.ExperimentalGetImage;
|
|
||||||
import androidx.camera.core.ImageProxy;
|
|
||||||
|
|
||||||
import org.opencv.android.Utils;
|
|
||||||
import org.opencv.core.Core;
|
|
||||||
import org.opencv.core.CvType;
|
|
||||||
import org.opencv.core.Mat;
|
|
||||||
import org.opencv.core.MatOfPoint;
|
|
||||||
import org.opencv.core.Scalar;
|
|
||||||
import org.opencv.core.Size;
|
|
||||||
import org.opencv.imgproc.Imgproc;
|
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
|
||||||
@ExperimentalGetImage
|
|
||||||
public class OpenCVHelper {
|
|
||||||
|
|
||||||
/** OpenCV helper methods **/
|
|
||||||
public static Mat addGaussianBlur(Mat inputMat, Size kernelSize){
|
|
||||||
Mat outputMat = new Mat();
|
|
||||||
Imgproc.GaussianBlur(inputMat, outputMat, kernelSize, 0);
|
|
||||||
return outputMat;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Mat addBlur(Mat inputMat, Size kernelSize){
|
|
||||||
Mat outputMat = new Mat();
|
|
||||||
Imgproc.blur(inputMat, outputMat, kernelSize);
|
|
||||||
return outputMat;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Mat extractYChannel(@NonNull ImageProxy imgProxy) {
|
|
||||||
Image img = imgProxy.getImage();
|
|
||||||
|
|
||||||
assert img != null;
|
|
||||||
ByteBuffer yBuffer = img.getPlanes()[0].getBuffer();
|
|
||||||
byte[] yData = new byte[yBuffer.remaining()];
|
|
||||||
yBuffer.get(yData);
|
|
||||||
|
|
||||||
Mat yMat = new Mat(img.getHeight(), img.getWidth(), CvType.CV_8UC1);
|
|
||||||
yMat.put(0, 0, yData);
|
|
||||||
|
|
||||||
return yMat;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Mat thresholdPixels(Mat inputMat, Mat previousImage, int threshold){
|
|
||||||
Mat diffImage = new Mat();
|
|
||||||
Core.absdiff(inputMat, previousImage, diffImage);
|
|
||||||
Mat binaryMat = new Mat();
|
|
||||||
Imgproc.threshold(diffImage, binaryMat, threshold, 255, Imgproc.THRESH_BINARY);
|
|
||||||
return binaryMat;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static Mat thresholdContourArea(Mat inputMat, float areaThreshold){
|
|
||||||
List<MatOfPoint> contours = new ArrayList<>();
|
|
||||||
Mat hierarchy = new Mat();
|
|
||||||
Imgproc.findContours(inputMat, contours, hierarchy, Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_SIMPLE);
|
|
||||||
|
|
||||||
Mat outputMat = new Mat(inputMat.size(), inputMat.type(), new Scalar(0));
|
|
||||||
// Iterate over the contours and draw only the larger contours on the outputMat
|
|
||||||
for (MatOfPoint contour : contours) {
|
|
||||||
double contourArea = Imgproc.contourArea(contour);
|
|
||||||
if (contourArea > areaThreshold) {
|
|
||||||
Imgproc.drawContours(outputMat, Collections.singletonList(contour), 0, new Scalar(255), -1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Apply the outputMat as a mask to the dilatedImage
|
|
||||||
Mat maskedImage = new Mat();
|
|
||||||
inputMat.copyTo(maskedImage, outputMat);
|
|
||||||
return outputMat;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Mat dilateBinaryMat(Mat inputMat, Size kernelSize){
|
|
||||||
Mat dilatedMat = new Mat();
|
|
||||||
Mat kernel = Imgproc.getStructuringElement(Imgproc.MORPH_ELLIPSE, kernelSize);
|
|
||||||
Imgproc.dilate(inputMat, dilatedMat, kernel);
|
|
||||||
return dilatedMat;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int countNonZeroPixels(Mat inputImage) {
|
|
||||||
if (inputImage != null)
|
|
||||||
return Core.countNonZero(inputImage);
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static void debugMat(Mat mat, ImageView imageView) {
|
|
||||||
if (imageView == null || mat == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Bitmap bitmap = Bitmap.createBitmap(mat.cols(), mat.rows(), Bitmap.Config.ARGB_8888);
|
|
||||||
Utils.matToBitmap(mat, bitmap);
|
|
||||||
|
|
||||||
// Display the bitmap in an ImageView
|
|
||||||
imageView.setImageBitmap(bitmap);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-148
@@ -1,148 +0,0 @@
|
|||||||
package com.example.ueberwachungssystem.Detection.Signalverarbeitung;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class Complex {
|
|
||||||
private final double re; // the real part
|
|
||||||
private final double im; // the imaginary part
|
|
||||||
|
|
||||||
// create a new object with the given real and imaginary parts
|
|
||||||
public Complex(double real, double imag) {
|
|
||||||
re = real;
|
|
||||||
im = imag;
|
|
||||||
}
|
|
||||||
|
|
||||||
// return a string representation of the invoking com.example.ueberwachungssystem.Detection.Signalverarbeitung.Complex object
|
|
||||||
public String toString() {
|
|
||||||
if (im == 0) return re + "";
|
|
||||||
if (re == 0) return im + "i";
|
|
||||||
if (im < 0) return re + " - " + (-im) + "i";
|
|
||||||
return re + " + " + im + "i";
|
|
||||||
}
|
|
||||||
|
|
||||||
// return abs/modulus/magnitude
|
|
||||||
public double abs() {
|
|
||||||
return Math.hypot(re, im);
|
|
||||||
}
|
|
||||||
|
|
||||||
// return angle/phase/argument, normalized to be between -pi and pi
|
|
||||||
public double phase() {
|
|
||||||
return Math.atan2(im, re);
|
|
||||||
}
|
|
||||||
|
|
||||||
// return a new com.example.ueberwachungssystem.Detection.Signalverarbeitung.Complex object whose value is (this + b)
|
|
||||||
public Complex plus(Complex b) {
|
|
||||||
Complex a = this; // invoking object
|
|
||||||
double real = a.re + b.re;
|
|
||||||
double imag = a.im + b.im;
|
|
||||||
return new Complex(real, imag);
|
|
||||||
}
|
|
||||||
|
|
||||||
// return a new com.example.ueberwachungssystem.Detection.Signalverarbeitung.Complex object whose value is (this - b)
|
|
||||||
public Complex minus(Complex b) {
|
|
||||||
Complex a = this;
|
|
||||||
double real = a.re - b.re;
|
|
||||||
double imag = a.im - b.im;
|
|
||||||
return new Complex(real, imag);
|
|
||||||
}
|
|
||||||
|
|
||||||
// return a new com.example.ueberwachungssystem.Detection.Signalverarbeitung.Complex object whose value is (this * b)
|
|
||||||
public Complex times(Complex b) {
|
|
||||||
Complex a = this;
|
|
||||||
double real = a.re * b.re - a.im * b.im;
|
|
||||||
double imag = a.re * b.im + a.im * b.re;
|
|
||||||
return new Complex(real, imag);
|
|
||||||
}
|
|
||||||
|
|
||||||
// return a new object whose value is (this * alpha)
|
|
||||||
public Complex scale(double alpha) {
|
|
||||||
return new Complex(alpha * re, alpha * im);
|
|
||||||
}
|
|
||||||
|
|
||||||
// return a new com.example.ueberwachungssystem.Detection.Signalverarbeitung.Complex object whose value is the conjugate of this
|
|
||||||
public Complex conjugate() {
|
|
||||||
return new Complex(re, -im);
|
|
||||||
}
|
|
||||||
|
|
||||||
// return a new com.example.ueberwachungssystem.Detection.Signalverarbeitung.Complex object whose value is the reciprocal of this
|
|
||||||
public Complex reciprocal() {
|
|
||||||
double scale = re * re + im * im;
|
|
||||||
return new Complex(re / scale, -im / scale);
|
|
||||||
}
|
|
||||||
|
|
||||||
// return the real or imaginary part
|
|
||||||
public double re() {
|
|
||||||
return re;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double im() {
|
|
||||||
return im;
|
|
||||||
}
|
|
||||||
|
|
||||||
// return a / b
|
|
||||||
public Complex divides(Complex b) {
|
|
||||||
Complex a = this;
|
|
||||||
return a.times(b.reciprocal());
|
|
||||||
}
|
|
||||||
|
|
||||||
// return a new com.example.ueberwachungssystem.Detection.Signalverarbeitung.Complex object whose value is the complex exponential of this
|
|
||||||
public Complex exp() {
|
|
||||||
return new Complex(Math.exp(re) * Math.cos(im), Math.exp(re) * Math.sin(im));
|
|
||||||
}
|
|
||||||
|
|
||||||
// return a new com.example.ueberwachungssystem.Detection.Signalverarbeitung.Complex object whose value is the complex sine of this
|
|
||||||
public Complex sin() {
|
|
||||||
return new Complex(Math.sin(re) * Math.cosh(im), Math.cos(re) * Math.sinh(im));
|
|
||||||
}
|
|
||||||
|
|
||||||
// return a new com.example.ueberwachungssystem.Detection.Signalverarbeitung.Complex object whose value is the complex cosine of this
|
|
||||||
public Complex cos() {
|
|
||||||
return new Complex(Math.cos(re) * Math.cosh(im), -Math.sin(re) * Math.sinh(im));
|
|
||||||
}
|
|
||||||
|
|
||||||
// return a new com.example.ueberwachungssystem.Detection.Signalverarbeitung.Complex object whose value is the complex tangent of this
|
|
||||||
public Complex tan() {
|
|
||||||
return sin().divides(cos());
|
|
||||||
}
|
|
||||||
|
|
||||||
// a static version of plus
|
|
||||||
public static Complex plus(Complex a, Complex b) {
|
|
||||||
double real = a.re + b.re;
|
|
||||||
double imag = a.im + b.im;
|
|
||||||
Complex sum = new Complex(real, imag);
|
|
||||||
return sum;
|
|
||||||
}
|
|
||||||
|
|
||||||
// See Section 3.3.
|
|
||||||
public boolean equals(Object x) {
|
|
||||||
if (x == null) return false;
|
|
||||||
if (this.getClass() != x.getClass()) return false;
|
|
||||||
Complex that = (Complex) x;
|
|
||||||
return (this.re == that.re) && (this.im == that.im);
|
|
||||||
}
|
|
||||||
|
|
||||||
// See Section 3.3.
|
|
||||||
public int hashCode() {
|
|
||||||
return Objects.hash(re, im);
|
|
||||||
}
|
|
||||||
|
|
||||||
// sample client for testing
|
|
||||||
public static void main(String[] args) {
|
|
||||||
Complex a = new Complex(5.0, 6.0);
|
|
||||||
Complex b = new Complex(-3.0, 4.0);
|
|
||||||
|
|
||||||
System.out.println("a = " + a);
|
|
||||||
System.out.println("b = " + b);
|
|
||||||
System.out.println("Re(a) = " + a.re());
|
|
||||||
System.out.println("Im(a) = " + a.im());
|
|
||||||
System.out.println("b + a = " + b.plus(a));
|
|
||||||
System.out.println("a - b = " + a.minus(b));
|
|
||||||
System.out.println("a * b = " + a.times(b));
|
|
||||||
System.out.println("b * a = " + b.times(a));
|
|
||||||
System.out.println("a / b = " + a.divides(b));
|
|
||||||
System.out.println("(a / b) * b = " + a.divides(b).times(b));
|
|
||||||
System.out.println("conj(a) = " + a.conjugate());
|
|
||||||
System.out.println("|a| = " + a.abs());
|
|
||||||
System.out.println("tan(a) = " + a.tan());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-246
@@ -1,246 +0,0 @@
|
|||||||
package com.example.ueberwachungssystem.Detection.Signalverarbeitung;
|
|
||||||
// Source: https://introcs.cs.princeton.edu/java/97data/FFT.java.html
|
|
||||||
|
|
||||||
/******************************************************************************
|
|
||||||
* Compilation: javac FFT.java
|
|
||||||
* Execution: java FFT n
|
|
||||||
* Dependencies: com.example.ueberwachungssystem.Detection.Signalverarbeitung.Complex.java
|
|
||||||
*
|
|
||||||
* Compute the FFT and inverse FFT of a length n complex sequence
|
|
||||||
* using the radix 2 Cooley-Tukey algorithm.
|
|
||||||
* Bare bones implementation that runs in O(n log n) time and O(n)
|
|
||||||
* space. Our goal is to optimize the clarity of the code, rather
|
|
||||||
* than performance.
|
|
||||||
*
|
|
||||||
* This implementation uses the primitive root of unity w = e^(-2 pi i / n).
|
|
||||||
* Some resources use w = e^(2 pi i / n).
|
|
||||||
*
|
|
||||||
* Reference: https://www.cs.princeton.edu/~wayne/kleinberg-tardos/pdf/05DivideAndConquerII.pdf
|
|
||||||
*
|
|
||||||
* Limitations
|
|
||||||
* -----------
|
|
||||||
* - assumes n is a power of 2
|
|
||||||
*
|
|
||||||
* - not the most memory efficient algorithm (because it uses
|
|
||||||
* an object type for representing complex numbers and because
|
|
||||||
* it re-allocates memory for the subarray, instead of doing
|
|
||||||
* in-place or reusing a single temporary array)
|
|
||||||
*
|
|
||||||
* For an in-place radix 2 Cooley-Tukey FFT, see
|
|
||||||
* https://introcs.cs.princeton.edu/java/97data/InplaceFFT.java.html
|
|
||||||
*
|
|
||||||
******************************************************************************/
|
|
||||||
|
|
||||||
public class FFT {
|
|
||||||
|
|
||||||
// compute the FFT of x[], assuming its length n is a power of 2
|
|
||||||
public static Complex[] fft(Complex[] x) {
|
|
||||||
int n = x.length;
|
|
||||||
|
|
||||||
// base case
|
|
||||||
if (n == 1) return new Complex[]{x[0]};
|
|
||||||
|
|
||||||
// radix 2 Cooley-Tukey FFT
|
|
||||||
if (n % 2 != 0) {
|
|
||||||
throw new IllegalArgumentException("n is not a power of 2");
|
|
||||||
}
|
|
||||||
|
|
||||||
// compute FFT of even terms
|
|
||||||
Complex[] even = new Complex[n / 2];
|
|
||||||
for (int k = 0; k < n / 2; k++) {
|
|
||||||
even[k] = x[2 * k];
|
|
||||||
}
|
|
||||||
Complex[] evenFFT = fft(even);
|
|
||||||
|
|
||||||
// compute FFT of odd terms
|
|
||||||
Complex[] odd = even; // reuse the array (to avoid n log n space)
|
|
||||||
for (int k = 0; k < n / 2; k++) {
|
|
||||||
odd[k] = x[2 * k + 1];
|
|
||||||
}
|
|
||||||
Complex[] oddFFT = fft(odd);
|
|
||||||
|
|
||||||
// combine
|
|
||||||
Complex[] y = new Complex[n];
|
|
||||||
for (int k = 0; k < n / 2; k++) {
|
|
||||||
double kth = -2 * k * Math.PI / n;
|
|
||||||
Complex wk = new Complex(Math.cos(kth), Math.sin(kth));
|
|
||||||
y[k] = evenFFT[k].plus(wk.times(oddFFT[k]));
|
|
||||||
y[k + n / 2] = evenFFT[k].minus(wk.times(oddFFT[k]));
|
|
||||||
}
|
|
||||||
return y;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// compute the inverse FFT of x[], assuming its length n is a power of 2
|
|
||||||
public static Complex[] ifft(Complex[] x) {
|
|
||||||
int n = x.length;
|
|
||||||
Complex[] y = new Complex[n];
|
|
||||||
|
|
||||||
// take conjugate
|
|
||||||
for (int i = 0; i < n; i++) {
|
|
||||||
y[i] = x[i].conjugate();
|
|
||||||
}
|
|
||||||
|
|
||||||
// compute forward FFT
|
|
||||||
y = fft(y);
|
|
||||||
|
|
||||||
// take conjugate again
|
|
||||||
for (int i = 0; i < n; i++) {
|
|
||||||
y[i] = y[i].conjugate();
|
|
||||||
}
|
|
||||||
|
|
||||||
// divide by n
|
|
||||||
for (int i = 0; i < n; i++) {
|
|
||||||
y[i] = y[i].scale(1.0 / n);
|
|
||||||
}
|
|
||||||
|
|
||||||
return y;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// compute the circular convolution of x and y
|
|
||||||
public static Complex[] cconvolve(Complex[] x, Complex[] y) {
|
|
||||||
|
|
||||||
// should probably pad x and y with 0s so that they have same length
|
|
||||||
// and are powers of 2
|
|
||||||
if (x.length != y.length) {
|
|
||||||
throw new IllegalArgumentException("Dimensions don't agree");
|
|
||||||
}
|
|
||||||
|
|
||||||
int n = x.length;
|
|
||||||
|
|
||||||
// compute FFT of each sequence
|
|
||||||
Complex[] a = fft(x);
|
|
||||||
Complex[] b = fft(y);
|
|
||||||
|
|
||||||
// point-wise multiply
|
|
||||||
Complex[] c = new Complex[n];
|
|
||||||
for (int i = 0; i < n; i++) {
|
|
||||||
c[i] = a[i].times(b[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// compute inverse FFT
|
|
||||||
return ifft(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// compute the linear convolution of x and y
|
|
||||||
public static Complex[] convolve(Complex[] x, Complex[] y) {
|
|
||||||
Complex ZERO = new Complex(0, 0);
|
|
||||||
|
|
||||||
Complex[] a = new Complex[2 * x.length];
|
|
||||||
for (int i = 0; i < x.length; i++) a[i] = x[i];
|
|
||||||
for (int i = x.length; i < 2 * x.length; i++) a[i] = ZERO;
|
|
||||||
|
|
||||||
Complex[] b = new Complex[2 * y.length];
|
|
||||||
for (int i = 0; i < y.length; i++) b[i] = y[i];
|
|
||||||
for (int i = y.length; i < 2 * y.length; i++) b[i] = ZERO;
|
|
||||||
|
|
||||||
return cconvolve(a, b);
|
|
||||||
}
|
|
||||||
|
|
||||||
// compute the DFT of x[] via brute force (n^2 time)
|
|
||||||
public static Complex[] dft(Complex[] x) {
|
|
||||||
int n = x.length;
|
|
||||||
Complex ZERO = new Complex(0, 0);
|
|
||||||
Complex[] y = new Complex[n];
|
|
||||||
for (int k = 0; k < n; k++) {
|
|
||||||
y[k] = ZERO;
|
|
||||||
for (int j = 0; j < n; j++) {
|
|
||||||
int power = (k * j) % n;
|
|
||||||
double kth = -2 * power * Math.PI / n;
|
|
||||||
Complex wkj = new Complex(Math.cos(kth), Math.sin(kth));
|
|
||||||
y[k] = y[k].plus(x[j].times(wkj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return y;
|
|
||||||
}
|
|
||||||
|
|
||||||
// display an array of com.example.ueberwachungssystem.Detection.Signalverarbeitung.Complex numbers to standard output
|
|
||||||
public static void show(Complex[] x, String title) {
|
|
||||||
System.out.println(title);
|
|
||||||
System.out.println("-------------------");
|
|
||||||
for (int i = 0; i < x.length; i++) {
|
|
||||||
System.out.println(x[i]);
|
|
||||||
}
|
|
||||||
System.out.println();
|
|
||||||
}
|
|
||||||
|
|
||||||
/***************************************************************************
|
|
||||||
* Test client and sample execution
|
|
||||||
*
|
|
||||||
* % java FFT 4
|
|
||||||
* x
|
|
||||||
* -------------------
|
|
||||||
* -0.03480425839330703
|
|
||||||
* 0.07910192950176387
|
|
||||||
* 0.7233322451735928
|
|
||||||
* 0.1659819820667019
|
|
||||||
*
|
|
||||||
* y = fft(x)
|
|
||||||
* -------------------
|
|
||||||
* 0.9336118983487516
|
|
||||||
* -0.7581365035668999 + 0.08688005256493803i
|
|
||||||
* 0.44344407521182005
|
|
||||||
* -0.7581365035668999 - 0.08688005256493803i
|
|
||||||
*
|
|
||||||
* z = ifft(y)
|
|
||||||
* -------------------
|
|
||||||
* -0.03480425839330703
|
|
||||||
* 0.07910192950176387 + 2.6599344570851287E-18i
|
|
||||||
* 0.7233322451735928
|
|
||||||
* 0.1659819820667019 - 2.6599344570851287E-18i
|
|
||||||
*
|
|
||||||
* c = cconvolve(x, x)
|
|
||||||
* -------------------
|
|
||||||
* 0.5506798633981853
|
|
||||||
* 0.23461407150576394 - 4.033186818023279E-18i
|
|
||||||
* -0.016542951108772352
|
|
||||||
* 0.10288019294318276 + 4.033186818023279E-18i
|
|
||||||
*
|
|
||||||
* d = convolve(x, x)
|
|
||||||
* -------------------
|
|
||||||
* 0.001211336402308083 - 3.122502256758253E-17i
|
|
||||||
* -0.005506167987577068 - 5.058885073636224E-17i
|
|
||||||
* -0.044092969479563274 + 2.1934338938072244E-18i
|
|
||||||
* 0.10288019294318276 - 3.6147323062478115E-17i
|
|
||||||
* 0.5494685269958772 + 3.122502256758253E-17i
|
|
||||||
* 0.240120239493341 + 4.655566391833896E-17i
|
|
||||||
* 0.02755001837079092 - 2.1934338938072244E-18i
|
|
||||||
* 4.01805098805014E-17i
|
|
||||||
*
|
|
||||||
***************************************************************************/
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
int n = Integer.parseInt(args[0]);
|
|
||||||
Complex[] x = new Complex[n];
|
|
||||||
|
|
||||||
// original data
|
|
||||||
for (int i = 0; i < n; i++) {
|
|
||||||
x[i] = new Complex(i, 0);
|
|
||||||
}
|
|
||||||
show(x, "x");
|
|
||||||
|
|
||||||
// FFT of original data
|
|
||||||
Complex[] y = fft(x);
|
|
||||||
show(y, "y = fft(x)");
|
|
||||||
|
|
||||||
// FFT of original data
|
|
||||||
Complex[] y2 = dft(x);
|
|
||||||
show(y2, "y2 = dft(x)");
|
|
||||||
|
|
||||||
// take inverse FFT
|
|
||||||
Complex[] z = ifft(y);
|
|
||||||
show(z, "z = ifft(y)");
|
|
||||||
|
|
||||||
// circular convolution of x with itself
|
|
||||||
Complex[] c = cconvolve(x, x);
|
|
||||||
show(c, "c = cconvolve(x, x)");
|
|
||||||
|
|
||||||
// linear convolution of x with itself
|
|
||||||
Complex[] d = convolve(x, x);
|
|
||||||
show(d, "d = convolve(x, x)");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,20 +1,25 @@
|
|||||||
package com.example.ueberwachungssystem.Fragments;
|
package com.example.ueberwachungssystem.Fragments;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Environment;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.VideoView;
|
||||||
|
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
import com.example.ueberwachungssystem.R;
|
import com.example.ueberwachungssystem.R;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
public class Fragment1 extends Fragment {
|
public class Fragment1 extends Fragment {
|
||||||
private String text;
|
private String text;
|
||||||
private final static String KEY_TEXT = "KEY_TEXT";
|
private final static String KEY_TEXT = "KEY_TEXT";
|
||||||
|
|
||||||
private void log(String nachricht) {
|
private void log(String nachricht) {
|
||||||
Log.d(this.getClass().getSimpleName(), nachricht);
|
Log.d(this.getClass().getSimpleName(), nachricht);
|
||||||
}
|
}
|
||||||
@@ -23,7 +28,7 @@ public class Fragment1 extends Fragment {
|
|||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
|
||||||
log("onCreateView");
|
log("onCreateView");
|
||||||
View view = inflater.inflate(R.layout.fragment1, container, false);
|
View view = inflater.inflate(R.layout.fragment1, container, false);
|
||||||
TextView Sensor = (TextView) view.findViewById(R.id.Sensor);
|
TextView Sensor = (TextView) view.findViewById(R.id.Alarm);
|
||||||
Sensor.setText(text);
|
Sensor.setText(text);
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
@@ -36,7 +41,7 @@ public class Fragment1 extends Fragment {
|
|||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle bundle) {
|
public void onCreate(Bundle bundle) {
|
||||||
super .onCreate(bundle);
|
super.onCreate(bundle);
|
||||||
Bundle args = getArguments();
|
Bundle args = getArguments();
|
||||||
if (args != null ) {
|
if (args != null ) {
|
||||||
text = args.getString(KEY_TEXT);
|
text = args.getString(KEY_TEXT);
|
||||||
|
|||||||
@@ -1,18 +1,28 @@
|
|||||||
package com.example.ueberwachungssystem.Fragments;
|
package com.example.ueberwachungssystem.Fragments;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.ListView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
|
import com.example.ueberwachungssystem.MeinAdapter;
|
||||||
import com.example.ueberwachungssystem.R;
|
import com.example.ueberwachungssystem.R;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class Fragment2 extends Fragment {
|
public class Fragment2 extends Fragment {
|
||||||
private String text;
|
private String text;
|
||||||
|
private Context c;
|
||||||
private final static String KEY_TEXT = "KEY_TEXT" ;
|
private final static String KEY_TEXT = "KEY_TEXT" ;
|
||||||
private void log(String nachricht) {
|
private void log(String nachricht) {
|
||||||
Log.d(this.getClass().getSimpleName(), nachricht);
|
Log.d(this.getClass().getSimpleName(), nachricht);
|
||||||
@@ -21,8 +31,8 @@ public class Fragment2 extends Fragment {
|
|||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
|
||||||
log( "onCreateView" );
|
log( "onCreateView" );
|
||||||
View view = inflater.inflate(R.layout.fragment2, container, false );
|
View view = inflater.inflate(R.layout.fragment2, container, false );
|
||||||
TextView Sensor = (TextView) view.findViewById(R.id.Sensor);
|
// TextView Sensor = (TextView) view.findViewById(R.id.Aufzeichnungen);
|
||||||
Sensor.setText(text);
|
// Sensor.setText(text);
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
public static Fragment2 erstellen(String text) {
|
public static Fragment2 erstellen(String text) {
|
||||||
@@ -36,6 +46,9 @@ public class Fragment2 extends Fragment {
|
|||||||
public void onCreate(Bundle bundle) {
|
public void onCreate(Bundle bundle) {
|
||||||
super.onCreate(bundle);
|
super.onCreate(bundle);
|
||||||
Bundle args = getArguments();
|
Bundle args = getArguments();
|
||||||
|
c = getContext();
|
||||||
|
ListView listView = new ListView(c);
|
||||||
|
listView.setAdapter(new MeinAdapter(c, getVideoFiles()));
|
||||||
if (args != null) {
|
if (args != null) {
|
||||||
text = args.getString(KEY_TEXT);
|
text = args.getString(KEY_TEXT);
|
||||||
log("onCreate: text=" + text);
|
log("onCreate: text=" + text);
|
||||||
@@ -43,4 +56,10 @@ public class Fragment2 extends Fragment {
|
|||||||
log("onCreate");
|
log("onCreate");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public List<File> getVideoFiles(){
|
||||||
|
File directory = c.getFilesDir();
|
||||||
|
File[] files = directory.listFiles();
|
||||||
|
assert files != null;
|
||||||
|
return Arrays.asList(files);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -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,9 +1,10 @@
|
|||||||
package com.example.ueberwachungssystem;
|
package com.example.ueberwachungssystem;
|
||||||
|
|
||||||
|
import androidx.camera.core.ExperimentalGetImage;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.fragment.app.FragmentTransaction;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.camera.core.ExperimentalGetImage;
|
|
||||||
import androidx.camera.view.PreviewView;
|
|
||||||
|
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -12,86 +13,130 @@ import android.content.ServiceConnection;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ImageView;
|
import android.widget.Button;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
import android.widget.ToggleButton;
|
import android.widget.ToggleButton;
|
||||||
|
|
||||||
import com.example.ueberwachungssystem.Detection.Accelerometer;
|
import com.example.ueberwachungssystem.Fragments.Fragment1;
|
||||||
import com.example.ueberwachungssystem.Detection.AudioRecorder;
|
import com.example.ueberwachungssystem.Fragments.Fragment2;
|
||||||
import com.example.ueberwachungssystem.Detection.DetectionReport;
|
|
||||||
import com.example.ueberwachungssystem.Detection.Detector;
|
|
||||||
import com.example.ueberwachungssystem.Detection.DetectorService;
|
import com.example.ueberwachungssystem.Detection.DetectorService;
|
||||||
import com.example.ueberwachungssystem.Detection.MicrophoneDetector;
|
|
||||||
import com.example.ueberwachungssystem.Detection.VideoDetector;
|
|
||||||
|
|
||||||
@ExperimentalGetImage
|
@ExperimentalGetImage
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
//Fragmente
|
||||||
|
private Fragment aktuellesFragment;
|
||||||
|
private Fragment1 fragment1;
|
||||||
|
private Fragment2 fragment2;
|
||||||
|
|
||||||
private DetectorService detectorService = new DetectorService();
|
private DetectorService detectorService = new DetectorService();
|
||||||
ImageView inputImageView;
|
int num=0;
|
||||||
ImageView outputImageView;
|
//Textviews
|
||||||
ToggleButton toggleButton;
|
private TextView Auswahl;
|
||||||
|
private TextView AoderA;
|
||||||
|
private String auswahltext = "Wahl des Detektionsmodus";
|
||||||
|
private String auswahlAoderA = "Wahl von Alarmmeldungen oder Auswahl von Alarmaufzeichnungen";
|
||||||
|
//Buttons
|
||||||
|
private ToggleButton toggleKamera;
|
||||||
|
private ToggleButton toggleAudio;
|
||||||
|
private ToggleButton toggleBewegung;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
setTitle(this.getClass().getSimpleName());
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
|
Auswahl = findViewById(R.id.textAuswahl);
|
||||||
|
Auswahl.setText(auswahltext);
|
||||||
|
AoderA = findViewById(R.id.textAoderA);
|
||||||
|
AoderA.setText(auswahlAoderA);
|
||||||
|
toggleKamera = findViewById(R.id.toggleKamera);
|
||||||
|
toggleAudio = findViewById(R.id.toggleAudio);
|
||||||
|
toggleBewegung = findViewById(R.id.toggleBewegung);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
inputImageView = findViewById(R.id.inputImageView);
|
protected void onResume() {
|
||||||
outputImageView = findViewById(R.id.outputImageView);
|
super.onResume();
|
||||||
toggleButton = findViewById(R.id.toggleButton);
|
|
||||||
|
|
||||||
|
|
||||||
PermissionHandler permissionHandler = new PermissionHandler(this);
|
PermissionHandler permissionHandler = new PermissionHandler(this);
|
||||||
permissionHandler.getPermissions();
|
//permissionHandler.getPermissions();
|
||||||
if (permissionHandler.hasPermissions()) {
|
if (permissionHandler.hasPermissions()) {
|
||||||
|
|
||||||
|
|
||||||
Intent serviceIntent = new Intent(this, DetectorService.class);
|
Intent serviceIntent = new Intent(this, DetectorService.class);
|
||||||
bindService(serviceIntent, serviceConnection, Context.BIND_AUTO_CREATE);
|
bindService(serviceIntent, serviceConnection, Context.BIND_AUTO_CREATE);
|
||||||
startService(serviceIntent);
|
startService(serviceIntent);
|
||||||
|
|
||||||
|
toggleKamera.setOnClickListener(new View.OnClickListener() {
|
||||||
toggleButton.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (toggleButton.isChecked())
|
if (toggleKamera.isChecked()) {
|
||||||
{
|
|
||||||
if (detectorService != null){
|
|
||||||
|
|
||||||
detectorService.videoDetector.debugProcessing(inputImageView, outputImageView);
|
} else {
|
||||||
detectorService.videoDetector.startDetection();
|
|
||||||
|
|
||||||
detectorService.audioDetector.startDetection();
|
|
||||||
|
|
||||||
detectorService.motionDetector.startDetection();
|
|
||||||
|
|
||||||
detectorService.audioRecorder.stopRecording();
|
|
||||||
|
|
||||||
detectorService.videoDetector.startRecording();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
detectorService.videoDetector.stopDetection();
|
|
||||||
|
|
||||||
detectorService.audioDetector.stopDetection();
|
|
||||||
|
|
||||||
detectorService.motionDetector.stopDetection();
|
|
||||||
|
|
||||||
detectorService.audioRecorder.stopRecording();
|
|
||||||
|
|
||||||
detectorService.videoDetector.stopRecording();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
toggleAudio.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if (toggleAudio.isChecked()) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
toggleBewegung.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if (toggleBewegung.isChecked()) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}else{
|
||||||
|
Toast.makeText(this,"Bitte Rechte geben", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
getMenuInflater().inflate(R.menu.options_menu, menu);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
Toast.makeText(this, "Selected Item: " + item.getTitle(), Toast.LENGTH_SHORT).show();
|
||||||
|
PopUpClass popUpClass;
|
||||||
|
switch (item.getItemId()) {
|
||||||
|
case R.id.Rechteverwaltung:
|
||||||
|
popUpClass = new PopUpClass(MainActivity.this);
|
||||||
|
popUpClass.showPopupWindow(toggleAudio);
|
||||||
|
popUpClass.RechtePrüfen();
|
||||||
|
return true;
|
||||||
|
case R.id.Sensoren:
|
||||||
|
popUpClass = new PopUpClass(MainActivity.this);
|
||||||
|
popUpClass.showPopupWindow(toggleAudio);
|
||||||
|
popUpClass.Sensoren();
|
||||||
|
return true;
|
||||||
|
case R.id.Impressum:
|
||||||
|
popUpClass = new PopUpClass(MainActivity.this);
|
||||||
|
popUpClass.showPopupWindow(toggleAudio);
|
||||||
|
popUpClass.Impressum();
|
||||||
|
return true;
|
||||||
|
case R.id.Detection:
|
||||||
|
popUpClass = new PopUpClass(MainActivity.this);
|
||||||
|
popUpClass.showPopupWindow(toggleAudio);
|
||||||
|
popUpClass.DetectionTotal(num);
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,15 +145,47 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
public void onServiceConnected(ComponentName name, IBinder service) {
|
public void onServiceConnected(ComponentName name, IBinder service) {
|
||||||
DetectorService.ServiceBinder binder = (DetectorService.ServiceBinder) service;
|
DetectorService.ServiceBinder binder = (DetectorService.ServiceBinder) service;
|
||||||
detectorService = binder.getBoundService();
|
detectorService = binder.getBoundService();
|
||||||
|
// detectorService.videoDetector.debugProcessing(null, outputImageView); //inputImageView
|
||||||
|
|
||||||
detectorService.setOnDetectionListener(new DetectorService.OnDetectionListener() {
|
detectorService.setOnDetectionListener(new DetectorService.OnDetectionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onDetection(@NonNull DetectionReport detectionReport) {
|
public void onDetection(@NonNull StringBuffer stringBuffer) {
|
||||||
Log.d("onDetection", detectionReport.toMessage());
|
Log.d("onDetection", stringBuffer.toString()); //Für oli hier Textview einbauen
|
||||||
|
num++;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void onServiceDisconnected(ComponentName name) {}
|
public void onServiceDisconnected(ComponentName name) {
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public void onClickZeigeFragment1(View view) {
|
||||||
|
Button button = (Button) view;
|
||||||
|
zeigeFragment(fragment1.erstellen("Hier stehen dann die Alarme"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onClickZeigeFragment2(View view) {
|
||||||
|
Button button = (Button) view;
|
||||||
|
zeigeFragment(fragment2.erstellen("Hier stehen dann die Videos"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onClickEntferneFragment(View view) {
|
||||||
|
entferneFragment();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void zeigeFragment(Fragment fragment) {
|
||||||
|
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
||||||
|
ft.replace(R.id.frame, fragment);
|
||||||
|
ft.commit();
|
||||||
|
aktuellesFragment = fragment;
|
||||||
|
}
|
||||||
|
private void entferneFragment() {
|
||||||
|
if (aktuellesFragment != null) {
|
||||||
|
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
||||||
|
ft.remove(aktuellesFragment);
|
||||||
|
ft.commit();
|
||||||
|
aktuellesFragment = null ;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package com.example.ueberwachungssystem;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class MeinAdapter extends ArrayAdapter<File> {
|
||||||
|
private Context context;
|
||||||
|
private File[] files;
|
||||||
|
public MeinAdapter(Context context, List<File> listf) {
|
||||||
|
super(context, android.R.layout.simple_list_item_1, listf);
|
||||||
|
this.context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View getView(final int pos, View cv, ViewGroup vg) {
|
||||||
|
View v = super.getView(pos, cv, vg);
|
||||||
|
v.setOnClickListener( new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
Log.d("DerLog","nicht null");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -35,7 +35,7 @@ public class PermissionRequest extends AppCompatActivity{
|
|||||||
handler.post(new Runnable() {
|
handler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Toast.makeText(mainActivity.getApplicationContext(),"Es werden Rechte benötigt", Toast.LENGTH_LONG).show();
|
Toast.makeText(mainActivity.getApplicationContext(),"Es werden Rechte benötigt", Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ public class PopUpClass {
|
|||||||
PermissionRequest permission;
|
PermissionRequest permission;
|
||||||
TextView PopUpText;
|
TextView PopUpText;
|
||||||
|
|
||||||
|
Button buttonEdit;
|
||||||
|
|
||||||
|
|
||||||
public PopUpClass(MainActivity mainActivity) {
|
public PopUpClass(MainActivity mainActivity) {
|
||||||
this.mainActivity = mainActivity;
|
this.mainActivity = mainActivity;
|
||||||
@@ -47,7 +49,7 @@ public class PopUpClass {
|
|||||||
|
|
||||||
PopUpText = popupView.findViewById(R.id.titleText);
|
PopUpText = popupView.findViewById(R.id.titleText);
|
||||||
|
|
||||||
Button buttonEdit = popupView.findViewById(R.id.RechteAnfordern);
|
buttonEdit = popupView.findViewById(R.id.RechteAnfordern);
|
||||||
buttonEdit.setOnClickListener(new View.OnClickListener() {
|
buttonEdit.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
@@ -70,17 +72,25 @@ public class PopUpClass {
|
|||||||
public void RechtePrüfen(){
|
public void RechtePrüfen(){
|
||||||
StringBuilder Text = permission.rechtePruefen();
|
StringBuilder Text = permission.rechtePruefen();
|
||||||
PopUpText.setText(Text);
|
PopUpText.setText(Text);
|
||||||
|
buttonEdit.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
}
|
}
|
||||||
public void RechteAnfordern(){
|
public void RechteAnfordern(){
|
||||||
permission.rechteAnfordern();
|
permission.rechteAnfordern();
|
||||||
StringBuilder Text = permission.rechtePruefen();
|
StringBuilder Text = permission.rechtePruefen();
|
||||||
PopUpText.setText(Text);
|
PopUpText.setText(Text);
|
||||||
|
|
||||||
}
|
}
|
||||||
public void Sensoren(){
|
public void Sensoren(){
|
||||||
PopUpText.setText("Es können 3 verschiedene Sensoren verwendet werden \n -1. Beschleunigungssensor\n -2. Mikrofon\n -3. Kamera");
|
PopUpText.setText("Es können 3 verschiedene Sensoren verwendet werden \n -1. Beschleunigungssensor\n -2. Mikrofon\n -3. Kamera");
|
||||||
|
buttonEdit.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
public void Impressum(){
|
public void Impressum(){
|
||||||
PopUpText.setText("Die Ueberwachungsapp wurde im Rahmen eines Praktikums der TH-Nürnberg programmiert");
|
PopUpText.setText("Die Ueberwachungsapp wurde im Rahmen eines Praktikums der TH-Nürnberg programmiert");
|
||||||
|
buttonEdit.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
public void DetectionTotal(int num) {
|
||||||
|
PopUpText.setText("Total Detektions:" +num);
|
||||||
|
buttonEdit.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.example.ueberwachungssystem;
|
package com.example.ueberwachungssystem;
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
|
import android.util.Log;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
@@ -30,6 +31,11 @@ public class WifiCommunication {
|
|||||||
private final DatagramSocket socket;
|
private final DatagramSocket socket;
|
||||||
volatile private boolean running;
|
volatile private boolean running;
|
||||||
|
|
||||||
|
private boolean Gruppe =true;
|
||||||
|
private boolean showMessage = true;
|
||||||
|
|
||||||
|
StringBuffer rxStringBuffer = new StringBuffer();
|
||||||
|
|
||||||
private OnConnectionListener listener;
|
private OnConnectionListener listener;
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
public WifiCommunication(int port) {
|
public WifiCommunication(int port) {
|
||||||
@@ -51,20 +57,20 @@ public class WifiCommunication {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public interface OnConnectionListener {
|
public interface OnConnectionListener {
|
||||||
void onConnection(StringBuffer data);
|
void onConnection(String data);
|
||||||
}
|
}
|
||||||
public void setOnConnectionListener(@NonNull OnConnectionListener listener) {
|
public void setOnConnectionListener(@NonNull OnConnectionListener listener) {
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendWifiData(StringBuffer wifiMessage) {
|
public void sendWifiData(String wifiMessage) {
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
listener.onConnection(wifiMessage);
|
listener.onConnection(wifiMessage);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ReceiveThread extends Thread {
|
private class ReceiveThread extends Thread {
|
||||||
private StringBuffer rxStringBuffer = new StringBuffer();
|
|
||||||
private String rxString="";
|
private String rxString="";
|
||||||
private String previousRxString = "";
|
private String previousRxString = "";
|
||||||
|
|
||||||
@@ -77,11 +83,30 @@ public class WifiCommunication {
|
|||||||
socket.receive(rxPacket);
|
socket.receive(rxPacket);
|
||||||
rxString = new String(receiveData, 0, rxPacket.getLength());
|
rxString = new String(receiveData, 0, rxPacket.getLength());
|
||||||
String[] splitrxString = rxString.split(",");
|
String[] splitrxString = rxString.split(",");
|
||||||
if(!previousRxString.equals(rxString) && splitrxString[0].equals("1") && splitrxString.length==7) {
|
String[] splitrxStringBuffer = splitBufferIntoStrings(rxStringBuffer);
|
||||||
rxStringBuffer.append(rxString).append("\n");
|
for(String elem: splitrxStringBuffer){
|
||||||
sendWifiData(rxStringBuffer);
|
if(elem.equals(rxString)){
|
||||||
//mainActivity.runOnUiThread(() -> mainActivity.tvMessages.setText(rxStringBuffer));
|
showMessage = false;
|
||||||
previousRxString = rxString;
|
}else{
|
||||||
|
showMessage = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(Gruppe){
|
||||||
|
if(!previousRxString.equals(rxString) && splitrxString[0].equals("1") && splitrxString.length==7 && showMessage) {
|
||||||
|
rxStringBuffer.append(rxString).append("\n");
|
||||||
|
Log.d("empfangen", rxString);
|
||||||
|
sendWifiData(rxString);
|
||||||
|
//mainActivity.runOnUiThread(() -> mainActivity.tvMessages.setText(rxStringBuffer));
|
||||||
|
previousRxString = rxString;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
if(!previousRxString.equals(rxString) && splitrxString[0].equals("1") && splitrxString.length==7 && showMessage) {
|
||||||
|
rxStringBuffer.append(rxString).append("\n");
|
||||||
|
Log.d("empfangen", rxString);
|
||||||
|
sendWifiData(rxString);
|
||||||
|
//mainActivity.runOnUiThread(() -> mainActivity.tvMessages.setText(rxStringBuffer));
|
||||||
|
previousRxString = rxString;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} while (running);
|
} while (running);
|
||||||
}
|
}
|
||||||
@@ -99,16 +124,17 @@ public class WifiCommunication {
|
|||||||
if(send)
|
if(send)
|
||||||
{
|
{
|
||||||
send = false;
|
send = false;
|
||||||
SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
|
/*SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
|
||||||
Date curDate = new Date(System.currentTimeMillis());
|
Date curDate = new Date(System.currentTimeMillis());
|
||||||
String str = formatter.format(curDate);
|
String str = formatter.format(curDate);*/
|
||||||
byte[] send_Data = new byte[512];
|
byte[] send_Data = new byte[512];
|
||||||
String txString = ("1," +str+ ",Gruppe2," + getLocalIpAddress() + ",An,Video," +messageToSend);
|
String txString = (messageToSend); //"1," +str+ ",Gruppe2," + getLocalIpAddress() + ",An,Video,"
|
||||||
|
Log.d("send", txString);
|
||||||
send_Data = txString.getBytes();
|
send_Data = txString.getBytes();
|
||||||
|
|
||||||
DatagramPacket txPacket = new DatagramPacket(send_Data, txString.length(), address, port);
|
DatagramPacket txPacket = new DatagramPacket(send_Data, txString.length(), address, port);
|
||||||
|
|
||||||
for(int i = 0; i < 300; i++) {
|
for(int i = 0; i < 500; i++) {
|
||||||
socket.send(txPacket);
|
socket.send(txPacket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -143,4 +169,8 @@ public class WifiCommunication {
|
|||||||
running = false;
|
running = false;
|
||||||
socket.close();
|
socket.close();
|
||||||
}
|
}
|
||||||
|
public String[] splitBufferIntoStrings(StringBuffer string){
|
||||||
|
String[] splitrxString2 = string.toString().split("\n");
|
||||||
|
return splitrxString2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:state_checked="false" android:drawable="@color/redbright" />
|
||||||
|
<item android:state_checked="true" android:drawable="@color/greenbright" />
|
||||||
|
</selector>
|
||||||
@@ -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>
|
|
||||||
@@ -1,41 +1,129 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="center"
|
android:background="#010C49"
|
||||||
android:gravity="top"
|
android:visibility="visible"
|
||||||
android:orientation="vertical"
|
tools:context="com.example.ueberwachungssystem.MainActivity"
|
||||||
tools:context=".MainActivity">
|
tools:visibility="visible">
|
||||||
|
|
||||||
|
<TextView
|
||||||
<androidx.camera.view.PreviewView
|
android:id="@+id/textAuswahl"
|
||||||
android:id="@+id/previewView"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:backgroundTint="@android:color/black"/>
|
android:layout_alignParentTop="true"
|
||||||
|
android:layout_alignParentLeft="true"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:textColor="@color/white"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textAoderA"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@+id/toggleAudio"
|
||||||
|
android:layout_alignParentLeft="true"
|
||||||
|
android:layout_marginTop="15dp"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:textColor="@color/white"/>
|
||||||
|
|
||||||
<ToggleButton
|
<ToggleButton
|
||||||
android:id="@+id/toggleButton"
|
android:id="@+id/toggleKamera"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignBottom="@id/toggleAudio"
|
||||||
|
android:layout_marginRight="30dp"
|
||||||
|
android:layout_toLeftOf="@id/toggleAudio"
|
||||||
|
android:textColor="@color/yellow"
|
||||||
|
android:textOn="Kamera an"
|
||||||
|
android:textOff="Kamera aus"
|
||||||
|
android:background="@drawable/toggle_btn"/>
|
||||||
|
|
||||||
|
<ToggleButton
|
||||||
|
android:id="@+id/toggleAudio"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@id/textAuswahl"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
android:textColor="@color/yellow"
|
||||||
|
android:textOn="Audio an"
|
||||||
|
android:textOff="Audio aus"
|
||||||
|
android:background="@drawable/toggle_btn"/>
|
||||||
|
|
||||||
|
<ToggleButton
|
||||||
|
android:id="@+id/toggleBewegung"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignBottom="@id/toggleAudio"
|
||||||
|
android:layout_marginLeft="30dp"
|
||||||
|
android:layout_toEndOf="@+id/toggleAudio"
|
||||||
|
android:layout_toRightOf="@id/toggleAudio"
|
||||||
|
android:textColor="@color/yellow"
|
||||||
|
android:textOn="Bewegung an"
|
||||||
|
android:textOff="Bewegung aus"
|
||||||
|
android:background="@drawable/toggle_btn"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btnAlarme"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignBottom="@+id/btnAufnahmen"
|
||||||
|
android:layout_toLeftOf="@id/btnAufnahmen"
|
||||||
|
android:layout_marginRight="15dp"
|
||||||
|
android:theme="@style/Button.Green"
|
||||||
|
android:onClick="onClickZeigeFragment1"
|
||||||
|
android:text="Alarme" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btnAufnahmen"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@+id/textAoderA"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_marginTop="15dp"
|
||||||
|
android:theme="@style/Button.Green"
|
||||||
|
android:onClick="onClickZeigeFragment2"
|
||||||
|
android:text="Aufnahmen" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btnAnzeigeVerb"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignBottom="@+id/btnAufnahmen"
|
||||||
|
android:layout_toRightOf="@id/btnAufnahmen"
|
||||||
|
android:layout_marginLeft="15dp"
|
||||||
|
android:text="Anzeige verbergen"
|
||||||
|
android:onClick="onClickEntferneFragment"/>
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/frame"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:text="ToggleButton" />
|
android:layout_below="@+id/btnAufnahmen"
|
||||||
|
android:layout_marginTop="25dp"
|
||||||
|
android:layout_alignParentStart="true"
|
||||||
|
android:background="@color/white">
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
<ImageView
|
<!--
|
||||||
android:id="@+id/inputImageView"
|
<ScrollView
|
||||||
android:layout_width="wrap_content"
|
android:id="@+id/scrollView1"
|
||||||
android:layout_height="wrap_content"
|
android:layout_width="match_parent"
|
||||||
tools:srcCompat="@tools:sample/avatars" />
|
android:layout_height="match_parent"
|
||||||
|
android:layout_below="@id/btnAufnahmen"
|
||||||
|
android:layout_marginTop="25dp">
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical" >
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/Alarm"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@color/red"/>
|
||||||
|
</LinearLayout>
|
||||||
|
</ScrollView>
|
||||||
|
-->
|
||||||
|
|
||||||
<ImageView
|
</RelativeLayout>
|
||||||
android:id="@+id/outputImageView"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
tools:srcCompat="@tools:sample/avatars" />
|
|
||||||
|
|
||||||
<androidx.camera.view.PreviewView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
@@ -4,19 +4,23 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:background="@android:color/holo_green_light">
|
android:background="@color/bluedark">
|
||||||
|
|
||||||
<TextView
|
<ScrollView
|
||||||
android:id="@+id/Sensor"
|
android:id="@+id/scrollView1"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"/>
|
android:layout_marginTop="25dp">
|
||||||
|
<LinearLayout
|
||||||
<TextView
|
android:layout_width="match_parent"
|
||||||
android:id="@+id/Alarm"
|
android:layout_height="match_parent"
|
||||||
android:layout_width="wrap_content"
|
android:orientation="vertical" >
|
||||||
android:layout_height="wrap_content"
|
<TextView
|
||||||
android:layout_below="@id/Sensor"
|
android:id="@+id/Alarm"
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"/>
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textColor="@color/yellow"/>
|
||||||
|
</LinearLayout>
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
@@ -6,17 +6,28 @@
|
|||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:background="@android:color/holo_blue_light" >
|
android:background="@android:color/holo_blue_light" >
|
||||||
|
|
||||||
<TextView
|
<ScrollView
|
||||||
android:id="@+id/Sensor"
|
android:id="@+id/scrollView2"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="250dp"
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"/>
|
android:layout_marginTop="25dp">
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical" >
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/Aufzeichnungen"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textColor="@color/yellow"/>
|
||||||
|
</LinearLayout>
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
<TextView
|
<VideoView
|
||||||
android:id="@+id/Alarm"
|
android:id="@+id/AusAuf"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@id/Sensor"
|
android:layout_below="@id/scrollView2"
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"/>
|
android:textAppearance="?android:attr/textAppearanceLarge"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</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>
|
|
||||||
@@ -4,6 +4,8 @@
|
|||||||
android:title="Rechteverwaltung" />
|
android:title="Rechteverwaltung" />
|
||||||
<item android:id="@+id/Sensoren"
|
<item android:id="@+id/Sensoren"
|
||||||
android:title="Sensoren" />
|
android:title="Sensoren" />
|
||||||
|
<item android:id="@+id/Detection"
|
||||||
|
android:title="Detektionen" />
|
||||||
<item android:id="@+id/Impressum"
|
<item android:id="@+id/Impressum"
|
||||||
android:title="Impressum" />
|
android:title="Impressum" />
|
||||||
</menu>
|
</menu>
|
||||||
@@ -7,4 +7,9 @@
|
|||||||
<color name="teal_700">#FF018786</color>
|
<color name="teal_700">#FF018786</color>
|
||||||
<color name="black">#FF000000</color>
|
<color name="black">#FF000000</color>
|
||||||
<color name="white">#FFFFFFFF</color>
|
<color name="white">#FFFFFFFF</color>
|
||||||
|
<color name="red">#5C0000</color>
|
||||||
|
<color name="redbright">#EF3434</color>
|
||||||
|
<color name="greenbright">#469733</color>
|
||||||
|
<color name="bluedark">#053C8E</color>
|
||||||
|
<color name="yellow">#FFEB3B</color>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -13,4 +13,9 @@
|
|||||||
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
|
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
|
||||||
<!-- Customize your theme here. -->
|
<!-- Customize your theme here. -->
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="Button.Green" parent="ThemeOverlay.AppCompat">
|
||||||
|
<item name="colorAccent">#0F3E01</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
Reference in new issue
Block a user