OpenCVのarucoの四角
opencvのarucoで角の対応関係をよく忘れるので備忘録
import cv2
dic = cv2.aruco.getPredefinedDictionary(aruco.DICT_4X4_50)
img = cv2.imread('sample.png')
corners, ids, _ = aruco.detectMarkers(frame, dic)
idsには検出したマーカーのidが入っている。
このリストの順に、cornersに四角の位置が格納されている。
例えば、0番のマーカーの四角を知りたければ
corners[list(ids.flatten()).index(0)][0] #マーカー0番の四角
で取得できる
つまり、
# マーカー0番の左上
corners[list(ids.flatten()).index(0)][0][0]
# マーカー0番の右上
corners[list(ids.flatten()).index(0)][0][1]
# マーカー0番の右下
corners[list(ids.flatten()).index(0)][0][2]
# マーカー0番の左下
corners[list(ids.flatten()).index(0)][0][3]
Author And Source
この問題について(OpenCVのarucoの四角), 我々は、より多くの情報をここで見つけました https://qiita.com/marimori/items/74774685c7a2f1df0adc著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .