(self,
                 imageName,
                 classId,
                 x,
                 y,
                 w,
                 h,
                 typeCoordinates=CoordinatesType.Absolute,
                 imgSize=None,
                 bbType=BBType.GroundTruth,
                 classConfidence=None,
                 format=BBFormat.XYWH)
Constructor.
        Args:
            imageName: String representing the image name.
            classId: String value representing class id.
            x: Float value representing the X upper-left coordinate of the bounding box.
            y: Float value representing the Y upper-left coordinate of the bounding box.
            w: Float value representing the width bounding box.
            h: Float value representing the height bounding box.
            typeCoordinates: (optional) Enum (Relative or Absolute) represents if the bounding box
            coordinates (x,y,w,h) are absolute or relative to size of the image. Default:'Absolute'.
            imgSize: (optional) 2D vector (width, height)=>(int, int) represents the size of the
            image of the bounding box. If typeCoordinates is 'Relative', imgSize is required.
            bbType: (optional) Enum (Groundtruth or Detection) identifies if the bounding box
            represents a ground truth or a detection. If it is a detection, the classConfidence has
            to be informed.
            classConfidence: (optional) Float value representing the confidence of the detected
            class. If detectionType is Detection, classConfidence needs to be informed.
            format: (optional) Enum (BBFormat.XYWH or BBFormat.XYX2Y2) indicating the format of the
            coordinates of the bounding boxes. BBFormat.XYWH: <left> <top> <width> <height>
            BBFormat.XYX2Y2: <left> <top> <right> <bottom>.
Constructor.
        Args:
            imageName: String representing the image name.
            classId: String value representing class id.
            x: Float value representing the X upper-left coordinate of the bounding box.
            y: Float value representing the Y upper-left coordinate of the bounding box.
            w: Float value representing the width bounding box.
            h: Float value representing the height bounding box.
            typeCoordinates: (optional) Enum (Relative or Absolute) represents if the bounding box
            coordinates (x,y,w,h) are absolute or relative to size of the image. Default:'Absolute'.
            imgSize: (optional) 2D vector (width, height)=>(int, int) represents the size of the
            image of the bounding box. If typeCoordinates is 'Relative', imgSize is required.
            bbType: (optional) Enum (Groundtruth or Detection) identifies if the bounding box
            represents a ground truth or a detection. If it is a detection, the classConfidence has
            to be informed.
            classConfidence: (optional) Float value representing the confidence of the detected
            class. If detectionType is Detection, classConfidence needs to be informed.
            format: (optional) Enum (BBFormat.XYWH or BBFormat.XYX2Y2) indicating the format of the
            coordinates of the bounding boxes. BBFormat.XYWH: <left> <top> <width> <height>
            BBFormat.XYX2Y2: <left> <top> <right> <bottom>.
Constructor . Args : imageName : String representing the image name . classId : String value representing class id . x : Float value representing the X upper - left coordinate of the bounding box . y : Float value representing the Y upper - left coordinate of the bounding box . w : Float value representing the width bounding box . h : Float value representing the height bounding box . typeCoordinates : ( optional ) Enum ( Relative or Absolute ) represents if the bounding box coordinates ( x y w h ) are absolute or relative to size of the image . Default : Absolute . imgSize : ( optional ) 2D vector ( width height ) = > ( int int ) represents the size of the image of the bounding box . If typeCoordinates is Relative imgSize is required . bbType : ( optional ) Enum ( Groundtruth or Detection ) identifies if the bounding box represents a ground truth or a detection . If it is a detection the classConfidence has to be informed . classConfidence : ( optional ) Float value representing the confidence of the detected class . If detectionType is Detection classConfidence needs to be informed . format : ( optional ) Enum ( BBFormat . XYWH or BBFormat . XYX2Y2 ) indicating the format of the coordinates of the bounding boxes . BBFormat . XYWH : <left > <top > <width > <height > BBFormat . XYX2Y2 : <left > <top > <right > <bottom > .
def __init__(self,
                 imageName,
                 classId,
                 x,
                 y,
                 w,
                 h,
                 typeCoordinates=CoordinatesType.Absolute,
                 imgSize=None,
                 bbType=BBType.GroundTruth,
                 classConfidence=None,
                 format=BBFormat.XYWH):
        """Constructor.
        Args:
            imageName: String representing the image name.
            classId: String value representing class id.
            x: Float value representing the X upper-left coordinate of the bounding box.
            y: Float value representing the Y upper-left coordinate of the bounding box.
            w: Float value representing the width bounding box.
            h: Float value representing the height bounding box.
            typeCoordinates: (optional) Enum (Relative or Absolute) represents if the bounding box
            coordinates (x,y,w,h) are absolute or relative to size of the image. Default:'Absolute'.
            imgSize: (optional) 2D vector (width, height)=>(int, int) represents the size of the
            image of the bounding box. If typeCoordinates is 'Relative', imgSize is required.
            bbType: (optional) Enum (Groundtruth or Detection) identifies if the bounding box
            represents a ground truth or a detection. If it is a detection, the classConfidence has
            to be informed.
            classConfidence: (optional) Float value representing the confidence of the detected
            class. If detectionType is Detection, classConfidence needs to be informed.
            format: (optional) Enum (BBFormat.XYWH or BBFormat.XYX2Y2) indicating the format of the
            coordinates of the bounding boxes. BBFormat.XYWH: <left> <top> <width> <height>
            BBFormat.XYX2Y2: <left> <top> <right> <bottom>.
        """
        self._imageName = imageName
        self._typeCoordinates = typeCoordinates
        if typeCoordinates == CoordinatesType.Relative and imgSize is None:
            raise IOError(
                'Parameter \'imgSize\' is required. It is necessary to inform the image size.')
        if bbType == BBType.Detected and classConfidence is None:
            raise IOError(
                'For bbType=\'Detection\', it is necessary to inform the classConfidence value.')
        # if classConfidence != None and (classConfidence < 0 or classConfidence > 1):
        # raise IOError('classConfidence value must be a real value between 0 and 1. Value: %f' %
        # classConfidence)

        self._classConfidence = classConfidence
        self._bbType = bbType
        self._classId = classId
        self._format = format

        # If relative coordinates, convert to absolute values
        # For relative coords: (x,y,w,h)=(X_center/img_width , Y_center/img_height)
        if (typeCoordinates == CoordinatesType.Relative):
            (self._x, self._y, self._w, self._h) = convertToAbsoluteValues(imgSize, (x, y, w, h))
            self._width_img = imgSize[0]
            self._height_img = imgSize[1]
            if format == BBFormat.XYWH:
                self._x2 = self._w
                self._y2 = self._h
                self._w = self._x2 - self._x
                self._h = self._y2 - self._y
            else:
                raise IOError(
                    'For relative coordinates, the format must be XYWH (x,y,width,height)')
        # For absolute coords: (x,y,w,h)=real bb coords
        else:
            self._x = x
            self._y = y
            if format == BBFormat.XYWH:
                self._w = w
                self._h = h
                self._x2 = self._x + self._w
                self._y2 = self._y + self._h
            else:  # format == BBFormat.XYX2Y2: <left> <top> <right> <bottom>.
                self._x2 = w
                self._y2 = h
                self._w = self._x2 - self._x
                self._h = self._y2 - self._y
        if imgSize is None:
            self._width_img = None
            self._height_img = None
        else:
            self._width_img = imgSize[0]
            self._height_img = imgSize[1]
def __init__ ( self , imageName , classId , x , y , w , h , typeCoordinates = CoordinatesType . Absolute , imgSize = None , bbType = BBType . GroundTruth , classConfidence = None , format = BBFormat . XYWH ) : self . _imageName = imageName self . _typeCoordinates = typeCoordinates if typeCoordinates == CoordinatesType . Relative and imgSize is None : raise IOError ( 'Parameter \'imgSize\' is required. It is necessary to inform the image size.' ) if bbType == BBType . Detected and classConfidence is None : raise IOError ( 'For bbType=\'Detection\', it is necessary to inform the classConfidence value.' ) # if classConfidence != None and (classConfidence < 0 or classConfidence > 1): # raise IOError('classConfidence value must be a real value between 0 and 1. Value: %f' % # classConfidence) self . _classConfidence = classConfidence self . _bbType = bbType self . _classId = classId self . _format = format # If relative coordinates, convert to absolute values # For relative coords: (x,y,w,h)=(X_center/img_width , Y_center/img_height) if ( typeCoordinates == CoordinatesType . Relative ) : ( self . _x , self . _y , self . _w , self . _h ) = convertToAbsoluteValues ( imgSize , ( x , y , w , h ) ) self . _width_img = imgSize [ 0 ] self . _height_img = imgSize [ 1 ] if format == BBFormat . XYWH : self . _x2 = self . _w self . _y2 = self . _h self . _w = self . _x2 - self . _x self . _h = self . _y2 - self . _y else : raise IOError ( 'For relative coordinates, the format must be XYWH (x,y,width,height)' ) # For absolute coords: (x,y,w,h)=real bb coords else : self . _x = x self . _y = y if format == BBFormat . XYWH : self . _w = w self . _h = h self . _x2 = self . _x + self . _w self . _y2 = self . _y + self . _h else : # format == BBFormat.XYX2Y2: <left> <top> <right> <bottom>. self . _x2 = w self . _y2 = h self . _w = self . _x2 - self . _x self . _h = self . _y2 - self . _y if imgSize is None : self . _width_img = None self . _height_img = None else : self . _width_img = imgSize [ 0 ] self . _height_img = imgSize [ 1 ]