improutils.acquisition package

Submodules

improutils.acquisition.img_io module

improutils.acquisition.img_io.copy_to(src, dst, mask)[source]

Copy source image pixel to destination image using mask matrix.

This function is Python alternative to C++/Java OpenCV’s Mat.copyTo(). More: https://docs.opencv.org/trunk/d3/d63/classcv_1_1Mat.html#a626fe5f96d02525e2604d2ad46dd574f

Parameters:
  • src (numpy.ndarray) – Source image

  • dst (numpy.ndarray) – Destination image

  • mask (numpy.ndarray) – Binary image that specifies which pixels are copied. Value 1 means true

Return type:

Destination image with copied pixels from source image

improutils.acquisition.img_io.load_image(file_path)[source]

Load an image from a file.

The function calls cv2.imread() to load image from the specified file and then return it. If the image cannot be read, the AssertError exception is thrown.

For more info about formats, see cv2.imread() documentation

Parameters:

file_path (string) – A path to an image file

Return type:

Loaded image in numpy.ndarray

improutils.acquisition.img_io.reindex_image_files(source_dir, output_dir=None)[source]

Read all images in source_dir and rename them to continuous integers.

Based on their original order, changes their filenames to be continuous integers (starting from 0). Then, they can be easily read by cv2.VideoCapture. Image format is kept.

Parameters:
  • source_dir (string) – Input images directory that have to be renamed.

  • output_dir (Optional[string]) – Output directory for renamed files. If not specified, renaming is done inplace in source_dir.

Return type:

None

improutils.acquisition.img_io.save_image(image, file_path)[source]

Save an image to a file.

The function calls cv2.imwrite() to save an image to the specified file. The image format is chosen based on the filename extension.

Parameters:
  • image (numpy.ndarray) – Pixel values

  • file_path (string) – A path to an image file

Return type:

True if image is saved successfully

improutils.acquisition.pypylon module

improutils.acquisition.pypylon.connect_camera(serial_number)[source]

Connect the camera specified with its serial number.

Parameters:

serial_number (string) – The camera’s serial number.

Returns:

camera

Return type:

object

improutils.acquisition.pypylon_config module

Module contents

improutils.acquisition.connect_camera(serial_number)[source]

Connect the camera specified with its serial number.

Parameters:

serial_number (string) – The camera’s serial number.

Returns:

camera

Return type:

object

improutils.acquisition.copy_to(src, dst, mask)[source]

Copy source image pixel to destination image using mask matrix.

This function is Python alternative to C++/Java OpenCV’s Mat.copyTo(). More: https://docs.opencv.org/trunk/d3/d63/classcv_1_1Mat.html#a626fe5f96d02525e2604d2ad46dd574f

Parameters:
  • src (numpy.ndarray) – Source image

  • dst (numpy.ndarray) – Destination image

  • mask (numpy.ndarray) – Binary image that specifies which pixels are copied. Value 1 means true

Return type:

Destination image with copied pixels from source image

improutils.acquisition.load_image(file_path)[source]

Load an image from a file.

The function calls cv2.imread() to load image from the specified file and then return it. If the image cannot be read, the AssertError exception is thrown.

For more info about formats, see cv2.imread() documentation

Parameters:

file_path (string) – A path to an image file

Return type:

Loaded image in numpy.ndarray

improutils.acquisition.reindex_image_files(source_dir, output_dir=None)[source]

Read all images in source_dir and rename them to continuous integers.

Based on their original order, changes their filenames to be continuous integers (starting from 0). Then, they can be easily read by cv2.VideoCapture. Image format is kept.

Parameters:
  • source_dir (string) – Input images directory that have to be renamed.

  • output_dir (Optional[string]) – Output directory for renamed files. If not specified, renaming is done inplace in source_dir.

Return type:

None

improutils.acquisition.save_image(image, file_path)[source]

Save an image to a file.

The function calls cv2.imwrite() to save an image to the specified file. The image format is chosen based on the filename extension.

Parameters:
  • image (numpy.ndarray) – Pixel values

  • file_path (string) – A path to an image file

Return type:

True if image is saved successfully