Object detection and location calculation - Gradient-PG/Drones GitHub Wiki
Object detection with OpenCV
TODO
Object detection with YOLO
YOLO is one of the best object detection neural networks models available on markets. It has powerful options to detect object. Also it is possible to train network on your own classes. In yolo.py detect() functions is remake of original yolo detect.py file. It was done due to necessity to adjust YOLO functionality to project workflow, to prevent from extra disk operations. Function has several parameters, which can be set up in config file.
- NETWORK_PATH - path to weights file, which should be used by YOLO. This path should always be models\weights_name.pt. Also if you are working with default YOLO networks, please add them to gitignore. However if you train new model, you should upload it as well.
- CLASS - name of class, which we want to track. YOLO by default have all class from COCO dataset, so if you are interested in tracing one of them, you should put name of it. Only one class per time can be traced, so it is not permitted to add more classes here. It always must be one class
- CONFIDENCE_THRESHOLD - confidence level on which YOLO will detect object.
- IMG_SIZE - size of image after scaling. Higher size is, the results will be better. However doubling size will end up with quadruple processing time, so please take it into consideration.
- DEVICE - select device on which neural network will run. I can be cuda or cpu. In case of cuda you have to specifically it(I.e. 0 or 0, 1, 2, 3)
- CLASSES - this parameter represents classes on which yolo will detect. It should be placed by integer list. Please use it only if you have certain reason(YOLO will run a little bit faster), but it is hard to use.
- IOU_THRESHOLD = Intersection Over Union. This parameter represent threshold on bounding boxes. For more details please follow link
All this yolo parameters are read from config file when you create YOLO object.
Counting distance
To count distance we use focal length and real width of object. distance = (known_width * focal_length) / pixel_width
Getting pitch and yaw
There are counted from image parameters and position of object. After counting position vector from expecting point, result are position_vector/img_shape*field of view. range of values are from -FOV to +FOV