-
Notifications
You must be signed in to change notification settings - Fork 314
/
PossibleChar.py
41 lines (22 loc) · 1.17 KB
/
PossibleChar.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# PossibleChar.py
import cv2
import numpy as np
import math
###################################################################################################
class PossibleChar:
# constructor #################################################################################
def __init__(self, _contour):
self.contour = _contour
self.boundingRect = cv2.boundingRect(self.contour)
[intX, intY, intWidth, intHeight] = self.boundingRect
self.intBoundingRectX = intX
self.intBoundingRectY = intY
self.intBoundingRectWidth = intWidth
self.intBoundingRectHeight = intHeight
self.intBoundingRectArea = self.intBoundingRectWidth * self.intBoundingRectHeight
self.intCenterX = (self.intBoundingRectX + self.intBoundingRectX + self.intBoundingRectWidth) / 2
self.intCenterY = (self.intBoundingRectY + self.intBoundingRectY + self.intBoundingRectHeight) / 2
self.fltDiagonalSize = math.sqrt((self.intBoundingRectWidth ** 2) + (self.intBoundingRectHeight ** 2))
self.fltAspectRatio = float(self.intBoundingRectWidth) / float(self.intBoundingRectHeight)
# end constructor
# end class