Darknet/YOLO v5.0-117-g31c55275-dirty
Object Detection Framework
 
Loading...
Searching...
No Matches
darknet_video Namespace Reference

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))
 

Function Documentation

◆ check_arguments_errors()

darknet_video.check_arguments_errors (   args)
Here is the call graph for this function:

◆ convert2original()

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.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ convert2relative()

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.
Here is the caller graph for this function:

◆ convert4cropping()

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).
Here is the call graph for this function:

◆ drawing()

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.
Here is the call graph for this function:

◆ inference()

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.
Here is the call graph for this function:

◆ parse_args()

darknet_video.parse_args ( )

◆ set_saved_video()

darknet_video.set_saved_video (   input_video,
  output_video,
  size 
)
Here is the caller graph for this function:

◆ signal_handler()

darknet_video.signal_handler (   sig,
  frame 
)
Handles a specific signal and stops the main loop.

◆ str2int()

darknet_video.str2int (   video_path)
argparse returns and string althout webcam uses int (0, 1 ...)
Cast to int if needed
Here is the caller graph for this function:

◆ video_capture()

darknet_video.video_capture (   frame_queue,
  darknet_image_queue 
)

Variable Documentation

◆ args

darknet_video.args = parse_args()

◆ cap

darknet_video.cap = cv2.VideoCapture(input_path)

◆ capture_thread

darknet_video.capture_thread = None

◆ class_colors

darknet_video.class_colors = darknet.class_colors(class_names)

◆ class_names

darknet_video.class_names = open(args.data_file).read().splitlines()

◆ darknet_height

darknet_video.darknet_height = darknet.network_height(network)

◆ darknet_image_queue

darknet_video.darknet_image_queue = Queue(maxsize=1)

◆ darknet_width

darknet_video.darknet_width = darknet.network_width(network)

◆ detections_queue

darknet_video.detections_queue = Queue(maxsize=1)

◆ drawing_thread

darknet_video.drawing_thread = None

◆ fps_queue

darknet_video.fps_queue = Queue(maxsize=1)

◆ frame_delay

int darknet_video.frame_delay = 30

◆ frame_queue

darknet_video.frame_queue = Queue()

◆ inference_thread

darknet_video.inference_thread = None

◆ input_path

darknet_video.input_path = str2int(args.input)

◆ is_running

bool darknet_video.is_running = True

◆ network

darknet_video.network = darknet.load_net_custom(args.config_file.encode("ascii"), args.weights.encode("ascii"), 0, 1)

◆ video_height

darknet_video.video_height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))

◆ video_width

darknet_video.video_width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))