1. Visual Studio Code
1. Download
Visual Studio Code. (Recommended)
2. Download Python 3.7 or newer (tested on Python
3.8/3.9/3.10/3.11)
3. Configure Visual Studio Code & Terminal
1. Open Folder (This is the folder where you want to have the OpenML project)
2. Open New Terminal
3. Install the dependencies
4. Dependencies (use pip3 for python3)
pip install opencv-python ultralytics numpy
Or
pip install opencv-python==4.8.0.76
pip install ultralytics==8.0.196
pip install numpy==1.24.4
If OpenCV does not work try to reinstall it using the method above
(or retry using the methods below)
pip install opencv-python
Example
5. Hardware Requirements
A Webcam connected to the device is required (the code uses cv2.VideoCapture(0), make sure
camera index 0 is correct for your configuration.)
Sufficient CPU power for real-time inference (a CUDA-enabled graphics card is recommended
for better performance) for Testing and Control Hub is also accepted.
6. Test Camera Python Script
Create a Python script named camera_test.py and add the following code to it
camera_test.py (Click
to
download)
import cv2
cap = cv2.VideoCapture(0) #If it doesn't work, increment the number by 1 until the camera works and appears on the screen
ret, frame = cap.read()
print("Camera working:", ret)
cap.release()
Then
7.If the camera works, download the ML model from
Resources
If you have a Very Low / Low quality camera download the first ML
If you have a Medium / Very Good quality camera download the second
ML
Make sure you download the model with [Python Testing] for your camera
quality
[It matters a lot]
8. Calibrate The Camera
Access Camera
Calibration, and then return after you have finished calibrating the camera.
9.πIf you have successfully completed all steps, you can proceed
to Python Code For Detection to test the OpenML model π
10. Additional Notes
The code uses math and cv2 modules for geometric calculations and camera operations. These
are included in the dependencies mentioned above.
If you encounter CUDA-related errors, ensure you have compatible GPU drivers and PyTorch/CUDA
is installed (Ultralytics YOLO usually handles this automatically).
Adjust the fov_degrees, first_angle and y values based on your camera calibration.