Skip to content

Commit

Permalink
Correcting linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
BradleyBravender committed Jan 24, 2024
1 parent b837089 commit 427a206
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions benchmarks/hughes.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class HughesTransformDetector(LandingPadDetector):
MAX_RADIUS = 300 # was 20
SENSITIVITY = 6
FILTER = 1 # 0 toggles the monochromeFilter, any other value toggles the colorFilter

BLUE_THRESHOLD = 230
GREEN_THRESHOLD = 230
RED_THRESHOLD = 50
Expand Down Expand Up @@ -52,20 +52,20 @@ def predict(self, image: Image.Image) -> Optional[BoundingBox]:
image = self.monochromeFilter(image, height, width)
else:
image = self.colorFilter(image, height, width)

# plt.imshow(image)
# plt.show()

image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
image = cv2.medianBlur(image, 5)
circles = cv2.HoughCircles(image, cv2.HOUGH_GRADIENT, 1, 20, param1=100, param2=self.SENSITIVITY,
minRadius=self.MIN_RADIUS, maxRadius=self.MAX_RADIUS)

if circles is not None:
sift = cv2.SIFT_create() # so that we can extract image keypoints later
circles = np.uint16(np.around(circles))
circleInfoList = []

for i in range(len(circles[0])): # iterating through every circle detected
circle = circles[0, i]
x, y, r = circle
Expand All @@ -85,15 +85,16 @@ def predict(self, image: Image.Image) -> Optional[BoundingBox]:
except IndexError:
pass
#FIXME why do IndexErrors even occur in this program?

#return mostAccurateCircle[0], mostAccurateCircle[1], mostAccurateCircle[2]
else:
return None

def debug(self, image):
image = np.array(image)
print(image)


if __name__ == "__main__":
if debug == 0:
import glob
Expand All @@ -108,7 +109,7 @@ def debug(self, image):

from loader import MultiBundleLoader, Vec2
from detector import BoundingBox, LandingPadDetector

detector = HughesTransformDetector()
for i in range(17456, 17461):
filename = "48/"+str(i)+".jpeg"
Expand All @@ -118,7 +119,7 @@ def debug(self, image):
array_image = np.array(image)
if detector.predict(image) != None:
center_x, center_y, radius = detector.predict(image)
cv2.circle(array_image, (center_x, center_y), radius, (0,0,255), 1)
cv2.circle(array_image, (center_x, center_y), radius, (0, 0, 255), 1)
cv2.imwrite(f"BradleyPositives/{str(i)}.jpeg", array_image)
else:
cv2.imwrite(f"BradleyNegatives/{str(i)}.jpeg", array_image)
cv2.imwrite(f"BradleyNegatives/{str(i)}.jpeg", array_image)

0 comments on commit 427a206

Please sign in to comment.