opencvに関する質問です.
以下のコードを実行するとこのようなエラーが出るのですが原因は何でしょうか?
ソースコード
python
1import cv2 2import numpy as np 3import pprint 4 5w = h = 360 6n = 6 7np.random.seed(0) 8pts = np.random.randint(0, w, (n, 2)) 9 10print(pts) 11print(type(pts)) 12print(pts.shape) 13 14img = np.zeros((w, h, 3), np.uint8) 15 16for p in pts: 17 cv2.drawMarker(img, tuple(p), (255, 255, 255), thickness = 2) 18 19rect = (0, 0, w, h) 20subdiv = cv2.Subdiv2D(rect) 21 22print(type(subdiv)) 23for p in pts: 24 subdiv.insert((p[0],p[1])) 25 26 27cv2.imshow("a", img) 28cv2.waitKey(0) 29cv2.destroyAllWindows()
cv2.error: OpenCV(4.5.5) :-1: error: (-5:Bad argument) in function 'insert' > Overload resolution failed: > - Can't parse 'pt'. Sequence item with index 0 has a wrong type > - Can't parse 'ptvec'. Sequence item with index 0 has a wrong type
subdiv.insert((p[0],p[1]))のところでエラーが起こっているとは思うのですが対応がわかりません.
よろしくお願い致します.
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2022/03/17 08:39
2022/03/17 08:40
2022/03/17 08:41