Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,6 @@ dmypy.json
.pyre/
.idea/

# Photos
*.jpg
*.png

# YOLO model directory
/drones/models/yolov5m.pt
/drones/models/yolov5l.pt
5 changes: 4 additions & 1 deletion drones/image_processing/image_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from drones.image_processing.yolo import YoloDetection
from drones.image_processing.utils import distance_to_camera, vector_to_centre
from typing import List, Tuple
import os


class ImageProcessing:
Expand Down Expand Up @@ -39,7 +40,9 @@ def process_image(self, image: np.ndarray) -> List[Tuple[float, float, float]]:
detection list will be empty.
"""
config_parser = configparser.ConfigParser()
config_parser.read("image_processing/config.ini")
pwd = os.path.dirname(os.path.abspath(__file__))
config_path = os.path.join(pwd, "config.ini")
config_parser.read(config_path)
config = config_parser["OBJECT"]

focal = int(config["FOCAL"])
Expand Down
5 changes: 4 additions & 1 deletion drones/image_processing/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import configparser
import typing
import drones.image_processing.normalization as normalization
import os


def calculate_focal(known_width: float, known_distance: float, pixel_width: int) -> float:
Expand Down Expand Up @@ -108,7 +109,9 @@ def detect_object(image: np.ndarray) -> typing.Tuple[typing.Tuple[int, int], int
This returned format is insired by OpenCV minEnclosingCircle function returned format.
"""
config_parser = configparser.ConfigParser()
config_parser.read("image_processing/config.ini")
pwd = os.path.dirname(os.path.abspath(__file__))
config_path = os.path.join(pwd, "config.ini")
config_parser.read(config_path)
config = config_parser["COLOR_RANGE"]

# Image normalization to make colors more visious and less light vulnerable.
Expand Down
5 changes: 4 additions & 1 deletion drones/image_processing/yolo.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@
from yolov5.utils.torch_utils import select_device
import logging
from typing import List, Tuple
import os


class YoloDetection:
def __init__(self):
self.log = logging.getLogger(__name__)
# Initialize config.
self.config_parser = configparser.ConfigParser()
self.config_parser.read("image_processing/config.ini")
pwd = os.path.dirname(os.path.abspath(__file__))
config_path = os.path.join(pwd, "config.ini")
self.config_parser.read(config_path)
self.config = self.config_parser["YOLO"]

# Parse classes from config.
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ numpy==1.20.2
opencv-python==4.5.1.48
pre-commit~=2.11.0
pytest==6.2.2
yolov5==5.0.3
yolov5==5.0.5
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/image_processing/resources/bottles.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/image_processing/resources/dog.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading