Collection of computer vision tools for experimentation with OpenCV.
- Python 3.13 or higher
# Create virtual environment
python3 -m venv .venv
# Activate virtual environment
source .venv/bin/activate
# Install dependencies
pip install numpy opencv-python pyaudio scipy pillow matplotlib
# Install portaudio (required for macOS)
brew install portaudio
# Install dependencies using Pipenv
pipenv install
pipenv shell
Simple tool to experiment with RGB color values:
python rgb_trackbar.py
Track objects of specific colors:
# Track green objects (default)
python object_tracking/colour_tracking.py
# Track blue objects
python object_tracking/colour_tracking.py --colour blue
# Available colors: blue, green, red, orange, yellow
Options:
--colour [COLOR]
: Color to track (blue, green, red, orange, yellow)--flip
: Flip video horizontally--width
: Video width (default: 160)--height
: Video height (default: 120)-v, --verbose
: Increase output verbosity
Select a region of color to track:
python object_tracking/pick_and_track.py
- Click and drag to select a region in the input window
- The script will track objects of that color
- Press 'r' to reset selection
- Press 'q' to quit
If you encounter camera access errors:
OpenCV: error in [AVCaptureDeviceInput initWithDevice:error:]
OpenCV: Cannot Use FaceTime HD Camera
OpenCV: camera failed to properly initialize!
Try the following:
sudo killall VDCAssistant
If you get "No module named 'cv2'" error, make sure you've activated your virtual environment:
source .venv/bin/activate