Object Detection
3. Object Detection Configuration
3.1 Initial Hardware Setup
-
Coprocessor Preparation:
- Make sure your coprocessor is already set up from a previous quickstart, OR
- Download latest Orange PI 5 PhotonVision image
- Flash image to microSD card
- Insert microSD into Orange PI 5
-
Camera Naming:
- Download ArducamUVCSerialNumber_Official.zip
- Extract the program
- For each Arducam OV9782 camera:
- Connect camera to laptop via USB
- Open ArducamUVCSerialNumber program
- In "Device name" field, enter camera position:
- Format:
POSITION_Object
- Examples:
FL_Object
,FM_Object
,FR_Object
- Format:
- Click "Write"
- Open Device Manager
- Uninstall the camera
- Reconnect the camera
- Verify new name appears
- Disconnect from laptop
- Connect to Orange PI 5
- Repeat for all cameras
3.2 PhotonVision Configuration
-
Pipeline Setup:
- Open PhotonVision web interface
- For each camera:
- Select camera in UI
- Create new pipeline named "ObjectDetection"
- Set pipeline type to "ObjectDetection"
- Configure processing:
- Auto White Balance: ON
- Set camera settings:
- Resolution: 1280x720
- FPS: 30 (or similar)
- Stream Resolution: Lowest available
- Navigate to Cameras tab
- Select camera
- Set Model as "OV9782"
-
Camera Calibration:
- For each camera:
- Select calibration settings:
- Tag Family: 5x5
- Resolution: 720p
- Pattern Spacing: 3.15 inches
- Marker Size: 2.36 inches
- Board: 12x8
- Take multiple calibration snapshots:
- Vary angles and distances
- Include corner views
- Mix close and far positions
- Run calibration
- Verify mean error < 1.0 pixels
- If error too high:
- Delete poor quality snapshots
- Add more varied angles
- Recalibrate
- Select calibration settings:
- For each camera:
-
Field Tuning:
- At competition field:
- Adjust exposure
- Tune brightness
- Set appropriate gain
- Test detection reliability
- Save field-specific settings
- At competition field:
3.3 Camera Offset Measurement
Accurate camera position measurements are critical for object detection:
-
Physical Measurements:
- Use calipers or precise measuring tools
- Measure from robot center (origin) to camera lens center
- Record three distances for each camera:
- Forward distance (X): positive towards robot front
- Left distance (Y): positive towards robot left
- Up distance (Z): positive towards robot top
- Measure camera angles:
- Pitch: downward tilt (usually negative)
- Yaw: left/right rotation
-
Update Constants:
-
Camera Configuration:
java // Add configuration for each physical camera public static final CameraConfig[] CAMERA_CONFIGS = { new CameraConfig( "FM_ObjectDetection", CAMERA_OFFSETS[0], new SimCameraProperties()) };
-
IO Configuration:
-
Replay Support:
3.4 Game Element Configuration
Before testing object detection, configure the game elements that need to be detected:
-
Define Game Elements:
-
Create Class ID Array:
-
Important Considerations:
- Array indices must match model's class IDs exactly
- Measurements must be in meters
- Dimensions are width, length, height
- Names should match what's shown in PhotonVision
3.5 Camera Verification
After configuring cameras and game elements:
-
Physical Checks:
- Verify camera mounts are secure
- Check USB connections
- Confirm cameras are powered
- LED indicators should be on
-
Network Verification:
- Open PhotonVision dashboard
- Confirm all cameras are connected
- Check video feeds are active
- Verify camera names match configs
-
Basic Testing:
- Place game piece in camera view
- Confirm detection in dashboard
- Check pose estimation quality
- Verify reasonable distance estimates
-
Filtering Configuration:
- Position Match Tolerance:
// Tolerance in meters for matching object positions // Default is usually fine, but can be adjusted if needed public static final double POSITION_MATCH_TOLERANCE = 0.5;
- Larger values: More stable tracking during rotation
- Smaller values: More accurate position tracking
- Trade-off between stability and accuracy
- Start with default and adjust if objects appear unstable
- Position Match Tolerance:
-
Common Issues:
- Camera disconnections: Check USB connections
- Poor detection: Adjust exposure/brightness
- Incorrect poses: Double-check offset measurements
- Network lag: Monitor bandwidth usage
- Unstable tracking: Try increasing POSITION_MATCH_TOLERANCE
- Position jumps: Try decreasing POSITION_MATCH_TOLERANCE