Make sure we can't take the log10 of 0
This commit is contained in:
parent
fa15964b98
commit
4ca4d0c3cd
Binary file not shown.
Binary file not shown.
@ -180,6 +180,7 @@ def detect(calibration_width, img_file, show, quick):
|
|||||||
#orig = image.copy()
|
#orig = image.copy()
|
||||||
num += 1
|
num += 1
|
||||||
# if the contour is not sufficiently large, ignore it
|
# if the contour is not sufficiently large, ignore it
|
||||||
|
#pixelsPerMetric = 75
|
||||||
if cv2.contourArea(c) < 100 or pixelsPerMetric is None:
|
if cv2.contourArea(c) < 100 or pixelsPerMetric is None:
|
||||||
continue
|
continue
|
||||||
# compute the rotated bounding box of the contour
|
# compute the rotated bounding box of the contour
|
||||||
@ -319,7 +320,8 @@ def detect(calibration_width, img_file, show, quick):
|
|||||||
# cv2.putText(orig, "{:.5f}in".format(itemhr),
|
# cv2.putText(orig, "{:.5f}in".format(itemhr),
|
||||||
# (int(trbrX + 20), int(trbrY)), cv2.FONT_HERSHEY_SIMPLEX,
|
# (int(trbrX + 20), int(trbrY)), cv2.FONT_HERSHEY_SIMPLEX,
|
||||||
# 0.65, (255, 255, 255), 2)
|
# 0.65, (255, 255, 255), 2)
|
||||||
#objtype = magicSort(c)
|
if objtype != "Penny":
|
||||||
|
objtype = magicSort(c)
|
||||||
if objtype == "Unknown":
|
if objtype == "Unknown":
|
||||||
objtype = magicSort(c)
|
objtype = magicSort(c)
|
||||||
output = "{:.2f}in".format(itemw) + " x {:.2f}in".format(itemh)
|
output = "{:.2f}in".format(itemw) + " x {:.2f}in".format(itemh)
|
||||||
@ -370,6 +372,8 @@ def magicSort(contour):
|
|||||||
#magicNumber2 = 0
|
#magicNumber2 = 0
|
||||||
name = "Unknown"
|
name = "Unknown"
|
||||||
for i in range(0,7):
|
for i in range(0,7):
|
||||||
|
if humoments[i] == 0:
|
||||||
|
humoments[i] = 0.1;
|
||||||
humoments[i] = -1 * math.copysign(1.0, humoments[i]) * math.log10(abs(humoments[i]))
|
humoments[i] = -1 * math.copysign(1.0, humoments[i]) * math.log10(abs(humoments[i]))
|
||||||
if i > 1:
|
if i > 1:
|
||||||
humoments[i] = int(round(humoments[i][0] / 8) * 8)
|
humoments[i] = int(round(humoments[i][0] / 8) * 8)
|
||||||
|
BIN
img.jpg
BIN
img.jpg
Binary file not shown.
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 3.9 MiB |
@ -8,9 +8,9 @@ import time
|
|||||||
from imutils.video import FPS
|
from imutils.video import FPS
|
||||||
calibration_width = 0.75
|
calibration_width = 0.75
|
||||||
image = "img7.jpg"
|
image = "img7.jpg"
|
||||||
images = ("img2.jpg", "img3.jpg", "img4.jpg", "img5.jpg", "img6.jpg", "img7.jpg", "img8.jpg")
|
images = ("img.jpg", "img3.jpg", "img4.jpg", "img5.jpg", "img6.jpg", "img7.jpg", "img8.jpg")
|
||||||
#images = ("img.jpg", "img2.jpg")
|
#images = ("img.jpg", "img2.jpg")
|
||||||
video = False
|
video = True
|
||||||
def go():
|
def go():
|
||||||
for file in images:
|
for file in images:
|
||||||
items,output = detect.detect(calibration_width, file, True, False)
|
items,output = detect.detect(calibration_width, file, True, False)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user