imgdata package

Submodules

imgdata.coordinates module

filename

sppas.src.imgdata.coordinates.py

author

Florian Hocquet, Brigitte Bigi

contact

develop@sppas.org

summary

Data structure to represent an area with a confidence score.

class imgdata.coordinates.sppasCoords(x=0, y=0, w=0, h=0, confidence=None)[source]

Bases: object

Class to illustrate coordinates of an area.

A sppasCoords object represents the coordinates of an area in an image. It has 5 parameters:

  • x: coordinate on the x axis

  • y: coordinate on the y axis

  • w: width of the visage

  • h: height of the visage

  • an optional confidence score

Example

>>> c = sppasCoords(143, 17, 150, 98, 0.7)
>>> c.get_confidence()
>>> 0.7
>>> c.get_x()
>>> 143
>>> c.get_y()
>>> 17
>>> c.get_w()
>>> 150
>>> c.get_h()
>>> 98
MAX_H = 8640
MAX_W = 15360
__init__(x=0, y=0, w=0, h=0, confidence=None)[source]

Create a new sppasCoords instance.

Allows to represent a point (x,y), or a size(w,h) or both, with an optional confidence score ranging [0.0,1.0].

Parameters
  • x – (int) The x-axis value

  • y – (int) The y-axis value

  • w – (int) The width value

  • h – (int) The height value

  • confidence – (float) An optional confidence score ranging [0,1]

area()[source]

Return the area of the rectangle.

copy()[source]

Return a deep copy of the current sppasCoords.

get_confidence()[source]

Return the confidence value (float).

get_h()[source]

Return height value (int).

get_w()[source]

Return width value (int).

get_x()[source]

Return x-axis value (int).

get_y()[source]

Return y-axis value (int).

property h

Return height value (int).

intermediate(other)[source]

Return the coordinates with the intermediate position and size.

Parameters

other – (sppasCoords)

Returns

(sppasCoords)

intersection_area(other)[source]

Return the intersection area of two rectangles.

Parameters

other – (sppasCoords)

overlap(other)[source]

Return the 2 percentage of overlaps.

  1. the overlapped area is overlapping other of XX percent of its area.

  2. the overlapped area is overlapping self of XX percent of my area.

Parameters

other – (sppasCoords)

Returns

percentage of overlap of self in other and of other in self.

scale(coeff, image=None)[source]

Multiply width and height values with given coefficient value.

Parameters
  • coeff – (int) The value to multiply with.

  • image – (numpy.ndarray or sppasImage) An image to check w, h.

Returns

Returns the value of the shift to use on the x-axis,

according to the value of the scale in order to keep the same center. :raise: TypeError, ScaleWidthError, ScaleHeightError

set_confidence(value)[source]

Set confidence value.

Parameters

value – (float) The new confidence value ranging [0, 1].

Raise

TypeError, ValueError

shift(x_value=0, y_value=0, image=None)[source]

Shift position of (x,y) values.

Parameters
  • x_value – (int) The value to add to x-axis value.

  • y_value – (int) The value to add to y-axis value.

  • image – (numpy.ndarray or sppasImage) An image to check coords.

Raise

TypeError

static to_coords(coord)[source]

Check the given coord and return it as a sppasCoords instance.

static to_dtype(value, dtype=<class 'int'>, unsigned=True)[source]

Convert a value to int or raise the appropriate exception.

property w

Return width value (int).

property x

Return x-axis value (int).

property y

Return y-axis value (int).

imgdata.image module

imgdata.imageutils module

imgdata.imgcoordswriter module

imgdata.imgdataexc module

filename

sppas.src.imgdata.imgdataexc.py

author

Brigitte Bigi

contact

develop@sppas.org

summary

Image data exceptions.

exception imgdata.imgdataexc.ImageBoundError(value, img_value)[source]

Bases: ValueError

:ERROR 2330:.

The value {} can’t be superior to the one of the image {}.

__init__(value, img_value)[source]
exception imgdata.imgdataexc.ImageEastingError(value, img_value)[source]

Bases: ValueError

:ERROR 2336:.

The x-axis value {} can’t be superior to the width {} of the image.

__init__(value, img_value)[source]
exception imgdata.imgdataexc.ImageHeightError(value, img_value)[source]

Bases: ValueError

:ERROR 2334:.

The height value {} can’t be superior to the height {} of the image.

__init__(value, img_value)[source]
exception imgdata.imgdataexc.ImageNorthingError(value, img_value)[source]

Bases: ValueError

:ERROR 2338:.

The y-axis value {} can’t be superior to the height {} of the image.

__init__(value, img_value)[source]
exception imgdata.imgdataexc.ImageReadError(name)[source]

Bases: OSError

:ERROR 2610:.

Image of file {filename} can’t be read by opencv library.

__init__(name)[source]
exception imgdata.imgdataexc.ImageWidthError(value, img_value)[source]

Bases: ValueError

:ERROR 2332:.

The width value {} can’t be superior to the width {} of the image.

__init__(value, img_value)[source]
exception imgdata.imgdataexc.ImageWriteError(name)[source]

Bases: OSError

:ERROR 2620:.

Image of file {filename} can’t be written by opencv library.

__init__(name)[source]

imgdata.imgsequence module

imgdata.imgsimilarity module

imgdata.objdetec module

Module contents

filename

sppas.src.imgdata.__init__.py

author

Brigitte Bigi

contact

develop@sppas.org

summary

Package for the management of image files

imgdata: management of image files

Requires the following other packages:

  • config

Requires the following other external libraries:

  • opencv

  • numpy

If the video feature is not enabled, the sppasEnableFeatureError() is raised when a class is instantiated.

class imgdata.HaarCascadeDetector(*args, **kwargs)[source]

Bases: imgdata.sppasImageDataError

class imgdata.ImageSequence(*args, **kwargs)[source]

Bases: imgdata.sppasImageDataError

class imgdata.NeuralNetCaffeDetector(*args, **kwargs)[source]

Bases: imgdata.sppasImageDataError

class imgdata.NeuralNetONNXDetector(*args, **kwargs)[source]

Bases: imgdata.sppasImageDataError

class imgdata.NeuralNetTensorFlowDetector(*args, **kwargs)[source]

Bases: imgdata.sppasImageDataError

class imgdata.sppasCoords(x=0, y=0, w=0, h=0, confidence=None)[source]

Bases: object

Class to illustrate coordinates of an area.

A sppasCoords object represents the coordinates of an area in an image. It has 5 parameters:

  • x: coordinate on the x axis

  • y: coordinate on the y axis

  • w: width of the visage

  • h: height of the visage

  • an optional confidence score

Example

>>> c = sppasCoords(143, 17, 150, 98, 0.7)
>>> c.get_confidence()
>>> 0.7
>>> c.get_x()
>>> 143
>>> c.get_y()
>>> 17
>>> c.get_w()
>>> 150
>>> c.get_h()
>>> 98
MAX_H = 8640
MAX_W = 15360
__init__(x=0, y=0, w=0, h=0, confidence=None)[source]

Create a new sppasCoords instance.

Allows to represent a point (x,y), or a size(w,h) or both, with an optional confidence score ranging [0.0,1.0].

Parameters
  • x – (int) The x-axis value

  • y – (int) The y-axis value

  • w – (int) The width value

  • h – (int) The height value

  • confidence – (float) An optional confidence score ranging [0,1]

area()[source]

Return the area of the rectangle.

copy()[source]

Return a deep copy of the current sppasCoords.

get_confidence()[source]

Return the confidence value (float).

get_h()[source]

Return height value (int).

get_w()[source]

Return width value (int).

get_x()[source]

Return x-axis value (int).

get_y()[source]

Return y-axis value (int).

property h

Return height value (int).

intermediate(other)[source]

Return the coordinates with the intermediate position and size.

Parameters

other – (sppasCoords)

Returns

(sppasCoords)

intersection_area(other)[source]

Return the intersection area of two rectangles.

Parameters

other – (sppasCoords)

overlap(other)[source]

Return the 2 percentage of overlaps.

  1. the overlapped area is overlapping other of XX percent of its area.

  2. the overlapped area is overlapping self of XX percent of my area.

Parameters

other – (sppasCoords)

Returns

percentage of overlap of self in other and of other in self.

scale(coeff, image=None)[source]

Multiply width and height values with given coefficient value.

Parameters
  • coeff – (int) The value to multiply with.

  • image – (numpy.ndarray or sppasImage) An image to check w, h.

Returns

Returns the value of the shift to use on the x-axis,

according to the value of the scale in order to keep the same center. :raise: TypeError, ScaleWidthError, ScaleHeightError

set_confidence(value)[source]

Set confidence value.

Parameters

value – (float) The new confidence value ranging [0, 1].

Raise

TypeError, ValueError

shift(x_value=0, y_value=0, image=None)[source]

Shift position of (x,y) values.

Parameters
  • x_value – (int) The value to add to x-axis value.

  • y_value – (int) The value to add to y-axis value.

  • image – (numpy.ndarray or sppasImage) An image to check coords.

Raise

TypeError

static to_coords(coord)[source]

Check the given coord and return it as a sppasCoords instance.

static to_dtype(value, dtype=<class 'int'>, unsigned=True)[source]

Convert a value to int or raise the appropriate exception.

property w

Return width value (int).

property x

Return x-axis value (int).

property y

Return y-axis value (int).

class imgdata.sppasCoordsCompare(*args, **kwargs)[source]

Bases: imgdata.sppasImageDataError

class imgdata.sppasCoordsImageWriter(*args, **kwargs)[source]

Bases: imgdata.sppasImageDataError

class imgdata.sppasImage(*args, **kwargs)[source]

Bases: imgdata.sppasImageDataError

class imgdata.sppasImageCompare(*args, **kwargs)[source]

Bases: imgdata.sppasImageDataError

class imgdata.sppasImageCoordsReader(*args, **kwargs)[source]

Bases: imgdata.sppasImageDataError

class imgdata.sppasImageObjectDetection(*args, **kwargs)[source]

Bases: imgdata.sppasImageDataError

class imgdata.sppasImagesSimilarity(*args, **kwargs)[source]

Bases: imgdata.sppasImageDataError