Computer Vision Fundamentals
Dasar-dasar computer vision untuk robot soccer - dari image processing hingga machine learning
Computer Vision untuk Robot Soccer
Computer vision adalah "mata" robot yang memungkinkan robot memahami lingkungan sekitar melalui kamera. Dalam RoboCup, vision system bertanggung jawab untuk mendeteksi bola, garis lapangan, gawang, dan robot lain.
Mengapa Penting?
Dalam RoboCup Humanoid League, robot harus sepenuhnya otonom - tidak ada remote control atau operator manusia. Semua keputusan diambil berdasarkan apa yang robot "lihat" melalui kamera.
| Objek | Pentingnya |
|---|---|
| Bola | Target utama untuk scoring |
| Garis Lapangan | Lokalisasi posisi di lapangan |
| Gawang | Target untuk menendang |
| Robot Lain | Hindari collision, identifikasi teammate/opponent |
Vision Pipeline Overview

Pipeline ini penting karena setiap tahap membatasi noise dan mengubah data ke bentuk yang bisa dipakai robot untuk mengambil keputusan. Ringkasnya:
- Preprocess menstabilkan input (denoise, resize, koreksi warna) agar deteksi lebih konsisten.
- Detection mengekstrak objek penting (bola, garis, gawang) dari citra.
- 3D Projection mengubah posisi pixel ke koordinat lapangan agar bisa dipakai untuk navigasi dan gerak.
Learning Tracks
Image Processing Basics
Color spaces, filtering, morphological operations
Camera Calibration
Intrinsics, extrinsics, 3D projection
Ball Detection
Color segmentation, circle detection, blob analysis
Field Detection
Line detection, field segmentation, landmark recognition
Object Tracking
Kalman filter, dropout handling, smoother output
Machine Learning
CNN, YOLO, training custom models
Dataset & Labeling
Data collection, annotation QA, split strategy
Evaluation & Benchmarking
Precision/recall/FPS/latency and regression checks
ROS 2 Integration
Topics, timestamps, TF alignment, launch params
Debugging Playbook
Symptom-first troubleshooting for match day
Recommended Learning Path
| Stage | Focus | Pages |
|---|---|---|
| Stage 1: Foundations | Preprocessing dan geometri kamera | Image Processing, Camera Calibration |
| Stage 2: Detection + Tracking | Deteksi robust dan stabil antar frame | Ball Detection, Field Detection, Object Tracking |
| Stage 3: ML Ops + Deployment | Data pipeline, evaluasi, integrasi ROS 2 | Machine Learning, Dataset & Labeling, Evaluation & Benchmarking, ROS 2 Integration, Debugging Playbook |
Tools & Libraries
Primary Tools
| Tool | Purpose | Link |
|---|---|---|
| OpenCV | Image processing, detection | opencv.org |
| NumPy | Array operations | numpy.org |
| PyTorch | Deep learning | pytorch.org |
| Ultralytics YOLO | Object detection | ultralytics.com |
ROS 2 Packages
# Image transport
sudo apt install ros-humble-image-transport
# CV Bridge (OpenCV ↔ ROS)
sudo apt install ros-humble-cv-bridge
# Image pipeline
sudo apt install ros-humble-image-pipelineQuick Start: Ball Detection
Contoh sederhana deteksi bola oranye menggunakan OpenCV:
import cv2
import numpy as np
def detect_ball(image):
"""Detect orange ball using HSV color filtering."""
# Convert BGR to HSV
hsv = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)
# Define orange color range
lower_orange = np.array([5, 100, 100])
upper_orange = np.array([15, 255, 255])
# Create mask
mask = cv2.inRange(hsv, lower_orange, upper_orange)
# Find contours
contours, _ = cv2.findContours(mask, cv2.RETR_EXTERNAL,
cv2.CHAIN_APPROX_SIMPLE)
if contours:
# Get largest contour (assume it's the ball)
largest = max(contours, key=cv2.contourArea)
(x, y), radius = cv2.minEnclosingCircle(largest)
if radius > 10: # Minimum size threshold
return int(x), int(y), int(radius)
return None
# Usage
cap = cv2.VideoCapture(0)
while True:
ret, frame = cap.read()
if not ret:
break
result = detect_ball(frame)
if result:
x, y, r = result
cv2.circle(frame, (x, y), r, (0, 255, 0), 2)
cv2.circle(frame, (x, y), 5, (0, 0, 255), -1)
cv2.imshow('Ball Detection', frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()Challenges in RoboCup
1. Lighting Variations
Lapangan RoboCup memiliki pencahayaan yang bisa berubah:
- Natural light vs artificial light
- Shadows dari robot/arena
- Specular reflections dari lantai
Solusi: Adaptive thresholding, histogram equalization, ML-based detection
2. Motion Blur
Robot bergerak cepat menyebabkan motion blur:
- Ball tracking saat walking
- Head movement untuk scanning
Solusi: Higher FPS camera, motion compensation, predictive tracking
3. Occlusion
Objek bisa terhalang:
- Ball behind opponent robot
- Partial line visibility
Solusi: Multi-frame tracking, probabilistic models
4. Real-time Constraint
Processing harus cepat (~30 fps minimum):
- Limited compute on robot
- Battery constraints
Solusi: Efficient algorithms, GPU acceleration, region of interest
Performance Metrics
| Metric | Target | Description |
|---|---|---|
| FPS | ≥30 | Frames per second |
| Latency | ≤50ms | Detection delay |
| Precision | ≥95% | Correct detections / total detections |
| Recall | ≥90% | Detected objects / actual objects |
Resources
Documentation
Papers & Research
- B-Human Team Report - State-of-the-art SPL vision
- RoboCup Symposium Papers
- YOLO Paper - Original YOLO architecture
Video Tutorials
GitHub Repositories
Next Steps
- Pemula: Mulai dengan Image Processing Basics
- Geometry: Pelajari Camera Calibration
- Detection: Lanjut ke Ball Detection dan Field Detection
- Stability: Tambahkan Object Tracking
- Deployment: Tutup dengan ROS 2 Integration dan Debugging Playbook
Praktik adalah kunci! Coba implementasi langsung dengan webcam atau dataset RoboCup yang tersedia.