module documentation

Undocumented

Function add_annotation_to_image Add Annotation to an image
Function biggest_contour_finder Undocumented
Function biggest_contours_finder Function to find the biggest contour in an binary image
Function compress_image Compress OpenCV image
Function concat_imgs Concat multiple images along 1 axis
Function debug_markers Display detected markers on an image
Function debug_threshold_color Return masked image to see the effect of color threshold
Function draw_contours Draw a list of contour on an image and return the drawing image
Function extract_img_from_ros_msg Take a ROS CompressedImage message and return the image uncompressed
Function extract_img_workspace Extract working area from an image thanks to 4 Niryo's markers
Function get_contour_angle Return orientation of a contour according to the smallest side in order to be well oriented for gripper
Function get_contour_barycenter Return barycenter of an OpenCV Contour
Function improve_mask Improve binary mask with morphological operation
Function morphological_transformations Take black & white image and apply morphological transformation
Function relative_pos_from_pixels Transform a pixels position to a relative position
Function resize_img Resize an image. The user should precise only width or height if he wants to keep image's ratio
Function show_and_check_close Display an image and check whether the user want to close
Function show_and_wait_close Display an image and wait that the user close it
Function show_img Display an image during a certain time
Function threshold_blue Threshold hsv image of blue component :param img_hsv: hsv image to be threshold :type img_hsv: numpy.array :param blue_img: threshold img :rtype: numpy.array
Function threshold_green Threshold hsv image of green component :param img_hsv: hsv image to be threshold :type img_hsv: numpy.array :param green_img: threshold img :rtype: numpy.array
Function threshold_hsv Take BGR image (OpenCV imread result) and return thresholded image according to values on HSV (Hue, Saturation, Value) Pixel will worth 1 if a pixel has a value between min_v and max_v for all channels...
Function threshold_red Threshold hsv image of red component :param img_hsv: hsv image to be threshold :type img_hsv: numpy.array :param red_img: threshold img :rtype: numpy.array
Function uncompress_image Take a compressed img and return an OpenCV image
Function undistort_image Use camera intrinsics to undistort raw image
Variable keys_leave Undocumented
def add_annotation_to_image(img, text, write_on_top=True):

Add Annotation to an image

Parameters
img:numpy.arrayImage
text:strtext string
write_on_top:boolif you write the text on top
Returns
numpy.arrayimg with text written on it
def biggest_contour_finder(img):

Undocumented

def biggest_contours_finder(img, nb_contours_max=3):

Function to find the biggest contour in an binary image

Parameters
img:numpy.arrayBinary Image
nb_contours_max:intmaximal number of contours which will be returned
Returns
list[OpenCV Contour]biggest contours found
def compress_image(img, quality=90):

Compress OpenCV image

Parameters
img:numpy.arrayOpenCV Image
quality:intinteger between 1 - 100. The higher it is, the less information will be lost, but the heavier the compressed image will be
Returns
bool, strstatus & string representing compressed image
def concat_imgs(tuple_imgs, axis=1):

Concat multiple images along 1 axis

Parameters
tuple_imgs:tuple[numpy.array]tuple of images
axis:int0 means vertically and 1 means horizontally
Returns
numpy.arrayConcat image
def debug_markers(img, workspace_ratio=1.0):

Display detected markers on an image

Parameters
img:numpy.arrayOpenCV image which contain Niryo's markers
workspace_ratio:floatRatio between the width and the height of the area represented by the markers
Returns
numpy.array(status, annotated image)
def debug_threshold_color(img, color_hsv):

Return masked image to see the effect of color threshold

Parameters
img:numpy.arrayOpenCV image
color_hsv:ColorHSVColor used for debug
Returns
numpy.arrayMasked image
def draw_contours(img, contours):

Draw a list of contour on an image and return the drawing image

Parameters
img:numpy.arrayImage
contours:list[OpenCV Contour]contours list
Returns
numpy.arrayImage with drawing
def extract_img_from_ros_msg(ros_msg):

Take a ROS CompressedImage message and return the image uncompressed

Parameters
ros_msg::sensor_msgs:`CompressedImage`a ROS CompressedImage
Returns
numpy.arrayimage uncompressed
def extract_img_workspace(img, workspace_ratio=1.0):

