GRIP JAVA Coding Issues

Hi! This is my first post, so dont yell at me If I did something wrong. When I was coding my camera code in my main Robot class, I ran into an error for creating the rectangle.
Code:
package org.usfirst.frc.team193.robot;

import edu.wpi.first.wpilibj.IterativeRobot;
import com.ctre.CANTalon;
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj.CameraServer;
import edu.wpi.first.wpilibj.Joystick;

import org.opencv.core.KeyPoint;
import org.opencv.core.MatOfKeyPoint;
import org.opencv.core.Rect;
import org.opencv.imgproc.Imgproc;
import com.ctre.CANTalon;
import edu.wpi.cscore.UsbCamera;
import edu.wpi.first.wpilibj.CameraServer;
import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.vision.VisionRunner;
import edu.wpi.first.wpilibj.vision.VisionThread;

/**

  • The VM is configured to automatically run this class, and to call the

  • functions corresponding to each mode, as described in the IterativeRobot

  • documentation. If you change the name of this class or the package after

  • creating this project, you must also update the manifest file in the resource

  • directory.
    */
    public class Robot extends IterativeRobot {
    final String defaultAuto = “Default”;
    final String customAuto = “My Auto”;
    String autoSelected;
    SendableChooser<String> chooser = new SendableChooser<>();
    Joystick leftJoy = new Joystick(0);
    Joystick rightJoy = new Joystick(1);
    double leftValue;
    double rightValue;
    CANTalon leftMaster = new CANTalon(2);
    CANTalon rightMaster = new CANTalon (5);
    private static final int IMG_WIDTH = 320;
    private static final int IMG_HEIGHT = 240;

    MatOfKeyPoint blobsOutput = new MatOfKeyPoint();

    private VisionThread visionThread;
    private double centerX = 0.0;
    private RobotDrive drive;

    private final Object imgLock = new Object();
    /**

    • This function is run when the robot is first started up and should be

    • used for any initialization code.
      */
      @Override
      public void robotInit() {
      chooser.addDefault(“Default Auto”, defaultAuto);
      chooser.addObject(“My Auto”, customAuto);
      SmartDashboard.putData(“Auto choices”, chooser);

      UsbCamera camera = CameraServer.getInstance().startAutomaticCapture();
      camera.setResolution(IMG_WIDTH, IMG_HEIGHT);

       visionThread = new VisionThread(camera, new Pipeline(), pipeline -&gt; {
           if (!pipeline.findBlobsOutput().empty()) {
               Rect r = Imgproc.boundingRect(pipeline.findBlobsOutput().get(0, 0));
               synchronized (imgLock) {
                   centerX = r.x + (r.width / 2);
               }
           }
       });
       visionThread.start();
      

    }

    /**

    • This autonomous (along with the chooser code above) shows how to select
    • between different autonomous modes using the dashboard. The sendable
    • chooser code works with the Java SmartDashboard. If you prefer the
    • LabVIEW Dashboard, remove all of the chooser code and uncomment the
    • getString line to get the auto name from the text box below the Gyro
    • You can add additional auto modes by adding additional comparisons to the
    • switch structure below with additional strings. If using the
    • SendableChooser make sure to add them to the chooser code above as well.
      */
      @Override
      public void autonomousInit() {
      autoSelected = chooser.getSelected();
      // autoSelected = SmartDashboard.getString(“Auto Selector”,
      // defaultAuto);
      System.out.println("Auto selected: " + autoSelected);
      }

    /**

    • This function is called periodically during autonomous
      */
      @Override
      public void autonomousPeriodic() {
      switch (autoSelected) {
      case customAuto:
      if (!blobsOutput.empty()){
      KeyPoint KPArray] = blobsOutput.toArray();
      double centerX;
      synchronized (imgLock) {
      centerX = this.centerX;
      }
      double turn = centerX - (IMG_WIDTH / 2);
      drive.arcadeDrive(-0.6, turn * 0.005);

       }
       		
       break;
      

      case defaultAuto:
      default:
      // Put default auto code here
      break;
      }
      }

    /**

    • This function is called periodically during operator control
      */
      @Override
      public void teleopPeriodic() {
      leftValue = leftJoy.getY();
      rightValue = rightJoy.getY();
      leftMaster.set(-leftValue);
      rightMaster.set(rightValue);
      }

    /**

    • This function is called periodically during test mode
      */
      @Override
      public void testPeriodic() {
      }
      }

ERROR: the method boundingRect(MatOfPoint) in they type Imgproc is not applicable for the type double].

Any help would be greatly appreciated. Thank you!

Oh I see.
You edited a logic/syntax error the following line.

Rect r = Imgproc.boundingRect(pipeline.findBlobsOutput().get(0, 0));

Where you found this in screensteps it had only one of those 0s.

Rect r = Imgproc.boundingRect(pipeline.findBlobsOutput().get(0));

This (sample) logic uses only the first blob. There are other good screensteps pages which explain how to handle multiple blobs.

I don’t know when/why you would use the get(row,col) method, (it might be something which should be private/protected in the future).