Compare commits
No commits in common. "daaf8735de2fb37dbb5f7a3301324ef30e43affe" and "8cc57ec4d533d6486f4dc9d8e96a3600eb5ead6e" have entirely different histories.
daaf8735de
...
8cc57ec4d5
@ -34,7 +34,6 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
TextView textView = findViewById(R.id.textView);
|
TextView textView = findViewById(R.id.textView);
|
||||||
PreviewView previewView = findViewById(R.id.previewView);
|
PreviewView previewView = findViewById(R.id.previewView);
|
||||||
|
|
||||||
getCameraAccess();
|
|
||||||
|
|
||||||
VideoDetector vd = new VideoDetector(this);
|
VideoDetector vd = new VideoDetector(this);
|
||||||
vd.setPreviewView(previewView);
|
vd.setPreviewView(previewView);
|
||||||
@ -42,11 +41,27 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
@Override
|
@Override
|
||||||
public void onDetection(@NonNull DetectionReport detectionReport) {
|
public void onDetection(@NonNull DetectionReport detectionReport) {
|
||||||
detectionReport.log("OnDetection");
|
detectionReport.log("OnDetection");
|
||||||
textView.setText("Alarm:\t[" + String.valueOf(detectionReport.detectedValue) + "]");
|
textView.setText(detectionReport.toString());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
vd.startDetection();
|
//vd.startDetection();
|
||||||
|
|
||||||
|
|
||||||
|
ToggleButton toggleButton = findViewById(R.id.previewButton);
|
||||||
|
toggleButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
getCameraAccess();
|
||||||
|
if (isCameraAccessAllowed() && toggleButton.isChecked())
|
||||||
|
{
|
||||||
|
vd.startDetection();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
vd.stopDetection();
|
||||||
|
textView.setText("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isCameraAccessAllowed() {
|
private boolean isCameraAccessAllowed() {
|
||||||
|
@ -33,7 +33,7 @@ public class VideoDetector extends Detector {
|
|||||||
private PreviewView previewView = null;
|
private PreviewView previewView = null;
|
||||||
// Detect Violation
|
// Detect Violation
|
||||||
private static final float PIXEL_THRESHOLD = 30f; // Luminosity (brightness channel of YUV_420_888)
|
private static final float PIXEL_THRESHOLD = 30f; // Luminosity (brightness channel of YUV_420_888)
|
||||||
private static final float ALARM_THRESHOLD = 0.5f; // Percent of pixels changed
|
private static final float ALARM_THRESHOLD = 1f; // Percent of pixels changed
|
||||||
private ByteBuffer previousBuffer = null;
|
private ByteBuffer previousBuffer = null;
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,13 +14,18 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text=""
|
android:text=""
|
||||||
android:textSize="30sp"
|
android:textSize="20dp"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
|
||||||
|
<ToggleButton
|
||||||
|
android:id="@+id/previewButton"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="ToggleButton" />
|
||||||
|
|
||||||
|
|
||||||
<androidx.camera.view.PreviewView
|
<androidx.camera.view.PreviewView
|
||||||
|
Loading…
x
Reference in New Issue
Block a user