Compare commits
11
Commits
ccdff78a4a
..
Kamera
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
07a7a273a5 | ||
|
|
72527f9797 | ||
|
|
7f41e4a555 | ||
|
|
840d323317 | ||
|
|
6154414f12 | ||
|
|
de8d4c06aa | ||
|
|
94b763f676 | ||
|
|
abe79b1efe | ||
|
|
d06a1dd9b3 | ||
|
|
3a251ae72c | ||
|
|
0b1eaee31d |
No files matched your search
@@ -25,6 +25,7 @@ android {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
namespace 'com.example.greenwatch'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -35,4 +36,10 @@ dependencies {
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
|
||||
|
||||
def camerax_version = "1.2.3"
|
||||
implementation "androidx.camera:camera-camera2:${camerax_version}"
|
||||
implementation "androidx.camera:camera-lifecycle:${camerax_version}"
|
||||
implementation "androidx.camera:camera-view:${camerax_version}"
|
||||
|
||||
}
|
||||
@@ -1,6 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.example.greenwatch">
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
|
||||
<uses-permission android:name="android.permission.CAMERA"/>
|
||||
<uses-permission android:name="android.permission.BLUETOOTH"/>
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
|
||||
<uses-feature android:name="android.hardware.camera"/>
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
@@ -9,24 +18,6 @@
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.GreenWatch">
|
||||
<activity
|
||||
android:name=".ConnectionActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".VideodetectionAndAccelerometerActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".AudiodetectionAndAccelerometerActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".VideodetectionActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".AudiodetectionActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".AccelerometerActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true">
|
||||
@@ -36,6 +27,10 @@
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity android:name=".KameraAktivitaet" />
|
||||
<activity android:name=".Kamera_Beschleunigungssensor" />
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -1,137 +0,0 @@
|
||||
package com.example.greenwatch;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import android.hardware.Sensor;
|
||||
import android.hardware.SensorEvent;
|
||||
import android.hardware.SensorEventListener;
|
||||
import android.hardware.SensorManager;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.greenwatch.models.Device;
|
||||
import com.example.greenwatch.viewmodels.AccelerometerViewModel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class AccelerometerActivity extends AppCompatActivity implements SensorEventListener {
|
||||
|
||||
private SensorManager accelerometerManager;
|
||||
private Sensor accelerometerSensor;
|
||||
private TextView accelerometerStatusMessage;
|
||||
private TextView accelerometerDataTV;
|
||||
private TextView accelerometerWarningTV;
|
||||
private Button backToMainActivityButton;
|
||||
private AccelerometerViewModel mAccelerometerViewModel;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_accelerometer);
|
||||
|
||||
accelerometerStatusMessage = (TextView) findViewById(R.id.tvAccelerometerStatusmessage);
|
||||
accelerometerDataTV = (TextView) findViewById(R.id.tvAccelerometerData);
|
||||
accelerometerWarningTV = (TextView) findViewById(R.id.tvAccelerometerWarning);
|
||||
backToMainActivityButton = (Button) findViewById(R.id.accelerometerBackToMainActivity);
|
||||
|
||||
backToMainActivityButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
mAccelerometerViewModel = new ViewModelProvider(this).get(AccelerometerViewModel.class);
|
||||
mAccelerometerViewModel.init();
|
||||
mAccelerometerViewModel.getConnectedDeviceList().observe(this, new Observer<List<Device>>() {
|
||||
@Override
|
||||
public void onChanged(List<Device> devices) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Time Stamp: ");
|
||||
sb.append(mAccelerometerViewModel.getTimeStamp(mAccelerometerViewModel.getLocalDeviceUUID()));
|
||||
sb.append(";\n");
|
||||
sb.append("DeviceID: ");
|
||||
sb.append(mAccelerometerViewModel.getDeviceID(mAccelerometerViewModel.getLocalDeviceUUID()));
|
||||
sb.append(";\n");
|
||||
sb.append("Sensor Status: ");
|
||||
sb.append(mAccelerometerViewModel.getSensorStatus(mAccelerometerViewModel.getLocalDeviceUUID()));
|
||||
sb.append(";\n");
|
||||
sb.append("Sensor Type: ");
|
||||
sb.append(mAccelerometerViewModel.getSensorType(mAccelerometerViewModel.getLocalDeviceUUID()));
|
||||
sb.append(";\n");
|
||||
sb.append("Sensor Massage: ");
|
||||
sb.append(mAccelerometerViewModel.getSensorMassage(mAccelerometerViewModel.getLocalDeviceUUID()));
|
||||
accelerometerStatusMessage.setText(sb);
|
||||
Toast.makeText(AccelerometerActivity.this, "onChanged", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
|
||||
mAccelerometerViewModel.getMovementDetectedValue().observe(this, new Observer<Boolean>() {
|
||||
@Override
|
||||
public void onChanged(Boolean aBoolean) {
|
||||
if (aBoolean) {
|
||||
mAccelerometerViewModel.setDevice(mAccelerometerViewModel.getLocalDeviceUUID(), mAccelerometerViewModel.getSystemTimeStamp(), mAccelerometerViewModel.getLocalDeviceUUID(), true, "Accelerometer", 10);
|
||||
}
|
||||
else {
|
||||
mAccelerometerViewModel.setDevice(mAccelerometerViewModel.getLocalDeviceUUID(), mAccelerometerViewModel.getSystemTimeStamp(), mAccelerometerViewModel.getLocalDeviceUUID(), false, "Accelerometer", 0);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
accelerometerManager = (SensorManager) getSystemService(SENSOR_SERVICE);
|
||||
if (accelerometerManager.getSensorList(Sensor.TYPE_GYROSCOPE).size() == 0) {
|
||||
accelerometerSensor = null;
|
||||
Toast.makeText(AccelerometerActivity.this, "No accelerometer sensor available", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
else {
|
||||
accelerometerSensor = accelerometerManager.getSensorList(Sensor.TYPE_GYROSCOPE).get(0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSensorChanged(SensorEvent event) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("x=")
|
||||
.append(event.values[0])
|
||||
.append("\ny=")
|
||||
.append(event.values[1])
|
||||
.append("\nz=")
|
||||
.append(event.values[2]);
|
||||
accelerometerDataTV.setText(sb.toString());
|
||||
mAccelerometerViewModel.addValueToGesamtBE(event.values[0] + event.values[1] + event.values[2]);
|
||||
mAccelerometerViewModel.meanValueCalculation();
|
||||
mAccelerometerViewModel.calibrateAccelerometerSensor();
|
||||
mAccelerometerViewModel.checkAlarmCondition();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAccuracyChanged(Sensor sensor, int accuracy) {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
if (accelerometerSensor != null) {
|
||||
if (accelerometerManager.registerListener(this, accelerometerSensor, SensorManager.SENSOR_DELAY_GAME)) {
|
||||
Toast.makeText(AccelerometerActivity.this, "We registered to the sensor", Toast.LENGTH_LONG).show();
|
||||
} else {
|
||||
Toast.makeText(AccelerometerActivity.this, "Registration did not work", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
if (accelerometerSensor != null) {
|
||||
accelerometerManager.unregisterListener(this, accelerometerSensor);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.example.greenwatch;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
|
||||
public class AudiodetectionActivity extends AppCompatActivity {
|
||||
|
||||
private Button backToMainActivityButton;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_audiodetection);
|
||||
|
||||
backToMainActivityButton = (Button) findViewById(R.id.audiodetectorBackToMainActivity);
|
||||
|
||||
backToMainActivityButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.example.greenwatch;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
|
||||
public class AudiodetectionAndAccelerometerActivity extends AppCompatActivity {
|
||||
|
||||
private Button backToMainActivity;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_audiodetection_and_accelerometer);
|
||||
|
||||
backToMainActivity = (Button) findViewById(R.id.audiodetectionAndAccelerometerBackToMainActivity);
|
||||
|
||||
backToMainActivity.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.example.greenwatch;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
|
||||
public class ConnectionActivity extends AppCompatActivity {
|
||||
|
||||
private Button backToMainActivity;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_connection);
|
||||
|
||||
backToMainActivity = (Button) findViewById(R.id.connectionBackToMainActivity);
|
||||
|
||||
backToMainActivity.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
package com.example.greenwatch;
|
||||
|
||||
public class Kamera {
|
||||
}
|
||||
@@ -0,0 +1,205 @@
|
||||
package com.example.greenwatch;
|
||||
|
||||
import android.graphics.ImageFormat;
|
||||
import android.media.Image;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.util.Size;
|
||||
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.camera.core.CameraSelector;
|
||||
import androidx.camera.core.ImageAnalysis;
|
||||
import androidx.camera.lifecycle.ProcessCameraProvider;
|
||||
// PREVIEW
|
||||
//import androidx.camera.view.PreviewView;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
public class KameraAktivitaet extends AppCompatActivity {
|
||||
|
||||
// PREVIEW
|
||||
// private PreviewView previewView;
|
||||
private boolean isMotionDetected;
|
||||
private boolean camera_alarm = false;
|
||||
private TextView alarm;
|
||||
|
||||
// Bildverarbeitung Variablen
|
||||
private ByteBuffer previousBuffer;
|
||||
private int previousWidth;
|
||||
private int previousHeight;
|
||||
private final int threshold = 50;
|
||||
private int startX;
|
||||
private int startY;
|
||||
private int endX;
|
||||
private int endY;
|
||||
|
||||
private static final long ALARM_RESET_DELAY = 5000;
|
||||
private Runnable alarmResetRunnable;
|
||||
private final Handler alarmResetHandler = new Handler();
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
// NUR FÜR TESTS
|
||||
alarm = findViewById(R.id.textView);
|
||||
|
||||
// previewView = findViewById(R.id.previewView);
|
||||
|
||||
final ListenableFuture<ProcessCameraProvider> cameraProviderFuture = ProcessCameraProvider.getInstance(this);
|
||||
cameraProviderFuture.addListener(() -> {
|
||||
try {
|
||||
bindImageAnalysis(cameraProviderFuture.get());
|
||||
} catch (ExecutionException | InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}, ContextCompat.getMainExecutor(this));
|
||||
}
|
||||
|
||||
private void bindImageAnalysis(ProcessCameraProvider cameraProvider) {
|
||||
ImageAnalysis.Builder builder = new ImageAnalysis.Builder();
|
||||
builder.setTargetResolution(new Size(640, 480));
|
||||
builder.setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST);
|
||||
ImageAnalysis imageAnalysis = builder.build();
|
||||
imageAnalysis.setAnalyzer(
|
||||
ContextCompat.getMainExecutor(this),
|
||||
imageProxy -> {
|
||||
|
||||
int imageFormat = imageProxy.getFormat();
|
||||
|
||||
if (imageFormat == ImageFormat.YUV_420_888) {
|
||||
|
||||
Image currentImage = imageProxy.getImage();
|
||||
|
||||
if (previousHeight != 0) {
|
||||
assert currentImage != null;
|
||||
isMotionDetected = compareFrames(currentImage);
|
||||
}
|
||||
|
||||
assert currentImage != null;
|
||||
Image.Plane[] planes = currentImage.getPlanes();
|
||||
ByteBuffer buffer = planes[0].getBuffer().duplicate();
|
||||
previousBuffer = ByteBuffer.allocateDirect(buffer.remaining());
|
||||
previousBuffer.put(buffer);
|
||||
previousWidth = currentImage.getWidth();
|
||||
previousHeight = currentImage.getHeight();
|
||||
|
||||
currentImage.close();
|
||||
|
||||
if (isMotionDetected) {
|
||||
|
||||
alarm.setText("ALARM");
|
||||
camera_alarm = true;
|
||||
|
||||
if(alarmResetRunnable != null) {
|
||||
alarmResetHandler.removeCallbacks(alarmResetRunnable);
|
||||
}
|
||||
|
||||
alarmResetRunnable = this::resetAlarmStatus;
|
||||
alarmResetHandler.postDelayed(alarmResetRunnable, ALARM_RESET_DELAY);
|
||||
}
|
||||
}
|
||||
|
||||
imageProxy.close();
|
||||
});
|
||||
|
||||
// Preview preview = new Preview.Builder().build();
|
||||
|
||||
CameraSelector cameraSelector = new CameraSelector.Builder().requireLensFacing(CameraSelector.LENS_FACING_BACK).build();
|
||||
|
||||
// PREVIEW //
|
||||
// preview.setSurfaceProvider(previewView.getSurfaceProvider());
|
||||
|
||||
cameraProvider.bindToLifecycle(this, cameraSelector, imageAnalysis);
|
||||
|
||||
}
|
||||
|
||||
// Bildverarbeitung zur Bewegungserkennung
|
||||
private boolean compareFrames(Image currentImage) {
|
||||
Image.Plane[] planes = currentImage.getPlanes();
|
||||
ByteBuffer currentBuffer = planes[0].getBuffer();
|
||||
int currentWidth = currentImage.getWidth();
|
||||
int currentHeight = currentImage.getHeight();
|
||||
int yRowStride = planes[0].getRowStride();
|
||||
int yPixelStride = planes[0].getPixelStride();
|
||||
|
||||
|
||||
//System.out.println("Höhe: " + currentHeight + " Breite: " + currentWidth);
|
||||
|
||||
if (previousWidth != currentWidth || previousHeight != currentHeight) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Blöcke weiter verkleinern
|
||||
int blockSize = kleinstesQuadrat(previousHeight, previousWidth) / 8;
|
||||
|
||||
//System.out.println(blockSize);
|
||||
|
||||
int numBlocksX = currentWidth / blockSize;
|
||||
int numBlocksY = currentHeight / blockSize;
|
||||
|
||||
for (int blockY = 0; blockY < numBlocksY; blockY++) {
|
||||
for (int blockX = 0; blockX < numBlocksX; blockX++) {
|
||||
startX = blockX * blockSize;
|
||||
startY = blockY * blockSize;
|
||||
endX = startX + blockSize;
|
||||
endY = startY + blockSize;
|
||||
|
||||
float currentLuminance = berechneMittlereLuminanz(currentBuffer, yRowStride, yPixelStride);
|
||||
float previousLuminance = berechneMittlereLuminanz(previousBuffer, yRowStride, yPixelStride);
|
||||
|
||||
int pixelDifference = Math.abs((int) previousLuminance - (int) currentLuminance);
|
||||
|
||||
//System.out.println(pixelDifference);
|
||||
|
||||
if (pixelDifference > threshold) {
|
||||
System.out.println(pixelDifference);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private float berechneMittlereLuminanz(ByteBuffer buffer, int rowStride, int pixelStride) {
|
||||
int sumLuminance = 0;
|
||||
int countPixels = 0;
|
||||
|
||||
for (int row = startY; row < endY; row++) {
|
||||
for (int col = startX; col < endX; col++) {
|
||||
int bufferIndex = row * rowStride + col * pixelStride;
|
||||
int currentPixel = buffer.get(bufferIndex) & 0xFF;
|
||||
|
||||
sumLuminance += currentPixel;
|
||||
countPixels++;
|
||||
}
|
||||
}
|
||||
|
||||
return (float) sumLuminance / countPixels;
|
||||
}
|
||||
|
||||
private int kleinstesQuadrat(int height, int width) {
|
||||
if (height == width) {
|
||||
return height;
|
||||
} else if (height > width) {
|
||||
return kleinstesQuadrat(height - width, width);
|
||||
} else {
|
||||
return kleinstesQuadrat(height, width - height);
|
||||
}
|
||||
}
|
||||
|
||||
private void resetAlarmStatus() {
|
||||
camera_alarm = false;
|
||||
alarm.setText("OK");
|
||||
alarmResetRunnable = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,320 @@
|
||||
package com.example.greenwatch;
|
||||
|
||||
import android.graphics.ImageFormat;
|
||||
import android.hardware.Sensor;
|
||||
import android.hardware.SensorEvent;
|
||||
import android.hardware.SensorEventListener;
|
||||
import android.hardware.SensorManager;
|
||||
import android.media.Image;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
import android.os.Looper;
|
||||
import android.util.Size;
|
||||
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.camera.core.CameraSelector;
|
||||
import androidx.camera.core.ImageAnalysis;
|
||||
import androidx.camera.lifecycle.ProcessCameraProvider;
|
||||
// PREVIEW
|
||||
//import androidx.camera.view.PreviewView;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
public class Kamera_Beschleunigungssensor extends AppCompatActivity implements SensorEventListener {
|
||||
|
||||
private HandlerThread cameraThread;
|
||||
private Handler cameraHandler;
|
||||
// PREVIEW
|
||||
// private PreviewView previewView;
|
||||
private boolean isMotionDetected;
|
||||
private boolean camera_alarm;
|
||||
private TextView alarm;
|
||||
private ByteBuffer previousBuffer;
|
||||
private int previousWidth;
|
||||
private int previousHeight;
|
||||
|
||||
/////////////////////////////////////
|
||||
|
||||
private SensorManager bsmanager;
|
||||
private ArrayList<Float> Gesamt_be;
|
||||
private int sensorType = Sensor.TYPE_GYROSCOPE, zaehler_runde =0, listen_groesse = 500, kalibrieren, Offset_shared = 0, shared_merk, mittelwertsumme_shared;
|
||||
private Sensor sens, sensor_l;
|
||||
private float x_value = 0, y_value, z_value, Vorbesetzung = 0, gesamt_runde =0;
|
||||
private double Schwellwert = 0.15, mittelwertsumme = 0.0, Offset = 0.1;
|
||||
String Daten, Warnung, Zeitstempel, Array_shared;
|
||||
private final static String KEY_kalibirieren = "KEY_KALIBRIEREN_"+Beschleunigungssensor.class.getSimpleName();
|
||||
private final static String KEY_Gesamt_be = "KEY_GESAMT_BE_"+Beschleunigungssensor.class.getSimpleName();
|
||||
private final static String KEY_Offset = "KEY_OFFSET_"+Beschleunigungssensor.class.getSimpleName();
|
||||
private final static String KEY_Mittelwertsumme = "KEY_MITTELWERTSUMME_"+Beschleunigungssensor.class.getSimpleName();
|
||||
TextView Daten_Bsensor, Warnung_Bsensor, test;
|
||||
private boolean toggle = true, ts_setzen = true, start_messen;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_beschleunigung_kamera);
|
||||
////////
|
||||
Daten_Bsensor = (TextView) findViewById(R.id.DatenBsensor);
|
||||
Warnung_Bsensor = (TextView) findViewById(R.id.WarnungBsensor);
|
||||
test = (TextView) findViewById(R.id.test);
|
||||
|
||||
bsmanager = (SensorManager) getSystemService(SENSOR_SERVICE);
|
||||
if (bsmanager.getSensorList(Sensor.TYPE_GYROSCOPE).size() == 0) {
|
||||
sens = null;
|
||||
Daten = "kein B Sensor voranden";
|
||||
} else {
|
||||
sens = bsmanager.getSensorList(sensorType).get(0);
|
||||
}
|
||||
Gesamt_be = new ArrayList<Float>();
|
||||
for (int i = 0; i < listen_groesse ; i++){
|
||||
Gesamt_be.add(Vorbesetzung);
|
||||
}
|
||||
kalibrieren = 0;
|
||||
start_messen = false;
|
||||
|
||||
///////
|
||||
// NUR FÜR TESTS
|
||||
alarm = findViewById(R.id.Alarm_Kamera);
|
||||
|
||||
// PREVIEW //
|
||||
// previewView = findViewById(R.id.previewView);
|
||||
|
||||
final ListenableFuture<ProcessCameraProvider> cameraProviderFuture = ProcessCameraProvider.getInstance(this);
|
||||
cameraProviderFuture.addListener(() -> {
|
||||
try {
|
||||
bindImageAnalysis(cameraProviderFuture.get());
|
||||
} catch (ExecutionException | InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}, ContextCompat.getMainExecutor(this));
|
||||
}
|
||||
|
||||
public static String getTimestamp(){
|
||||
Long tslong = System.currentTimeMillis();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
|
||||
Date date = new Date(tslong);
|
||||
String result = sdf.format(date);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSensorChanged(SensorEvent event) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("x=").append(event.values[0])//.append(event.timestamp)
|
||||
.append("\ny=").append(event.values[1])
|
||||
.append("\nz=").append(event.values[2]);
|
||||
Daten = sb.toString();
|
||||
Daten_Bsensor.setText(Daten);
|
||||
gesamt_runde = event.values[0] + event.values[1] + event.values[2];
|
||||
Gesamt_be.remove(zaehler_runde);
|
||||
Gesamt_be.add(zaehler_runde, gesamt_runde);
|
||||
mittelwertsumme = 0.0;
|
||||
|
||||
//Mittelwert des Arrays berechnen
|
||||
for (int i = 0; i < listen_groesse; i++){
|
||||
if (Gesamt_be.get(i) < 0){
|
||||
mittelwertsumme += (Gesamt_be.get(i) * (-1));
|
||||
}else {
|
||||
mittelwertsumme += Gesamt_be.get(i);
|
||||
}
|
||||
}
|
||||
mittelwertsumme = mittelwertsumme/listen_groesse;
|
||||
if (kalibrieren < listen_groesse){
|
||||
Offset = mittelwertsumme;
|
||||
kalibrieren++;
|
||||
}else {
|
||||
start_messen = true;
|
||||
}
|
||||
StringBuilder testsb = new StringBuilder();
|
||||
testsb.append(mittelwertsumme);
|
||||
String tests = testsb.toString();
|
||||
test.setText(tests);
|
||||
|
||||
if((mittelwertsumme > (Schwellwert+Offset) ) & (ts_setzen == true) &(start_messen == true)){
|
||||
Zeitstempel = getTimestamp();
|
||||
StringBuilder ts = new StringBuilder();
|
||||
ts.append(Zeitstempel)
|
||||
.append(", Gruppe3")
|
||||
.append(", An")
|
||||
.append(", Bewegung, ")
|
||||
.append(mittelwertsumme);
|
||||
Warnung = ts.toString();
|
||||
Warnung_Bsensor.setText(Warnung);
|
||||
ts_setzen = false;
|
||||
}else if((mittelwertsumme > (Schwellwert+Offset)) & (ts_setzen == false)){
|
||||
} else if ((mittelwertsumme < (Schwellwert+Offset)) & (ts_setzen == false)) {
|
||||
Warnung_Bsensor.setText("");
|
||||
ts_setzen = true;
|
||||
}
|
||||
|
||||
if (zaehler_runde < (listen_groesse -1)){
|
||||
zaehler_runde++;
|
||||
}else {
|
||||
zaehler_runde = 0;
|
||||
}
|
||||
}
|
||||
//mittelwertsumme ist kein int in diesem programm
|
||||
//shared prefenrences: bei Kippen speichern -> nochmal neu klalibrieren? -> eig ja, weil neuer Standort
|
||||
//Vorbelegung nicht nochmal neu vornehmen -> aus onCreate Funktion raus -> hilfsvariablen auch in shared preferences speichern
|
||||
@Override
|
||||
public void onAccuracyChanged(Sensor sensor, int accuracy) {}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
if (sens != null) {
|
||||
if (bsmanager.registerListener(this, sens, SensorManager.SENSOR_DELAY_GAME)) {
|
||||
Daten = "Wir haben uns beim Sensor angemeldet";
|
||||
} else {
|
||||
Daten = "Das anmelden hat nicht geklappt";
|
||||
}
|
||||
}
|
||||
//SharedPreferences p = getPreferences(Context.MODE_PRIVATE);
|
||||
//mittelwertsumme_shared = p.getInt(KEY_Mittelwertsumme, 0);
|
||||
//kalibrieren = p.getInt(KEY_kalibirieren, 0);
|
||||
//Offset_shared = p.getInt(KEY_Offset, 0 );
|
||||
//Array_shared = p.getString(KEY_Gesamt_be, "");
|
||||
|
||||
//mittelwertsumme = (double) mittelwertsumme_shared;
|
||||
//mittelwertsumme /= 1000000.0;
|
||||
|
||||
//Offset = (double) Offset_shared;
|
||||
//Offset /= 1000000.0;
|
||||
|
||||
//String zw[] = Array_shared.split(";", listen_groesse);
|
||||
|
||||
//if(shared_merk == 2){
|
||||
//for (int i=0; i<listen_groesse; i++){
|
||||
//float wert = Float.valueOf(zw[i]);
|
||||
//Gesamt_be.add(i, wert);
|
||||
//}}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onPause () {
|
||||
super.onPause();
|
||||
if (sens != null) {
|
||||
bsmanager.unregisterListener(this, sens);
|
||||
}
|
||||
//shared_merk = 2;
|
||||
// Offset_shared = (int) (Offset * 1000000.0);
|
||||
//mittelwertsumme_shared = (int) (mittelwertsumme * 1000000.0);
|
||||
|
||||
//StringBuilder ar = new StringBuilder();
|
||||
//for (int z=0; z < listen_groesse; z++){
|
||||
//ar.append(Gesamt_be.get(z)).append(";");
|
||||
//}
|
||||
//Array_shared = ar.toString();
|
||||
|
||||
//SharedPreferences p = getPreferences(Context.MODE_PRIVATE);
|
||||
//SharedPreferences.Editor editor = p.edit();
|
||||
//editor.putInt(KEY_Mittelwertsumme, mittelwertsumme_shared);
|
||||
//editor.putInt(KEY_kalibirieren, kalibrieren);
|
||||
//editor.putInt(KEY_Offset, Offset_shared);
|
||||
//editor.putString(KEY_Gesamt_be, Array_shared);
|
||||
//editor.commit();
|
||||
}
|
||||
|
||||
// KAMERA //
|
||||
private void bindImageAnalysis(ProcessCameraProvider cameraProvider) {
|
||||
ImageAnalysis.Builder builder = new ImageAnalysis.Builder();
|
||||
builder.setTargetResolution(new Size(640, 480));
|
||||
builder.setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST);
|
||||
ImageAnalysis imageAnalysis = builder.build();
|
||||
imageAnalysis.setAnalyzer(
|
||||
ContextCompat.getMainExecutor(this),
|
||||
imageProxy -> {
|
||||
|
||||
int imageFormat = imageProxy.getFormat();
|
||||
|
||||
if (imageFormat == ImageFormat.YUV_420_888) {
|
||||
|
||||
Image currentImage = imageProxy.getImage();
|
||||
|
||||
if (previousHeight != 0) {
|
||||
assert currentImage != null;
|
||||
isMotionDetected = compareFrames(currentImage);
|
||||
}
|
||||
|
||||
assert currentImage != null;
|
||||
Image.Plane[] planes = currentImage.getPlanes();
|
||||
ByteBuffer buffer = planes[0].getBuffer().duplicate();
|
||||
previousBuffer = ByteBuffer.allocateDirect(buffer.remaining());
|
||||
previousBuffer.put(buffer);
|
||||
previousWidth = currentImage.getWidth();
|
||||
previousHeight = currentImage.getHeight();
|
||||
|
||||
currentImage.close();
|
||||
|
||||
if (isMotionDetected) {
|
||||
alarm.setText("ALARM");
|
||||
camera_alarm = true;
|
||||
} else {
|
||||
camera_alarm = false;
|
||||
alarm.setText("OK");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
imageProxy.close();
|
||||
});
|
||||
|
||||
// Preview preview = new Preview.Builder().build();
|
||||
|
||||
CameraSelector cameraSelector = new CameraSelector.Builder().requireLensFacing(CameraSelector.LENS_FACING_BACK).build();
|
||||
|
||||
// PREVIEW //
|
||||
// preview.setSurfaceProvider(previewView.getSurfaceProvider());
|
||||
|
||||
cameraProvider.bindToLifecycle(this, cameraSelector, imageAnalysis);
|
||||
|
||||
}
|
||||
|
||||
// Bildverarbeitung zur Bewegungserkennung
|
||||
private boolean compareFrames(Image currentImage) {
|
||||
|
||||
ByteBuffer currentBuffer = currentImage.getPlanes()[0].getBuffer();
|
||||
|
||||
int currentWidth = currentImage.getWidth();
|
||||
int currentHeight = currentImage.getHeight();
|
||||
|
||||
if (previousWidth != currentWidth || previousHeight != currentHeight) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int row = 0; row < previousHeight; row++) {
|
||||
for (int col = 0; col < previousWidth; col++) {
|
||||
|
||||
int previousIndex = row * previousWidth + col;
|
||||
int currentIndex = row * currentWidth + col;
|
||||
|
||||
int previousPixel = previousBuffer.get(previousIndex) & 0xFF;
|
||||
int currentPixel = currentBuffer.get(currentIndex) & 0xFF;
|
||||
|
||||
int pixelDifference = Math.abs(previousPixel - currentPixel);
|
||||
int threshold = 120;
|
||||
|
||||
if (pixelDifference > threshold) {
|
||||
// Testzwecke
|
||||
//String text = String.valueOf(pixelDifference);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,138 +1,40 @@
|
||||
package com.example.greenwatch;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.greenwatch.models.Device;
|
||||
import com.example.greenwatch.viewmodels.MainActivityViewModel;
|
||||
|
||||
import java.util.List;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
private TextView tvstatusmessage;
|
||||
private Button audiodetectionButton;
|
||||
private Button videodetectionButton;
|
||||
private Button accelerometerButton;
|
||||
private Button audiodetectionAndAccelerometerButton;
|
||||
private Button videodetectionAndAccelerometerButton;
|
||||
private Button connectionButton;
|
||||
private MainActivityViewModel mMainActivityViewModel;
|
||||
private static final int RECHTEANFORDERUNG_KAMERA = 10;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
tvstatusmessage = (TextView) findViewById(R.id.tvStatusmessage);
|
||||
audiodetectionButton = (Button) findViewById(R.id.audiodetectionButton);
|
||||
videodetectionButton = (Button) findViewById(R.id.videodetectionButton);
|
||||
accelerometerButton = (Button) findViewById(R.id.accelerometerButton);
|
||||
audiodetectionAndAccelerometerButton = (Button) findViewById(R.id.audiodetectionAndAccelerometerButton);
|
||||
videodetectionAndAccelerometerButton = (Button) findViewById(R.id.videodetectionAndAccelerometerButton);
|
||||
connectionButton = (Button) findViewById(R.id.connectionButton);
|
||||
|
||||
mMainActivityViewModel = new ViewModelProvider(this).get(MainActivityViewModel.class);
|
||||
mMainActivityViewModel.init();
|
||||
mMainActivityViewModel.getConnectedDeviceList().observe(this, new Observer<List<Device>>() {
|
||||
@Override
|
||||
public void onChanged(List<Device> devices) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Time Stamp: ");
|
||||
sb.append(mMainActivityViewModel.getTimeStamp(mMainActivityViewModel.getLocalDeviceUUID()));
|
||||
sb.append(";\n");
|
||||
sb.append("DeviceID: ");
|
||||
sb.append(mMainActivityViewModel.getDeviceID(mMainActivityViewModel.getLocalDeviceUUID()));
|
||||
sb.append(";\n");
|
||||
sb.append("Sensor Status: ");
|
||||
sb.append(mMainActivityViewModel.getSensorStatus(mMainActivityViewModel.getLocalDeviceUUID()));
|
||||
sb.append(";\n");
|
||||
sb.append("Sensor Type: ");
|
||||
sb.append(mMainActivityViewModel.getSensorType(mMainActivityViewModel.getLocalDeviceUUID()));
|
||||
sb.append(";\n");
|
||||
sb.append("Sensor Massage: ");
|
||||
sb.append(mMainActivityViewModel.getSensorMassage(mMainActivityViewModel.getLocalDeviceUUID()));
|
||||
tvstatusmessage.setText(sb);
|
||||
Toast.makeText(MainActivity.this, "onChanged", Toast.LENGTH_LONG).show();
|
||||
Button kameraStarten = findViewById(R.id.button_camera);
|
||||
kameraStarten.setOnClickListener(v -> {
|
||||
if (istZugriffAufKameraErlaubt()) {
|
||||
starteKameraAktivitaet();
|
||||
} else {
|
||||
zugriffAufKameraAnfordern();
|
||||
}
|
||||
});
|
||||
|
||||
audiodetectionButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
//openAudiodetectionActivity();
|
||||
mMainActivityViewModel.setDevice(mMainActivityViewModel.getLocalDeviceUUID(), "10:51", "12345", false, "Audio", 10);
|
||||
}
|
||||
});
|
||||
videodetectionButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
//openVideodetectionActivity();
|
||||
mMainActivityViewModel.setSensorType(mMainActivityViewModel.getLocalDeviceUUID(), "Video");
|
||||
mMainActivityViewModel.setTimeStamp(mMainActivityViewModel.getLocalDeviceUUID(), "12:50");
|
||||
mMainActivityViewModel.setDeviceID(mMainActivityViewModel.getLocalDeviceUUID(), mMainActivityViewModel.getLocalDeviceUUID());
|
||||
}
|
||||
});
|
||||
accelerometerButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
openAccelerometerActivity();
|
||||
mMainActivityViewModel.setSensorType(mMainActivityViewModel.getLocalDeviceUUID(), "Accelerometer");
|
||||
}
|
||||
});
|
||||
audiodetectionAndAccelerometerButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
//openAudiodetectionAndAccelerometerActivity();
|
||||
mMainActivityViewModel.setSensorType(mMainActivityViewModel.getLocalDeviceUUID(), "AudiodetectionAndAccelerometer");
|
||||
mMainActivityViewModel.setTimeStamp(mMainActivityViewModel.getLocalDeviceUUID(), "00:00");
|
||||
mMainActivityViewModel.setDeviceID(mMainActivityViewModel.getLocalDeviceUUID(), "6789");
|
||||
}
|
||||
});
|
||||
videodetectionAndAccelerometerButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
openVideodetectionAndAccelerometerActivity();
|
||||
}
|
||||
});
|
||||
connectionButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
openConnectionActivity();
|
||||
}
|
||||
});
|
||||
}
|
||||
public void openAudiodetectionActivity(){
|
||||
Intent intent = new Intent(this, AudiodetectionActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
public void openVideodetectionActivity(){
|
||||
Intent intent = new Intent(this, VideodetectionActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
public void openAccelerometerActivity(){
|
||||
Intent intent = new Intent(this, AccelerometerActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
public void openAudiodetectionAndAccelerometerActivity(){
|
||||
Intent intent = new Intent(this, AudiodetectionAndAccelerometerActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
public void openVideodetectionAndAccelerometerActivity(){
|
||||
Intent intent = new Intent(this, VideodetectionAndAccelerometerActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
public void openConnectionActivity(){
|
||||
Intent intent = new Intent(this, ConnectionActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
private boolean istZugriffAufKameraErlaubt() {
|
||||
return ContextCompat.checkSelfPermission(this, android.Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED;
|
||||
}
|
||||
|
||||
private void zugriffAufKameraAnfordern() {
|
||||
ActivityCompat.requestPermissions(this,new String[]{android.Manifest.permission.CAMERA}, RECHTEANFORDERUNG_KAMERA);
|
||||
}
|
||||
|
||||
private void starteKameraAktivitaet() {
|
||||
startActivity(new Intent(this, KameraAktivitaet.class));
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.example.greenwatch;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
|
||||
public class VideodetectionActivity extends AppCompatActivity {
|
||||
|
||||
private Button backToMainActivity;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_videodetection);
|
||||
|
||||
backToMainActivity = (Button) findViewById(R.id.videodetectorBackToMainActivity);
|
||||
|
||||
backToMainActivity.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.example.greenwatch;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
|
||||
public class VideodetectionAndAccelerometerActivity extends AppCompatActivity {
|
||||
|
||||
private Button backToMainActivity;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_videodetection_and_accelerometer);
|
||||
|
||||
backToMainActivity = (Button) findViewById(R.id.videodetectionAndAccelerometerBackToMainActivity);
|
||||
|
||||
backToMainActivity.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
package com.example.greenwatch.models;
|
||||
|
||||
|
||||
public class Device {
|
||||
|
||||
private String timeStamp;
|
||||
private String deviceID;
|
||||
private boolean sensorStatus;
|
||||
private String sensorType;
|
||||
private int sensorMassage;
|
||||
|
||||
public Device(String timeStamp, String deviceID, boolean sensorStatus, String sensorType, int sensorMassage) {
|
||||
this.timeStamp = timeStamp;
|
||||
this.deviceID = deviceID;
|
||||
this.sensorStatus = sensorStatus;
|
||||
this.sensorType = sensorType;
|
||||
this.sensorMassage = sensorMassage;
|
||||
}
|
||||
public void setTimeStamp(String timeStamp) {
|
||||
this.timeStamp = timeStamp;
|
||||
}
|
||||
|
||||
public String getTimeStamp() {
|
||||
return timeStamp;
|
||||
}
|
||||
|
||||
public void setDeviceID(String deviceID) {
|
||||
this.deviceID = deviceID;
|
||||
}
|
||||
|
||||
public String getDeviceID() {
|
||||
return deviceID;
|
||||
}
|
||||
public void setSensorType(String sensorType) {
|
||||
this.sensorType = sensorType;
|
||||
}
|
||||
|
||||
public String getSensorType() {
|
||||
return sensorType;
|
||||
}
|
||||
|
||||
public void setSensorStatus(boolean sensorStatus) {
|
||||
this.sensorStatus = sensorStatus;
|
||||
}
|
||||
|
||||
public Boolean getSensorStatus() {
|
||||
return sensorStatus;
|
||||
}
|
||||
|
||||
public void setSensorMassage(int sensorMassage) {
|
||||
this.sensorMassage = sensorMassage;
|
||||
}
|
||||
|
||||
public int getSensorMassage() {
|
||||
return sensorMassage;
|
||||
}
|
||||
}
|
||||
@@ -1,216 +0,0 @@
|
||||
package com.example.greenwatch.repositories;
|
||||
|
||||
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
import com.example.greenwatch.models.Device;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class DeviceRepository {
|
||||
|
||||
private String delimiter = ", ";
|
||||
private String deviceUUID;
|
||||
private static DeviceRepository deviceRepositoryInstance;
|
||||
private MutableLiveData<List<Device>> deviceList = new MutableLiveData<>();
|
||||
private HashMap<String, Device> connectedDevicesList = new HashMap<>();
|
||||
private HashMap<String, String> deviceIDMapper = new HashMap<>();
|
||||
|
||||
public static synchronized DeviceRepository getInstance() {
|
||||
if (deviceRepositoryInstance == null){
|
||||
deviceRepositoryInstance = new DeviceRepository();
|
||||
deviceRepositoryInstance.setDeviceUUID();
|
||||
}
|
||||
return deviceRepositoryInstance;
|
||||
}
|
||||
|
||||
public MutableLiveData<List<Device>> getConnectedDeviceList() {
|
||||
setMutableLiveDataValue();
|
||||
return deviceList;
|
||||
}
|
||||
|
||||
public void createNewDevice(String timeStamp, String deviceID, boolean sensorStatus, String sensorType, int sensorMassage){
|
||||
Device newDevice = new Device(timeStamp, deviceID, sensorStatus, sensorType, sensorMassage);
|
||||
addToConnectedDeviceList(newDevice.getDeviceID(), newDevice);
|
||||
setMutableLiveDataValue();
|
||||
}
|
||||
|
||||
public void createNewRemoteDevice(String message) {
|
||||
String[] messageString = messageStringSplitter(message);
|
||||
String timeStamp = messageString[0];
|
||||
String deviceID = messageString[1];
|
||||
boolean sensorStatus = Boolean.valueOf(messageString[1]);
|
||||
String sensorType = messageString[3];
|
||||
int sensorMassage = Integer.valueOf(messageString[4]);
|
||||
|
||||
if(!connectedDevicesList.containsKey(deviceID)) {
|
||||
createNewDevice(timeStamp, deviceID, sensorStatus, sensorType, sensorMassage);
|
||||
}
|
||||
}
|
||||
|
||||
public String messageStringBuilder(String deviceID) {
|
||||
StringBuilder message = new StringBuilder();
|
||||
Device device = connectedDevicesList.get(deviceID);
|
||||
if(device != null) {
|
||||
message.append(device.getTimeStamp())
|
||||
.append(delimiter)
|
||||
.append(device.getDeviceID())
|
||||
.append(delimiter)
|
||||
.append(device.getSensorStatus())
|
||||
.append(delimiter)
|
||||
.append(device.getSensorType())
|
||||
.append(delimiter)
|
||||
.append(device.getSensorMassage());
|
||||
return message.toString();
|
||||
}
|
||||
return message.toString();
|
||||
}
|
||||
|
||||
public String getLocalDeviceUUID() {
|
||||
return deviceUUID;
|
||||
}
|
||||
|
||||
public void setDevice(String deviceID, String timeStamp, String newDeviceID, boolean sensorStatus, String sensorType, int sensorMassage) {
|
||||
String checkedDeviceID = checkDeviceID(deviceID);
|
||||
Device device = connectedDevicesList.get(checkedDeviceID);
|
||||
if(device != null) {
|
||||
device.setTimeStamp(timeStamp);
|
||||
device.setDeviceID(newDeviceID);
|
||||
device.setSensorStatus(sensorStatus);
|
||||
device.setSensorType(sensorType);
|
||||
device.setSensorMassage(sensorMassage);
|
||||
setDeviceIDMapper(newDeviceID);
|
||||
connectedDevicesList.remove(checkedDeviceID);
|
||||
addToConnectedDeviceList(newDeviceID, device);
|
||||
setMutableLiveDataValue();
|
||||
}
|
||||
}
|
||||
|
||||
public void setTimeStamp(String deviceID, String timeStamp) {
|
||||
String checkedDeviceID = checkDeviceID(deviceID);
|
||||
Device device = connectedDevicesList.get(checkedDeviceID);
|
||||
if(device != null) {
|
||||
device.setTimeStamp(timeStamp);
|
||||
addToConnectedDeviceList(checkedDeviceID, device);
|
||||
setMutableLiveDataValue();
|
||||
}
|
||||
}
|
||||
|
||||
public String getTimeStamp(String deviceID) {
|
||||
String checkedDeviceID = checkDeviceID(deviceID);
|
||||
Device device = connectedDevicesList.get(checkedDeviceID);
|
||||
if(device != null) {
|
||||
return device.getTimeStamp();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public void setDeviceID(String deviceID, String newDeviceID) {
|
||||
String checkedDeviceID = checkDeviceID(deviceID);
|
||||
Device device = connectedDevicesList.get(checkedDeviceID);
|
||||
if(device != null) {
|
||||
device.setDeviceID(newDeviceID);
|
||||
setDeviceIDMapper(newDeviceID);
|
||||
connectedDevicesList.remove(checkedDeviceID);
|
||||
addToConnectedDeviceList(newDeviceID, device);
|
||||
setMutableLiveDataValue();
|
||||
}
|
||||
}
|
||||
|
||||
public String getDeviceID(String deviceID) {
|
||||
String checkedDeviceID = checkDeviceID(deviceID);
|
||||
Device device = connectedDevicesList.get(checkedDeviceID);
|
||||
if(device != null) {
|
||||
return device.getDeviceID();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public void setSensorStatus(String deviceID, boolean sensorStatus) {
|
||||
String checkedDeviceID = checkDeviceID(deviceID);
|
||||
Device device = connectedDevicesList.get(checkedDeviceID);
|
||||
if(device != null) {
|
||||
device.setSensorStatus(sensorStatus);
|
||||
addToConnectedDeviceList(checkedDeviceID, device);
|
||||
setMutableLiveDataValue();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getSensorStatus(String deviceID) {
|
||||
String checkedDeviceID = checkDeviceID(deviceID);
|
||||
Device device = connectedDevicesList.get(checkedDeviceID);
|
||||
if(device != null) {
|
||||
return device.getSensorStatus();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setSensorType(String deviceID, String sensorType) {
|
||||
String checkedDeviceID = checkDeviceID(deviceID);
|
||||
Device device = connectedDevicesList.get(checkedDeviceID);
|
||||
if(device != null) {
|
||||
device.setSensorType(sensorType);
|
||||
addToConnectedDeviceList(checkedDeviceID, device);
|
||||
setMutableLiveDataValue();
|
||||
}
|
||||
}
|
||||
|
||||
public String getSensorType(String deviceID) {
|
||||
String checkedDeviceID = checkDeviceID(deviceID);
|
||||
Device device = connectedDevicesList.get(checkedDeviceID);
|
||||
if(device != null) {
|
||||
return device.getSensorType();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public void setSensorMassage(String deviceID, int sensorMessage) {
|
||||
String checkedDeviceID = checkDeviceID(deviceID);
|
||||
Device device = connectedDevicesList.get(checkedDeviceID);
|
||||
if(device != null) {
|
||||
device.setSensorMassage(sensorMessage);
|
||||
addToConnectedDeviceList(checkedDeviceID, device);
|
||||
setMutableLiveDataValue();
|
||||
}
|
||||
}
|
||||
|
||||
public int getSensorMassage(String deviceID) {
|
||||
String checkedDeviceID = checkDeviceID(deviceID);
|
||||
Device device = connectedDevicesList.get(checkedDeviceID);
|
||||
if(device != null) {
|
||||
return device.getSensorMassage();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private void setMutableLiveDataValue() {
|
||||
List<Device> list = new ArrayList<>(connectedDevicesList.values());
|
||||
deviceList.setValue(list);
|
||||
}
|
||||
|
||||
private void addToConnectedDeviceList(String key, Device device) {
|
||||
connectedDevicesList.put(key, device);
|
||||
}
|
||||
|
||||
private String checkDeviceID(String deviceID) {
|
||||
if(!deviceIDMapper.isEmpty() && deviceID.equals(deviceUUID)) {
|
||||
return deviceIDMapper.get(deviceID);
|
||||
}
|
||||
return deviceID;
|
||||
}
|
||||
|
||||
private void setDeviceIDMapper(String deviceID) {
|
||||
deviceIDMapper.put(deviceUUID, deviceID);
|
||||
}
|
||||
|
||||
private void setDeviceUUID(){
|
||||
this.deviceUUID = UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
private String[] messageStringSplitter(String message) {
|
||||
return message.split(delimiter);
|
||||
}
|
||||
}
|
||||
@@ -1,143 +0,0 @@
|
||||
package com.example.greenwatch.viewmodels;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
import com.example.greenwatch.models.Device;
|
||||
import com.example.greenwatch.repositories.DeviceRepository;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class AccelerometerViewModel extends ViewModel {
|
||||
|
||||
private MutableLiveData<List<Device>> mDeviceList;
|
||||
private MutableLiveData<Boolean> mMovementDetected = new MutableLiveData<>();
|
||||
private DeviceRepository mDeviceRepository;
|
||||
private ArrayList<Float> Gesamt_be;
|
||||
int arraySize = 500;
|
||||
int functionCallCount;
|
||||
float meanValue;
|
||||
float offsetValue;
|
||||
float thresholdValue;
|
||||
boolean startMeasuring;
|
||||
|
||||
public void init() {
|
||||
if (mDeviceList == null) {
|
||||
mDeviceRepository = DeviceRepository.getInstance();
|
||||
mDeviceList = mDeviceRepository.getConnectedDeviceList();
|
||||
}
|
||||
initGesamtBE();
|
||||
mMovementDetected.setValue(false);
|
||||
functionCallCount = 0;
|
||||
meanValue = 0f;
|
||||
offsetValue = 0.1f;
|
||||
thresholdValue = 0.15f;
|
||||
startMeasuring = false;
|
||||
}
|
||||
|
||||
public void initGesamtBE() {
|
||||
Gesamt_be = new ArrayList<>(arraySize);
|
||||
for (int i = 0; i < arraySize; i++) {
|
||||
Gesamt_be.add(0f);
|
||||
}
|
||||
}
|
||||
|
||||
public void addValueToGesamtBE(float newValue) {
|
||||
if (Gesamt_be.size() == arraySize) {
|
||||
Gesamt_be.remove(Gesamt_be.size() -1);
|
||||
}
|
||||
Gesamt_be.add(0, newValue);
|
||||
functionCallCount++;
|
||||
}
|
||||
|
||||
public void meanValueCalculation() {
|
||||
for (float element : Gesamt_be) {
|
||||
meanValue += Math.abs(element);
|
||||
}
|
||||
meanValue = meanValue/arraySize;
|
||||
}
|
||||
|
||||
public void calibrateAccelerometerSensor() {
|
||||
if (functionCallCount <= arraySize) {
|
||||
offsetValue = meanValue;
|
||||
}
|
||||
else {
|
||||
startMeasuring = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void checkAlarmCondition() {
|
||||
if (meanValue > (thresholdValue + offsetValue) && startMeasuring && !mMovementDetected.getValue()) {
|
||||
mMovementDetected.setValue(true);
|
||||
}
|
||||
else if (meanValue < (thresholdValue + offsetValue) && mMovementDetected.getValue()){
|
||||
mMovementDetected.setValue(false);
|
||||
}
|
||||
}
|
||||
|
||||
public String getSystemTimeStamp() {
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
|
||||
Date date = new Date(System.currentTimeMillis());
|
||||
return formatter.format(date);
|
||||
}
|
||||
|
||||
public LiveData<Boolean> getMovementDetectedValue() {
|
||||
return mMovementDetected;
|
||||
}
|
||||
|
||||
public LiveData<List<Device>> getConnectedDeviceList() {
|
||||
return mDeviceList;
|
||||
}
|
||||
|
||||
public void setDevice(String deviceID, String timeStamp, String newDeviceID, boolean sensorStatus, String sensorType, int sensorMassage) {
|
||||
mDeviceRepository.setDevice(deviceID, timeStamp,newDeviceID, sensorStatus, sensorType, sensorMassage);
|
||||
}
|
||||
|
||||
public void setTimeStamp(String deviceID, String timeStamp) {
|
||||
mDeviceRepository.setTimeStamp(deviceID, timeStamp);
|
||||
}
|
||||
|
||||
public String getTimeStamp(String deviceID) {
|
||||
return mDeviceRepository.getTimeStamp(deviceID);
|
||||
}
|
||||
|
||||
public void setDeviceID(String deviceID, String newDeviceID) {
|
||||
mDeviceRepository.setDeviceID(deviceID, newDeviceID);
|
||||
}
|
||||
|
||||
public String getDeviceID(String deviceID) {
|
||||
return mDeviceRepository.getDeviceID(deviceID);
|
||||
}
|
||||
|
||||
public void setSensorStatus(String deviceID, boolean sensorStatus) {
|
||||
mDeviceRepository.setSensorStatus(deviceID, sensorStatus);
|
||||
}
|
||||
|
||||
public boolean getSensorStatus(String deviceID) {
|
||||
return mDeviceRepository.getSensorStatus(deviceID);
|
||||
}
|
||||
|
||||
public void setSensorType(String deviceID, String sensorType) {
|
||||
mDeviceRepository.setSensorType(deviceID, sensorType);
|
||||
}
|
||||
|
||||
public String getSensorType(String deviceID) {
|
||||
return mDeviceRepository.getSensorType(deviceID);
|
||||
}
|
||||
|
||||
public void setSensorMassage(String deviceID, int sensorMessage) {
|
||||
mDeviceRepository.setSensorMassage(deviceID, sensorMessage);
|
||||
}
|
||||
|
||||
public int getSensorMassage(String deviceID) {
|
||||
return mDeviceRepository.getSensorMassage(deviceID);
|
||||
}
|
||||
|
||||
public String getLocalDeviceUUID() {
|
||||
return mDeviceRepository.getLocalDeviceUUID();
|
||||
}
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
package com.example.greenwatch.viewmodels;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
import com.example.greenwatch.models.Device;
|
||||
import com.example.greenwatch.repositories.DeviceRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MainActivityViewModel extends ViewModel {
|
||||
|
||||
private MutableLiveData<List<Device>> mDeviceList;
|
||||
private DeviceRepository mDeviceRepository;
|
||||
|
||||
public void init() {
|
||||
if(mDeviceList != null) {
|
||||
return;
|
||||
}
|
||||
mDeviceRepository = DeviceRepository.getInstance();
|
||||
mDeviceRepository.createNewDevice("", mDeviceRepository.getLocalDeviceUUID(), false, "", 0);
|
||||
mDeviceList = mDeviceRepository.getConnectedDeviceList();
|
||||
}
|
||||
|
||||
public LiveData<List<Device>> getConnectedDeviceList() {
|
||||
return mDeviceList;
|
||||
}
|
||||
|
||||
public void setDevice(String deviceID, String timeStamp, String newDeviceID, boolean sensorStatus, String sensorType, int sensorMassage) {
|
||||
mDeviceRepository.setDevice(deviceID, timeStamp,newDeviceID, sensorStatus, sensorType, sensorMassage);
|
||||
}
|
||||
|
||||
public void setTimeStamp(String deviceID, String timeStamp) {
|
||||
mDeviceRepository.setTimeStamp(deviceID, timeStamp);
|
||||
}
|
||||
|
||||
public String getTimeStamp(String deviceID) {
|
||||
return mDeviceRepository.getTimeStamp(deviceID);
|
||||
}
|
||||
|
||||
public void setDeviceID(String deviceID, String newDeviceID) {
|
||||
mDeviceRepository.setDeviceID(deviceID, newDeviceID);
|
||||
}
|
||||
|
||||
public String getDeviceID(String deviceID) {
|
||||
return mDeviceRepository.getDeviceID(deviceID);
|
||||
}
|
||||
|
||||
public void setSensorStatus(String deviceID, boolean sensorStatus) {
|
||||
mDeviceRepository.setSensorStatus(deviceID, sensorStatus);
|
||||
}
|
||||
|
||||
public boolean getSensorStatus(String deviceID) {
|
||||
return mDeviceRepository.getSensorStatus(deviceID);
|
||||
}
|
||||
|
||||
public void setSensorType(String deviceID, String sensorType) {
|
||||
mDeviceRepository.setSensorType(deviceID, sensorType);
|
||||
}
|
||||
|
||||
public String getSensorType(String deviceID) {
|
||||
return mDeviceRepository.getSensorType(deviceID);
|
||||
}
|
||||
|
||||
public void setSensorMassage(String deviceID, int sensorMessage) {
|
||||
mDeviceRepository.setSensorMassage(deviceID, sensorMessage);
|
||||
}
|
||||
|
||||
public int getSensorMassage(String deviceID) {
|
||||
return mDeviceRepository.getSensorMassage(deviceID);
|
||||
}
|
||||
|
||||
public String getLocalDeviceUUID() {
|
||||
return mDeviceRepository.getLocalDeviceUUID();
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout 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"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:padding="10dp"
|
||||
tools:context=".AccelerometerActivity">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvAccelerometerStatusmessage"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="">
|
||||
</TextView>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvAccelerometerData"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="">
|
||||
</TextView>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvAccelerometerWarning"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="">
|
||||
</TextView>
|
||||
|
||||
<Button
|
||||
android:id="@+id/accelerometerBackToMainActivity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Back to MainActivity">
|
||||
</Button>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -1,25 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout 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"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:padding="10dp"
|
||||
tools:context=".AudiodetectionActivity">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvAudiodetectionStatusmessage"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Audiodetection Activity">
|
||||
</TextView>
|
||||
|
||||
<Button
|
||||
android:id="@+id/audiodetectorBackToMainActivity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Back to MainActivity">
|
||||
</Button>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -1,25 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout 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"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:padding="10dp"
|
||||
tools:context=".AudiodetectionAndAccelerometerActivity">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvAudiodetectionAndAccelerometerStatusmessage"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Audiodetection + Accelerometer Activity">
|
||||
</TextView>
|
||||
|
||||
<Button
|
||||
android:id="@+id/audiodetectionAndAccelerometerBackToMainActivity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Back to MainActivity">
|
||||
</Button>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout 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"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".Beschleunigungssensor">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/DatenBsensor"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/WarnungBsensor"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/test"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/Alarm_Kamera"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="OK" />
|
||||
</LinearLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -1,25 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout 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"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:padding="10dp"
|
||||
tools:context=".ConnectionActivity">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvConnectionStatusmessage"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Connection Activity">
|
||||
</TextView>
|
||||
|
||||
<Button
|
||||
android:id="@+id/connectionBackToMainActivity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Back to MainActivity">
|
||||
</Button>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -0,0 +1,54 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout 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"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".KameraAktivitaet">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/erklaerung">
|
||||
|
||||
<Button
|
||||
android:id="@+id/button2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Button" />
|
||||
|
||||
<androidx.camera.view.PreviewView
|
||||
android:id="@+id/previewView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
</androidx.camera.view.PreviewView>
|
||||
</FrameLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/alarm"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:text=""
|
||||
android:textSize="100sp"
|
||||
android:textColor="#9999ff"/>
|
||||
<TextView
|
||||
android:id="@+id/threshold_test"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:text=""
|
||||
android:textSize="100sp"
|
||||
android:textColor="#9999ff"/>
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -1,75 +1,44 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout 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"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:padding="10dp"
|
||||
tools:context=".MainActivity">
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_camera"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Kamera starten"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.129"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.931" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvStatusmessage"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:text="Hello World!"
|
||||
android:layout_weight="1">
|
||||
</TextView>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:layout_weight="1">
|
||||
android:id="@+id/textView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text=" "
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.498"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.247" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/audiodetectionButton"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="Audiodetection">
|
||||
</Button>
|
||||
<TextView
|
||||
android:id="@+id/textView2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="TextView"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/textView" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/videodetectionButton"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="Videodetection">
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
android:id="@+id/accelerometerButton"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="Accelerometer">
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
android:id="@+id/audiodetectionAndAccelerometerButton"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="Audiodetection + Accelerometer">
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
android:id="@+id/videodetectionAndAccelerometerButton"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="Videodetection + Accelerometer">
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
android:id="@+id/connectionButton"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="Connect to Devices">
|
||||
</Button>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -1,25 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout 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"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:padding="10dp"
|
||||
tools:context=".VideodetectionActivity">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvVideodetectionStatusmessage"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Videodetection Activity">
|
||||
</TextView>
|
||||
|
||||
<Button
|
||||
android:id="@+id/videodetectorBackToMainActivity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Back to MainActivity">
|
||||
</Button>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -1,25 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout 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"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:padding="10dp"
|
||||
tools:context=".VideodetectionAndAccelerometerActivity">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvVideodetectionAndAccelerometerStatusmessage"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Videodetection + Accelerometer Activity">
|
||||
</TextView>
|
||||
|
||||
<Button
|
||||
android:id="@+id/videodetectionAndAccelerometerBackToMainActivity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Back to MainActivity">
|
||||
</Button>
|
||||
|
||||
</LinearLayout>
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
plugins {
|
||||
id 'com.android.application' version '7.1.3' apply false
|
||||
id 'com.android.library' version '7.1.3' apply false
|
||||
id 'com.android.application' version '8.0.0' apply false
|
||||
id 'com.android.library' version '8.0.0' apply false
|
||||
}
|
||||
|
||||
task clean(type: Delete) {
|
||||
|
||||
+3
-1
@@ -18,4 +18,6 @@ android.useAndroidX=true
|
||||
# Enables namespacing of each library's R class so that its R class includes only the
|
||||
# resources declared in the library itself and none from the library's dependencies,
|
||||
# thereby reducing the size of the R class for that library
|
||||
android.nonTransitiveRClass=true
|
||||
android.nonTransitiveRClass=true
|
||||
android.defaults.buildfeatures.buildconfig=true
|
||||
android.nonFinalResIds=false
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#Thu May 11 14:50:16 CEST 2023
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
|
||||
distributionPath=wrapper/dists
|
||||
zipStorePath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
Reference in new issue
Block a user