-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjunction_yellow_pt2
47 lines (38 loc) · 1.79 KB
/
junction_yellow_pt2
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
46
47
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.junctionDetection;
import org.openftc.easyopencv.OpenCvCamera;
import org.openftc.easyopencv.OpenCvCameraFactory;
import org.openftc.easyopencv.OpenCvCameraRotation;
@TeleOp(name = "yellow junction")
public class VisionTest extends LinearOpMode {
private JunctionDetection junctionDetection;
private OpenCvCamera camera;
// Nome da Webcam a ser definido na configuração
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);
junctionDetection = new junctionDetection();
camera.setPipeline(junctionDetection);
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: ", junctionDetection.getPosition());
//telemetry.addData("X", TOPLEFT_ANCHOR_POINT.X.getPosition());
//telemetry.addData("Y", TOPLEFT_ANCHOR_POINT.y.getPosition());
telemetry.update();
}
waitForStart();
}
}