Created
April 5, 2018 18:29
-
-
Save marquesghm/aac62c43e7c740c72fd0df0d523658ff to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import cv2 | |
import cv2.aruco as aruco | |
cap = cv2.VideoCapture(0) | |
while(True): | |
# Capture frame-by-frame | |
ret, frame = cap.read() | |
#print(frame.shape) #480x640 | |
# Our operations on the frame come here | |
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) | |
#aruco_dict = aruco.Dictionary_get(aruco.DICT_6X6_250) | |
aruco_dict = cv2.aruco.getPredefinedDictionary(cv2.aruco.DICT_ARUCO_ORIGINAL) | |
parameters = aruco.DetectorParameters_create() | |
#print(parameters) | |
''' detectMarkers(...) | |
detectMarkers(image, dictionary[, corners[, ids[, parameters[, rejectedI | |
mgPoints]]]]) -> corners, ids, rejectedImgPoints | |
''' | |
#lists of ids and the corners beloning to each id | |
corners, ids, rejectedImgPoints = aruco.detectMarkers(gray, aruco_dict, parameters=parameters) | |
print(corners) | |
#It's working. | |
# my problem was that the cellphone put black all around it. The alrogithm | |
# depends very much upon finding rectangular black blobs | |
gray = aruco.drawDetectedMarkers(gray, corners) | |
#print(rejectedImgPoints) | |
# Display the resulting frame | |
cv2.imshow('frame',gray) | |
if cv2.waitKey(1) & 0xFF == ord('q'): | |
break | |
# When everything done, release the capture | |
cap.release() | |
cv2.destroyAllWindows() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment