-
Notifications
You must be signed in to change notification settings - Fork 4
/
VisionTest.java
45 lines (36 loc) · 1.67 KB
/
VisionTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
import org.firstinspires.ftc.robotcore.external.hardware.camera.WebcamName;
import org.firstinspires.ftc.teamcode.common.powerplay.SleeveDetection;
import org.openftc.easyopencv.OpenCvCamera;
import org.openftc.easyopencv.OpenCvCameraFactory;
import org.openftc.easyopencv.OpenCvCameraRotation;
@Autonomous(name = "Signal Sleeve Test")
public class VisionTest extends LinearOpMode {
private SleeveDetection sleeveDetection;
private OpenCvCamera camera;
// Name of the Webcam to be set in the config
private String webcamName = "Webcam 1";
@Override
public void runOpMode() throws InterruptedException {
int cameraMonitorViewId = hardwareMap.appContext.getResources().getIdentifier("cameraMonitorViewId", "id", hardwareMap.appContext.getPackageName());
camera = OpenCvCameraFactory.getInstance().createWebcam(hardwareMap.get(WebcamName.class, webcamName), cameraMonitorViewId);
sleeveDetection = new SleeveDetection();
camera.setPipeline(sleeveDetection);
camera.openCameraDeviceAsync(new OpenCvCamera.AsyncCameraOpenListener()
{
@Override
public void onOpened()
{
camera.startStreaming(320,240, OpenCvCameraRotation.SIDEWAYS_LEFT);
}
@Override
public void onError(int errorCode) {}
});
while (!isStarted()) {
telemetry.addData("ROTATION: ", sleeveDetection.getPosition());
telemetry.update();
}
waitForStart();
}
}