Extract working area from an image thanks to 4 Niryo's markers

Parameters
img:numpy.arrayOpenCV image which contain 4 Niryo's markers
workspace_ratio:floatRatio between the width and the height of the area represented by the markers
Returns
numpy.arrayextracted and warped working area image
def get_contour_angle(contour):

Return orientation of a contour according to the smallest side in order to be well oriented for gripper

Parameters
contour:OpenCV Contourcontour
Returns
floatAngle in radians
def get_contour_barycenter(contour):

Return barycenter of an OpenCV Contour

Parameters
contour:OpenCV Contour
Returns
int, intBarycenter X, Barycenter Y
def improve_mask(mask):

Improve binary mask with morphological operation

Parameters
mask:numpy.arrayinput mask to improve
Returns
numpy.arraymask improved
def morphological_transformations(im_thresh, morpho_type=MorphoType.CLOSE, kernel_shape=(5, 5), kernel_type=KernelType.ELLIPSE):

Take black & white image and apply morphological transformation

Parameters
im_thresh:numpy.arrayBlack & White Image
morpho_type:MorphoTypeCLOSE/OPEN/ERODE/DILATE => See on OpenCV/Google if you do not know these words
kernel_shape:tuple[float]tuple corresponding to the size of the kernel
kernel_type:KernelTypeRECT/ELLIPSE/CROSS => see on OpenCV
Returns
numpy.arrayimage after processing
def relative_pos_from_pixels(img, x_pixels, y_pixels):

Transform a pixels position to a relative position

Parameters
img:numpy.arrayImage where the object is detected
x_pixels:intcoordinate X
y_pixels:intcoordinate Y
Returns
float, floatX relative, Y relative
def resize_img(img, width=None, height=None, inter=cv2.INTER_AREA):

Resize an image. The user should precise only width or height if he wants to keep image's ratio

Parameters
img:numpy.arrayOpenCV Image
width:intTarget Width
height:intTarget Height
inter:longOpenCV interpolation flag
Returns
numpy.arrayresized image
def show_and_check_close(window_name, img):

Display an image and check whether the user want to close

Parameters
window_name:strwindow's name
img:numpy.arrayImage
Returns
boolboolean indicating if the user wanted to leave
def show_and_wait_close(window_name, img):

Display an image and wait that the user close it

Parameters
window_name:strwindow's name
img:numpy.arrayImage
Returns
NoneNone
def show_img(window_name, img, wait_ms=1):

Display an image during a certain time

Parameters
window_name:strwindow's name
img:numpy.arrayImage
wait_ms:intWait time in milliseconds
Returns
intvalue of the key pressed during the display
def threshold_blue(img_hsv):

Threshold hsv image of blue component :param img_hsv: hsv image to be threshold :type img_hsv: numpy.array :param blue_img: threshold img :rtype: numpy.array

def threshold_green(img_hsv):

Threshold hsv image of green component :param img_hsv: hsv image to be threshold :type img_hsv: numpy.array :param green_img: threshold img :rtype: numpy.array

def threshold_hsv(img, color_hsv):

Take BGR image (OpenCV imread result) and return thresholded image according to values on HSV (Hue, Saturation, Value) Pixel will worth 1 if a pixel has a value between min_v and max_v for all channels

Parameters
img:numpy.arrayimage BGR if rgb_space = False
color_hsvUndocumented
Returns
numpy.arraythreshold image
def threshold_red(img_hsv):

Threshold hsv image of red component :param img_hsv: hsv image to be threshold :type img_hsv: numpy.array :param red_img: threshold img :rtype: numpy.array

def uncompress_image(compressed_image):

Take a compressed img and return an OpenCV image

Parameters
compressed_image:strcompressed image
Returns
numpy.arrayOpenCV image
def undistort_image(img, mtx, dist):

Use camera intrinsics to undistort raw image

Parameters
img:numpy.arrayRaw Image
mtx:list[list[float]]Camera Intrinsics matrix
dist:list[list[float]]Distortion Coefficient
Returns
numpy.arrayUndistorted image
keys_leave =

Undocumented