これまでのARコードサンプルでは過去のヤラカシ由来の私怨からファイルに書き出してから読んでいました。
これだと、書き出し分の処理時間がありますし、
実際のところ
import cv2 import numpy as np import sys aruco = cv2.aruco dictionary = aruco.getPredefinedDictionary(aruco.DICT_4X4_50) stdin = sys.stdin.buffer.read() array = np.frombuffer(stdin,dtype="uint8") img_src = cv2.imdecode(array, 1) corners, ids, rejectedImgPoints = aruco.detectMarkers( img_src, dictionary ) print(corners, ids)
$ python3 foobar.py < 2.png
[array([[[378., 306.],
[582., 304.],
[583., 507.],
[380., 509.]]], dtype=float32)] [[42]]