Advertisement
Guest User

Untitled

a guest
Jan 26th, 2020
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.71 KB | None | 0 0
  1.    
  2. // Edited within StageSwitchingPipeline
  3.  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
  4.     private static float offsetY = 1.35f/8f;//changing this moves the three rects and circles up or down, range: (-4, 4) not inclusive
  5.  
  6.  
  7.     public void initSample() {
  8.         int cameraMonitorViewId = hardwareMap.appContext.getResources().getIdentifier("cameraMonitorViewId", "id", hardwareMap.appContext.getPackageName());
  9.  
  10.  
  11.         phoneCam = OpenCvCameraFactory.getInstance().createInternalCamera(OpenCvInternalCamera.CameraDirection.BACK, cameraMonitorViewId);
  12.  
  13.  
  14.         phoneCam.openCameraDevice();//open camera
  15.         phoneCam.setPipeline(new StageSwitchingPipeline());
  16.         phoneCam.startStreaming(StageSwitchingPipeline.rows, StageSwitchingPipeline.cols, OpenCvCameraRotation.UPSIDE_DOWN);//our phone is upside down, camera upside down
  17.  
  18.     }
  19.  
  20.     public void Sample() {
  21.  
  22.         sleep(1000); // Gives time for camera to start and see stones
  23.        
  24.         // 0 if skystone, 255 if stone
  25.         if (StageSwitchingPipeline.valLeft == 0)
  26.         {
  27.             skyStoneFound = true;
  28.             skyStonePosition = 'L';
  29.         }
  30.         else if (StageSwitchingPipeline.valRight == 0)
  31.         {
  32.             skyStoneFound = true;
  33.             skyStonePosition = 'R';
  34.         }
  35.         else if (StageSwitchingPipeline.valMid == 0)
  36.         {
  37.             skyStoneFound = true;
  38.             skyStonePosition = 'C';
  39.         }
  40.         else // stone not found
  41.         {
  42.             skyStoneFound = true;
  43.             skyStonePosition = 'X';
  44.         }
  45.         phoneCam.closeCameraDevice(); // closes after found
  46.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement