pypocquant.lib.tools

Module Contents

Functions

extract_strip(image, qr_code_border, strip_try_correct_orientation, strip_try_correct_orientation_rects=(0.52, 0.15, 0.09), stretch_for_hough=False, strip_text_to_search='', strip_text_on_right=True)

Attempts to extract the strip from the original image.

pypocquant.lib.tools.extract_strip(image, qr_code_border, strip_try_correct_orientation, strip_try_correct_orientation_rects=(0.52, 0.15, 0.09), stretch_for_hough=False, strip_text_to_search='', strip_text_on_right=True)

Attempts to extract the strip from the original image.

Parameters
  • image (numpy array) – RGB image to be processed.

  • qr_code_border (int) – Lateral and vertical extension of the (white) border around each QR code.

  • strip_try_correct_orientation (bool) – Try to assess and possibly correct for wrong orientation of the strip by searching for the position of the injection inlet.

  • strip_try_correct_orientation_rects (tuple) –

    Tuple containing information about the relative position of the two rectangles to be searched for the inlet on both sides of the center of the image:

    rectangle_props[0]: relative (0..1) vertical height of the rectangle with

    respect to the image height.

    rectangle_props[1]: relative (0..1) distance of the left edge of the right rectangle

    with respect to the center of the image.

    rectangle_props[2]: relative (0..1) distance of the left edge of the left rectangle

    with respect to the center of the image.

  • stretch_for_hough (bool (default, False)) – Set to True to apply auto-stretch to the image for Hough detection (1, 99 percentile).

  • strip_text_to_search (str) – str Text to search on the strip to assess orientation. Set to “” to skip.

  • strip_text_on_right (bool) – Assuming the strip is oriented horizontally, whether the ‘strip_text_to_search’ text is assumed to be on the right. If ‘strip_text_on_right’ is True and the text is found on the left hand-side of the strip, the strip will be rotated 180 degrees. Ignored if strip_text_to_search is “”.

Returns

strip_for_analysis: Strip image (RGB) or None if extraction fails.

Returns

error_msg: If strip is None, the cause of failure will be stored in error_message.

Returns

left_rect: Detected Hough circles in left_rect.

Returns

right_rect: Detected Hough circles in right_rect.

Return type

tuple