Welcome to labvision’s documentation!

Lab vision provides a range of tools to collect, manipulate and store images / video.

Contents

Installation

The project can be installed and maintained using pip

Initial Installation

pip install git+https://github.com/MikeSmithLabTeam/labvision

Update

pip install –upgrade git+https://github.com/MikeSmithLabTeam/labvision

Camera

Camera contains classes for controlling webcams through opencv and digital cameras via the linux tool gphoto2. The timer provides a simple way to perform timelapse imaging.

Camera

Camera Config

Web camera settings All settings are accessible via self.cam_type in CameraBase class Only required settings are 1 resolution and 1 fps. Can add any optional info you want.

labvision.camera.camera_config.MIKELAPTOP = {'fps': (20.0,), 'res': (640, 480, 3)}

Digital Camera settings Acquisition settings for digital cameras need their own script. See nikon_config.sh for example in scripts folder. You may need to change permissions to make this file executable.

Digtal Cameras

Quick Timer

Images

Images contains a host of methods for interacting with and manipulating images.

Basics

Contours

cropping

Draw

labvision.images.draw.draw_filled_polygon(im, points, color=(0, 0, 255))

Adds a filled polygon to an image

Parameters:
  • im – np.ndarrary of dtype np.uint8
  • points – N, 2 ndarray of corner points
  • color – BGR color tuple or images library color
Returns:

im: ndarray

labvision.images.draw.draw_circle(im, cx, cy, rad, color=(0, 255, 255), thickness=2)

Draw Circle NEEDS DOCSTRING

Parameters:
  • im
  • cx
  • cy
  • rad
  • color
  • thickness
Returns:

labvision.images.draw.draw_circles(im, circles, color=(0, 255, 255), thickness=2)

NEEDS DOCSTRING

Parameters:
  • im
  • circles
  • color
  • thickness
Returns:

labvision.images.draw.draw_circles_with_scale(im, circles, values, cmap=<sphinx.ext.autodoc.importer._MockObject object>, thickness=2)

NEEDS DOCSTRING

Parameters:
  • im
  • circles
  • values
  • cmap
  • thickness
Returns:

labvision.images.draw.draw_delaunay_tess(im, points)

Draws the delaunay tesselation for a set of points on an image

Parameters:
  • im (input image) – Any number of channels
  • points (array of N points) – Shape (N, 2). points[:, 0] contains x coordinates points[:, 1] contains y coordinates
Returns:

in – Same shape and type as input image

Return type:

annotated image

labvision.images.draw.draw_polygon(im, vertices, color=(0, 0, 255), thickness=1)

Draws a polygon on an image from a list of vertices

Parameters:
  • im (input image) – Any number of channels
  • vertices (array of N vertices) –
    Shape (N, 2) where
    vertices[:, 0] contains x coordinates vertices[:, 1] contains y coordinates
  • color (BGR tuple) – if input image is grayscale then circles will be black
  • thickness (int) – Thickness of the lines
Returns:

out – Same shape and type as input image

Return type:

output image

labvision.images.draw.draw_polygons(im, polygons, color=(0, 0, 255))

Draws multiple polygons on an image from a list of polygons

Parameters:
  • im (input image) – Any number of channels
  • polygons (array containing coordinates of polygons) – shape is (P, N, 2) where P is the number of polygons, N is the number of vertices in each polygon. [:, :, 0] contains x coordinates, [:, :, 1] contains y coordinates.
  • color (BGR tuple) –
Returns:

img – Same shape and type as input image

Return type:

annotated image

labvision.images.draw.draw_voronoi_cells(im, points)

Draws the voronoi cells for a set of points on an image

Parameters:
  • im (input image) – Any number of channels
  • points (array of N points) – Shape (N, 2). points[:, 0] contains x coordinates points[:, 1] contains y coordinates
Returns:

im – Same shape and type as input image

Return type:

annotated image

labvision.images.draw.draw_contours(im, contours, col=(0, 0, 255), thickness=1)

NEEDS DOCSTRING

Parameters:
  • im
  • contours
  • col
  • thickness
Returns:

Feature Detection

Geometric

Gui

Gui Base

Morphological

Smoothing

Thresholding

Video

Video contains an implementation of OpenCV and FFMPEG to read and write videos. Shape

OpenCV Video

FFMPEG Video

Shape and Size

Indices and tables