Skip to content
This repository has been archived by the owner on Mar 20, 2020. It is now read-only.

Commit

Permalink
Homography removed, imshow fix
Browse files Browse the repository at this point in the history
  • Loading branch information
surirohit committed Mar 13, 2019
1 parent 6bd4ba6 commit 031cb69
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions apriltags3.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ def detect(self, img, estimate_tag_pose=False, camera_params=None, tag_size=None

tag = apriltag.contents

homography = _matd_get_array(tag.H).copy()
homography = None #_matd_get_array(tag.H).copy() # Don't ask questions, move on with your life
center = numpy.ctypeslib.as_array(tag.c, shape=(2,)).copy()
corners = numpy.ctypeslib.as_array(tag.p, shape=(4, 2)).copy()

Expand Down Expand Up @@ -429,10 +429,17 @@ def _convert_image(self, img):

test_images_path = 'test'

visualization = True
try:
import cv2
except:
raise Exception('You need cv2 in order to run the demo. However, you can still use the library without it.')

try:
import cv2.imshow
except:
visualization = False

try:
import yaml
except:
Expand All @@ -458,7 +465,8 @@ def _convert_image(self, img):
cameraMatrix = numpy.array(parameters['sample_test']['K']).reshape((3,3))
camera_params = ( cameraMatrix[0,0], cameraMatrix[1,1], cameraMatrix[0,2], cameraMatrix[1,2] )

cv2.imshow('Original image',img)
if visualization:
cv2.imshow('Original image',img)

tags = at_detector.detect(img, True, camera_params, parameters['sample_test']['tag_size'])
print(tags)
Expand All @@ -475,11 +483,12 @@ def _convert_image(self, img):
fontScale=0.8,
color=(0, 0, 255))

cv2.imshow('Detected tags', color_img)
if visualization:
cv2.imshow('Detected tags', color_img)

k = cv2.waitKey(0)
if k == 27: # wait for ESC key to exit
cv2.destroyAllWindows()
k = cv2.waitKey(0)
if k == 27: # wait for ESC key to exit
cv2.destroyAllWindows()


#### TEST WITH THE ROTATION IMAGES ####
Expand Down Expand Up @@ -558,10 +567,11 @@ def _convert_image(self, img):
fontScale=0.8,
color=(0, 0, 255))

cv2.imshow('Detected tags for ' + image_name , color_img)
if visualization:
cv2.imshow('Detected tags for ' + image_name , color_img)

k = cv2.waitKey(0)
if k == 27: # wait for ESC key to exit
cv2.destroyAllWindows()
k = cv2.waitKey(0)
if k == 27: # wait for ESC key to exit
cv2.destroyAllWindows()

print("AVG time per detection: ", time_sum/time_num)

0 comments on commit 031cb69

Please sign in to comment.