RoboCarts
Functions
frame_processing Namespace Reference

Functions

def flip (img)
 
def rotate (img, count)
 
def resize (img, scale)
 
def frame_adjustment (img, scale_resize, num_rotate, num_flip)
 
def cut_image (img, left_corn, right_corn)
 
def morph_open (binary_img, kernel_size=15)
 
def morph_close (binary_img, kernel_size=15)
 
def morph_close_open (binary_img, kernel_size=25)
 
def get_canny (img, lower=50, upper=200)
 
def draw_edges (edges, img)
 
def turn_to_hsv (img, blur_kernel_size=7)
 
def mask_img (img, mask)
 
def convex_hull (cnt)
 
def find_contours (mask, ret_mode="tree", rgb_input=False)
 
def draw_contours (contours, frame, centre=False)
 
def diff_rgb (img1, img2)
 
def diff_hsv (img1, img2)
 
def binary_threshold (diff, t_value)
 
def make_histogram_bgr (img)
 
def adjust_cropped_rectangles_to_orig_img (rectangles, original_rectangle)
 

Detailed Description

@file frame_processing.py
@brief This file contains functions for various operations with individual frames

Function Documentation

◆ adjust_cropped_rectangles_to_orig_img()

def frame_processing.adjust_cropped_rectangles_to_orig_img (   rectangles,
  original_rectangle 
)
Adjusts the positions of cut out image parts relatively to the original image
:param rectangles: cut out rectangles
:param original_rectangle: original rectangular image
:return: adjusted rectangles

◆ binary_threshold()

def frame_processing.binary_threshold (   diff,
  t_value 
)
Function for binary thresholding of a grayscale image
:param diff: greyscale source image
:param t_value: threshold value
:return: thresholded binary image

◆ convex_hull()

def frame_processing.convex_hull (   cnt)
Makes a convex hull from a contour
:param cnt: original contour
:return: convex hull

◆ cut_image()

def frame_processing.cut_image (   img,
  left_corn,
  right_corn 
)
Crops a rectangle from an image
:param img: source image
:param left_corn: left corner of the cropping rectangle
:param right_corn: right corner of the cropping rectangle
:return: cropped rectangle

◆ diff_hsv()

def frame_processing.diff_hsv (   img1,
  img2 
)
Makes an image difference of two HSV images
:param img1: HSV image 1
:param img2: HSV image 2
:return: grayscale image difference

◆ diff_rgb()

def frame_processing.diff_rgb (   img1,
  img2 
)
Makes an image difference of two RGB images
:param img1: RGB image 1
:param img2: RGB image 2
:return: grayscale image difference

◆ draw_contours()

def frame_processing.draw_contours (   contours,
  frame,
  centre = False 
)
Draws contours on an image
:param contours: contours
:param frame: source image
:param centre: option to draw contour centroids
:return: -

◆ draw_edges()

def frame_processing.draw_edges (   edges,
  img 
)
Draws edges to an image
:param edges: image edges
:param img: image on which the edges will be displayed on
:return: image with contours

◆ find_contours()

def frame_processing.find_contours (   mask,
  ret_mode = "tree",
  rgb_input = False 
)
Finds contours in a binary image with a specific mode
:param mask: source binary image
:param ret_mode: mode for the contours output ("external", "list", "tree")
:param rgb_input: flag for binary/rgb source image
:return: list of contours

◆ flip()

def frame_processing.flip (   img)
Flips an image orientation alongside the horizontal axes
:param img: source image
:return: flipped img

◆ frame_adjustment()

def frame_processing.frame_adjustment (   img,
  scale_resize,
  num_rotate,
  num_flip 
)
Function for resizing and rotating frames
:param num_flip: how many times to flip
:param num_rotate: how many times to rotate
:param scale_resize: resizing scale
:param img: source image
:return: adjusted frame

◆ get_canny()

def frame_processing.get_canny (   img,
  lower = 50,
  upper = 200 
)
Function for finding edges in a grayscale image using the Canny detection algorithm
:param img: source image
:param lower: lower threshold value for Canny algorithm
:param upper: upper threshold value for Canny algorithm
:return: binary image with detected edges

◆ make_histogram_bgr()

def frame_processing.make_histogram_bgr (   img)
Makes a normalized histogram from an RGB image
:param img: source RGB image
:return: histogram

◆ mask_img()

def frame_processing.mask_img (   img,
  mask 
)
Masks regions on an image based on a binary mask
:param img: source image
:param mask: binary mask
:return: masked image

◆ morph_close()

def frame_processing.morph_close (   binary_img,
  kernel_size = 15 
)
Function for morphological closing of a binary image with ellipsoidal structuring element/kernel
:param binary_img: source binary image
:param kernel_size: kernel size
:return: morphed img

◆ morph_close_open()

def frame_processing.morph_close_open (   binary_img,
  kernel_size = 25 
)
Function for morphological opening and closing of a binary image with ellipsoidal structuring element/kernel
:param binary_img: source binary image
:param kernel_size: kernel size
:return: morphed img

◆ morph_open()

def frame_processing.morph_open (   binary_img,
  kernel_size = 15 
)
Function for morphological opening of a binary image with ellipsoidal structuring element/kernel
:param binary_img: source binary image
:param kernel_size: kernel size
:return: morphed image

◆ resize()

def frame_processing.resize (   img,
  scale 
)
Resizes an image's width and height based on the scale
:param img: source image
:param scale: scale in range 0.0 - inf
:return: resized img

◆ rotate()

def frame_processing.rotate (   img,
  count 
)
Rotates an image for 90° to the right (clockwise)
:param count: how many time should be the source image rotated
:param img: source image
:return: rotated img

◆ turn_to_hsv()

def frame_processing.turn_to_hsv (   img,
  blur_kernel_size = 7 
)
Auxiliary function to blur and turn an RGB image to an HSV image
:param blur_kernel_size: size of the kernel for blurring
:param img: source RGB image
:return: HSV image