diff --git a/__pycache__/detect.cpython-38.pyc b/__pycache__/detect.cpython-38.pyc index 8c6053a..5bec0fd 100644 Binary files a/__pycache__/detect.cpython-38.pyc and b/__pycache__/detect.cpython-38.pyc differ diff --git a/detect.cpython-38-x86_64-linux-gnu.so b/detect.cpython-38-x86_64-linux-gnu.so deleted file mode 100755 index 3265455..0000000 Binary files a/detect.cpython-38-x86_64-linux-gnu.so and /dev/null differ diff --git a/detect.py b/detect.py index 98136f5..eb91b7e 100644 --- a/detect.py +++ b/detect.py @@ -180,6 +180,7 @@ def detect(calibration_width, img_file, show, quick): #orig = image.copy() num += 1 # if the contour is not sufficiently large, ignore it + #pixelsPerMetric = 75 if cv2.contourArea(c) < 100 or pixelsPerMetric is None: continue # 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), # (int(trbrX + 20), int(trbrY)), cv2.FONT_HERSHEY_SIMPLEX, # 0.65, (255, 255, 255), 2) - #objtype = magicSort(c) + if objtype != "Penny": + objtype = magicSort(c) if objtype == "Unknown": objtype = magicSort(c) output = "{:.2f}in".format(itemw) + " x {:.2f}in".format(itemh) @@ -370,6 +372,8 @@ def magicSort(contour): #magicNumber2 = 0 name = "Unknown" 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])) if i > 1: humoments[i] = int(round(humoments[i][0] / 8) * 8) diff --git a/img.jpg b/img.jpg index 03c1f6f..5dd0bec 100644 Binary files a/img.jpg and b/img.jpg differ diff --git a/run_detect.py b/run_detect.py index 327a592..a7fac46 100644 --- a/run_detect.py +++ b/run_detect.py @@ -8,9 +8,9 @@ import time from imutils.video import FPS calibration_width = 0.75 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") -video = False +video = True def go(): for file in images: items,output = detect.detect(calibration_width, file, True, False)