Cleanup
This commit is contained in:
parent
287fef6443
commit
06182dc1e9
|
@ -20,12 +20,10 @@ public class Camera {
|
||||||
private TargetingPipeline targetingPipeline;
|
private TargetingPipeline targetingPipeline;
|
||||||
private boolean targetingCameraInitialized;
|
private boolean targetingCameraInitialized;
|
||||||
|
|
||||||
// Constructor
|
|
||||||
public Camera(HardwareMap hardwareMap) {
|
public Camera(HardwareMap hardwareMap) {
|
||||||
this.hardwareMap = hardwareMap;
|
this.hardwareMap = hardwareMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initiate the Targeting Camera
|
|
||||||
public void initTargetingCamera() {
|
public void initTargetingCamera() {
|
||||||
int targetingCameraMonitorViewId = hardwareMap.appContext.getResources().getIdentifier("cameraMonitorViewId", "id", hardwareMap.appContext.getPackageName());
|
int targetingCameraMonitorViewId = hardwareMap.appContext.getResources().getIdentifier("cameraMonitorViewId", "id", hardwareMap.appContext.getPackageName());
|
||||||
this.targetingCamera = OpenCvCameraFactory.getInstance().createWebcam(hardwareMap.get(WebcamName.class, TARGETING_WEBCAM), targetingCameraMonitorViewId);
|
this.targetingCamera = OpenCvCameraFactory.getInstance().createWebcam(hardwareMap.get(WebcamName.class, TARGETING_WEBCAM), targetingCameraMonitorViewId);
|
||||||
|
@ -45,14 +43,12 @@ public class Camera {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close the Targeting Camera
|
|
||||||
public void stopTargetingCamera() {
|
public void stopTargetingCamera() {
|
||||||
if (targetingCameraInitialized) {
|
if (targetingCameraInitialized) {
|
||||||
targetingCamera.closeCameraDeviceAsync(() -> targetingCameraInitialized = false);
|
targetingCamera.closeCameraDeviceAsync(() -> targetingCameraInitialized = false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the Red Goal Detection
|
|
||||||
public Detection getRed() {
|
public Detection getRed() {
|
||||||
return (targetingCameraInitialized ? targetingPipeline.getRed() : INVALID_DETECTION);
|
return (targetingCameraInitialized ? targetingPipeline.getRed() : INVALID_DETECTION);
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,8 +54,6 @@ public class Detection {
|
||||||
if (isValid()) {
|
if (isValid()) {
|
||||||
drawConvexHull(img, contour, color);
|
drawConvexHull(img, contour, color);
|
||||||
drawPoint(img, centerPx, GREEN);
|
drawPoint(img, centerPx, GREEN);
|
||||||
// drawPoint(img, bottomLeftPx, GREEN);
|
|
||||||
// drawPoint(img, bottomRightPx, GREEN);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,14 +62,11 @@ public class Detection {
|
||||||
if (isValid()) {
|
if (isValid()) {
|
||||||
fillConvexHull(img, contour, color);
|
fillConvexHull(img, contour, color);
|
||||||
drawPoint(img, centerPx, GREEN);
|
drawPoint(img, centerPx, GREEN);
|
||||||
// drawPoint(img, bottomLeftPx, GREEN);
|
|
||||||
// drawPoint(img, bottomRightPx, GREEN);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the current Detection is valid
|
// Check if the current Detection is valid
|
||||||
public boolean isValid() {
|
public boolean isValid() {
|
||||||
// return true;
|
|
||||||
return (this.contour != null) && (this.centerPx != INVALID_POINT) && (this.areaPx != INVALID_AREA);
|
return (this.contour != null) && (this.centerPx != INVALID_POINT) && (this.areaPx != INVALID_AREA);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue