我有一个问题使用CV2在覆盆子派与PiCamera。这是我的代码:
camera = PiCamera()
camera.resolution = ( 320, 240 )
camera.framerate = 60
rawCapture = PiRGBArray( camera, size=( 320, 240 ) )
time.sleep(1)
start = time.time()
for frame in camera.capture_continuous(rawCapture, format="bgr", use_video_port=True):
# and occupied/unoccupied text
images = frame.array
# show the frame
cv2.imshow("Frame", images)
cv_img = images.astype(np.uint8)
gray = cv2.imdecode(np.fromstring(cv_img, dtype=np.uint8), cv2.IMREAD_GRAYSCALE)
image = cv2.imdecode(np.fromstring(cv_img, dtype=np.uint8), cv2.IMREAD_UNCHANGED)
print("IMAGE: ",image)
print("GRAY: ",gray)
“图像”和“灰度”始终为“无”,而“图像”和“cv”图像包含正确的帧。我真不明白为什么它不起作用,你能帮帮我吗?在
提前谢谢你。在
我发现}之间架起桥梁的可靠方法。docs中有一些与您的不远的例子。在
picamera.array
是在picamara
和{一旦你进入了
cv2
领域是进行灰度转换的典型方法。用
imdecode
的方式做这件事太过分了。在相关问题 更多 >
编程相关推荐