Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Edited within StageSwitchingPipeline
- private static float offsetX = -1.10f/8f;//changing this moves the three rects and the three circles left or right, range : (-2, 2) not inclusive
- private static float offsetY = 1.35f/8f;//changing this moves the three rects and circles up or down, range: (-4, 4) not inclusive
- public void initSample() {
- int cameraMonitorViewId = hardwareMap.appContext.getResources().getIdentifier("cameraMonitorViewId", "id", hardwareMap.appContext.getPackageName());
- phoneCam = OpenCvCameraFactory.getInstance().createInternalCamera(OpenCvInternalCamera.CameraDirection.BACK, cameraMonitorViewId);
- phoneCam.openCameraDevice();//open camera
- phoneCam.setPipeline(new StageSwitchingPipeline());
- phoneCam.startStreaming(StageSwitchingPipeline.rows, StageSwitchingPipeline.cols, OpenCvCameraRotation.UPSIDE_DOWN);//our phone is upside down, camera upside down
- }
- public void Sample() {
- sleep(1000); // Gives time for camera to start and see stones
- // 0 if skystone, 255 if stone
- if (StageSwitchingPipeline.valLeft == 0)
- {
- skyStoneFound = true;
- skyStonePosition = 'L';
- }
- else if (StageSwitchingPipeline.valRight == 0)
- {
- skyStoneFound = true;
- skyStonePosition = 'R';
- }
- else if (StageSwitchingPipeline.valMid == 0)
- {
- skyStoneFound = true;
- skyStonePosition = 'C';
- }
- else // stone not found
- {
- skyStoneFound = true;
- skyStonePosition = 'X';
- }
- phoneCam.closeCameraDevice(); // closes after found
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement