Functions | |
| check_arguments_errors (args) | |
| convert2original (image, bbox) | |
| convert2relative (bbox) | |
| convert4cropping (image, bbox) | |
| drawing (frame_queue, detections_queue, fps_queue) | |
| inference (darknet_image_queue, detections_queue, fps_queue) | |
| parse_args () | |
| set_saved_video (input_video, output_video, size) | |
| signal_handler (sig, frame) | |
| str2int (video_path) | |
| video_capture (frame_queue, darknet_image_queue) | |
Variables | |
| args = parse_args() | |
| cap = cv2.VideoCapture(input_path) | |
| capture_thread = None | |
| class_colors = darknet.class_colors(class_names) | |
| class_names = open(args.data_file).read().splitlines() | |
| darknet_height = darknet.network_height(network) | |
| darknet_image_queue = Queue(maxsize=1) | |
| darknet_width = darknet.network_width(network) | |
| detections_queue = Queue(maxsize=1) | |
| drawing_thread = None | |
| fps_queue = Queue(maxsize=1) | |
| int | frame_delay = 30 |
| frame_queue = Queue() | |
| inference_thread = None | |
| input_path = str2int(args.input) | |
| bool | is_running = True |
| network = darknet.load_net_custom(args.config_file.encode("ascii"), args.weights.encode("ascii"), 0, 1) | |
| video_height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT)) | |
| video_width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)) | |
| darknet_video.check_arguments_errors | ( | args | ) |

| darknet_video.convert2original | ( | image, | |
| bbox | |||
| ) |
Converts relative bounding box coordinates back to original (absolute) coordinates.
Parameters:
image (array): The original image array on which detection was performed.
bbox (tuple): A tuple containing the bounding box's relative coordinates (x, y, w, h)
where x and y are the center of the box, and w and h are width and height.
Returns:
tuple: A tuple containing the bounding box's original (absolute) coordinates.


| darknet_video.convert2relative | ( | bbox | ) |
Converts bounding box coordinates from absolute to relative values.
In YOLO, relative coordinates are used where the dimensions of the image are normalized to a range of 0 to 1.
Parameters:
bbox (tuple): A tuple containing the bounding box's absolute coordinates in the format (x, y, w, h).
Here, x and y represent the center of the box, while w and h are its width and height.
Returns:
tuple: A tuple containing the bounding box's relative coordinates.

| darknet_video.convert4cropping | ( | image, | |
| bbox | |||
| ) |
Converts relative bounding box coordinates to absolute coordinates suitable for cropping.
Parameters:
image (array): The original image array on which detection was performed.
bbox (tuple): A tuple containing the bounding box's relative coordinates (x, y, w, h)
where x and y are the center of the box, and w and h are width and height.
Returns:
tuple: A tuple containing the coordinates for cropping (left, top, right, bottom).

| darknet_video.drawing | ( | frame_queue, | |
| detections_queue, | |||
| fps_queue | |||
| ) |
Draws bounding boxes on frames and displays them. Parameters: frame_queue: Queue from which to retrieve frames. detections_queue: Queue from which to retrieve detections for each frame. fps_queue: Queue from which to retrieve frames per second (FPS) values. This function continuously retrieves frames and their corresponding detections, draws bounding boxes on the frames, and displays them. If an output filename is provided, it also writes the frames to a video file.

| darknet_video.inference | ( | darknet_image_queue, | |
| detections_queue, | |||
| fps_queue | |||
| ) |
Processes images using the Darknet YOLO framework for object detection. Parameters: darknet_image_queue: A queue containing images to be processed. detections_queue: A queue to put the detections for later use. fps_queue: A queue to put the calculated frames per second (FPS) values. This function continuously retrieves images from the darknet_image_queue, performs object detection on them, and puts the detections and FPS values into their respective queues. This allows for parallel processing and data handling in other threads.

| darknet_video.parse_args | ( | ) |
| darknet_video.set_saved_video | ( | input_video, | |
| output_video, | |||
| size | |||
| ) |

| darknet_video.signal_handler | ( | sig, | |
| frame | |||
| ) |
Handles a specific signal and stops the main loop.
| darknet_video.str2int | ( | video_path | ) |
argparse returns and string althout webcam uses int (0, 1 ...) Cast to int if needed

| darknet_video.video_capture | ( | frame_queue, | |
| darknet_image_queue | |||
| ) |
| darknet_video.args = parse_args() |
| darknet_video.cap = cv2.VideoCapture(input_path) |
| darknet_video.capture_thread = None |
| darknet_video.class_colors = darknet.class_colors(class_names) |
| darknet_video.class_names = open(args.data_file).read().splitlines() |
| darknet_video.darknet_height = darknet.network_height(network) |
| darknet_video.darknet_image_queue = Queue(maxsize=1) |
| darknet_video.darknet_width = darknet.network_width(network) |
| darknet_video.detections_queue = Queue(maxsize=1) |
| darknet_video.drawing_thread = None |
| darknet_video.fps_queue = Queue(maxsize=1) |
| int darknet_video.frame_delay = 30 |
| darknet_video.frame_queue = Queue() |
| darknet_video.inference_thread = None |
| darknet_video.input_path = str2int(args.input) |
| bool darknet_video.is_running = True |
| darknet_video.network = darknet.load_net_custom(args.config_file.encode("ascii"), args.weights.encode("ascii"), 0, 1) |
| darknet_video.video_height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT)) |
| darknet_video.video_width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)) |