This code is an implementation of a YOLOv7 detector along with a Realsense D435i camera, which is used for object detection in real-time. The main purpose is to detect objects and obtain data such as position, distance, and orientation.
- Python 3.7 or later
- Pytorch 1.7.0 or later
- OpenCV 4.1.2 or later
- pyrealsense2 2.50.0 or later
- scipy 1.4.1 or later
- numpy 1.18.5 or later
To run the code, execute the detect function from the main.py file. The function has the following input arguments:
--weights
:str
: model.pt path(s)--source
:str
: source (file/folder, 0 for webcam)--img-size
:int
: inference size (pixels)--conf-thres
:float
: object confidence threshold--iou-thres
:float
: IOU threshold for NMS--device
:str
: cuda device, i.e. 0 or 0,1,2,3 or cpu
Example usage:
python main.py --weights yolov7s.pt --source 0 --img-size 640 --conf-thres 0.4 --iou-thres 0.5
To stop the detection, press the q
key.
The code will output a video stream that will display the detected objects along with the corresponding bounding boxes, labels, and orientation angles. Additionally, the data will be saved in a .mat file, containing the object coordinates, distance, and orientation data at time relative to code initialization.
This code was implemented using the YOLOv7 repository by Ultralytics LLC.
This project is licensed under the MIT License.