mirror of
https://github.com/qurator-spk/eynollah.git
synced 2026-07-26 05:29:16 +02:00
cnn-rnn-ocr: fix
This commit is contained in:
parent
5d129dc8c1
commit
aace571368
1 changed files with 5 additions and 4 deletions
|
|
@ -182,10 +182,11 @@ def get_orientation_moments(contour):
|
||||||
|
|
||||||
def get_orientation_moments_of_mask(mask):
|
def get_orientation_moments_of_mask(mask):
|
||||||
mask=mask.astype('uint8')
|
mask=mask.astype('uint8')
|
||||||
contours, _ = cv2.findContours(mask[:,:,0], cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
|
contours, _ = cv2.findContours(mask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
|
||||||
|
|
||||||
largest_contour = max(contours, key=cv2.contourArea) if contours else None
|
if not len(contours):
|
||||||
|
return 0
|
||||||
|
largest_contour = max(contours, key=cv2.contourArea)
|
||||||
moments = cv2.moments(largest_contour)
|
moments = cv2.moments(largest_contour)
|
||||||
if moments["mu20"] - moments["mu02"] == 0: # Avoid division by zero
|
if moments["mu20"] - moments["mu02"] == 0: # Avoid division by zero
|
||||||
return 90 if moments["mu11"] > 0 else -90
|
return 90 if moments["mu11"] > 0 else -90
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue