|
|
|
|
|
|
|
|
import androidx.camera.core.ExperimentalGetImage; |
|
|
import androidx.camera.core.ExperimentalGetImage; |
|
|
import androidx.camera.view.PreviewView; |
|
|
import androidx.camera.view.PreviewView; |
|
|
|
|
|
|
|
|
|
|
|
import android.content.ComponentName; |
|
|
|
|
|
import android.content.Context; |
|
|
|
|
|
import android.content.Intent; |
|
|
|
|
|
import android.content.ServiceConnection; |
|
|
import android.os.Bundle; |
|
|
import android.os.Bundle; |
|
|
|
|
|
import android.os.IBinder; |
|
|
import android.util.Log; |
|
|
import android.util.Log; |
|
|
import android.view.View; |
|
|
import android.view.View; |
|
|
import android.widget.ImageView; |
|
|
import android.widget.ImageView; |
|
|
|
|
|
|
|
|
import com.example.ueberwachungssystem.Detection.AudioRecorder; |
|
|
import com.example.ueberwachungssystem.Detection.AudioRecorder; |
|
|
import com.example.ueberwachungssystem.Detection.DetectionReport; |
|
|
import com.example.ueberwachungssystem.Detection.DetectionReport; |
|
|
import com.example.ueberwachungssystem.Detection.Detector; |
|
|
import com.example.ueberwachungssystem.Detection.Detector; |
|
|
|
|
|
import com.example.ueberwachungssystem.Detection.DetectorService; |
|
|
import com.example.ueberwachungssystem.Detection.MicrophoneDetector; |
|
|
import com.example.ueberwachungssystem.Detection.MicrophoneDetector; |
|
|
import com.example.ueberwachungssystem.Detection.VideoDetector; |
|
|
import com.example.ueberwachungssystem.Detection.VideoDetector; |
|
|
|
|
|
|
|
|
@ExperimentalGetImage |
|
|
@ExperimentalGetImage |
|
|
public class MainActivity extends AppCompatActivity { |
|
|
public class MainActivity extends AppCompatActivity { |
|
|
|
|
|
|
|
|
|
|
|
private DetectorService detectorService = new DetectorService(); |
|
|
|
|
|
ImageView inputImageView; |
|
|
|
|
|
ImageView outputImageView; |
|
|
|
|
|
ToggleButton toggleButton; |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
protected void onCreate(Bundle savedInstanceState) { |
|
|
protected void onCreate(Bundle savedInstanceState) { |
|
|
super.onCreate(savedInstanceState); |
|
|
super.onCreate(savedInstanceState); |
|
|
setContentView(R.layout.activity_main); |
|
|
setContentView(R.layout.activity_main); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ImageView inputImageView = findViewById(R.id.inputImageView); |
|
|
|
|
|
ImageView outputImageView = findViewById(R.id.outputImageView); |
|
|
|
|
|
PreviewView previewView = findViewById(R.id.previewView); |
|
|
|
|
|
|
|
|
inputImageView = findViewById(R.id.inputImageView); |
|
|
|
|
|
outputImageView = findViewById(R.id.outputImageView); |
|
|
|
|
|
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()) { |
|
|
AudioRecorder audioRecorder = new AudioRecorder(this); |
|
|
|
|
|
|
|
|
|
|
|
VideoDetector vd = new VideoDetector(this); |
|
|
|
|
|
//vd.debugProcessing(inputImageView, outputImageView); |
|
|
|
|
|
vd.setOnDetectionListener(new Detector.OnDetectionListener() { |
|
|
|
|
|
@Override |
|
|
|
|
|
public void onDetection(@NonNull DetectionReport detectionReport) { |
|
|
|
|
|
Log.d("onDetection", detectionReport.toString()); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
MicrophoneDetector microphoneDetector = new MicrophoneDetector(this); |
|
|
|
|
|
microphoneDetector.setOnDetectionListener(new Detector.OnDetectionListener() { |
|
|
|
|
|
@Override |
|
|
|
|
|
public void onDetection(@NonNull DetectionReport detectionReport) { |
|
|
|
|
|
Log.d("onDetection", detectionReport.toString()); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
Accelerometer accelerometer = new Accelerometer(this); |
|
|
|
|
|
accelerometer.getSensor(); |
|
|
|
|
|
accelerometer.setOnDetectionListener(new Detector.OnDetectionListener() { |
|
|
|
|
|
@Override |
|
|
|
|
|
public void onDetection(@NonNull DetectionReport detectionReport) { |
|
|
|
|
|
Log.d("onDetection", detectionReport.toString()); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
Intent serviceIntent = new Intent(this, DetectorService.class); |
|
|
|
|
|
bindService(serviceIntent, serviceConnection, Context.BIND_AUTO_CREATE); |
|
|
|
|
|
startService(serviceIntent); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ToggleButton toggleButton = findViewById(R.id.toggleButton); |
|
|
|
|
|
toggleButton.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 (toggleButton.isChecked()) |
|
|
{ |
|
|
{ |
|
|
//vd.startDetection(); |
|
|
|
|
|
//vd.stopDetection(); |
|
|
|
|
|
vd.startDetection(); |
|
|
|
|
|
microphoneDetector.startDetection(); |
|
|
|
|
|
accelerometer.startDetection(); |
|
|
|
|
|
|
|
|
|
|
|
vd.startRecording(); |
|
|
|
|
|
audioRecorder.startRecording(); |
|
|
|
|
|
|
|
|
if (detectorService != null){ |
|
|
|
|
|
|
|
|
|
|
|
detectorService.debugVideoProcessing(inputImageView, outputImageView); |
|
|
|
|
|
detectorService.startVideoDetection(); |
|
|
|
|
|
detectorService.startAudioDetection(); |
|
|
|
|
|
detectorService.startMotionDetection(); |
|
|
|
|
|
detectorService.startVideoRecording(); |
|
|
|
|
|
detectorService.startAudioRecording(); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
//vd.stopDetection(); |
|
|
|
|
|
vd.stopRecording(); |
|
|
|
|
|
audioRecorder.stopRecording(); |
|
|
|
|
|
|
|
|
detectorService.stopVideoDetection(); |
|
|
|
|
|
detectorService.stopAudioDetection(); |
|
|
|
|
|
detectorService.stopMotionDetection(); |
|
|
|
|
|
detectorService.stopVideoRecording(); |
|
|
|
|
|
detectorService.stopAudioRecording(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private ServiceConnection serviceConnection = new ServiceConnection() { |
|
|
|
|
|
@Override |
|
|
|
|
|
public void onServiceConnected(ComponentName name, IBinder service) { |
|
|
|
|
|
DetectorService.ServiceBinder binder = (DetectorService.ServiceBinder) service; |
|
|
|
|
|
detectorService = binder.getBoundService(); |
|
|
|
|
|
|
|
|
|
|
|
detectorService.setOnDetectionListener(new DetectorService.OnDetectionListener() { |
|
|
|
|
|
@Override |
|
|
|
|
|
public void onDetection(@NonNull DetectionReport detectionReport) { |
|
|
|
|
|
Log.d("onDetection", detectionReport.toString()); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
@Override |
|
|
|
|
|
public void onServiceDisconnected(ComponentName name) {} |
|
|
|
|
|
}; |
|
|
} |
|
|
} |