gpt4 book ai didi

Python IOError : [Errno 2] when saving captured image 错误

转载 作者:太空宇宙 更新时间:2023-11-03 23:13:13 25 4
gpt4 key购买 nike

我目前正在做一个运动检测项目,当使用 raspberry pi 和 raspberry pi 相机模块检测到运动时捕捉图像。然后图像将被上传到保管箱。

但是我有这个错误:

IOError: [Errno 2] No such file or directory: 'Motion2017_07_21_07_39_36.png'

这是我的代码:

def TakePicUpload(frame):
cv2.imwrite('image.png', frame)

最佳答案

screenshot您指向错误的位置或者可能缺少某些库。我刚刚实现了您的部分代码,它运行良好。我不知道您作为 frame 传递的是什么。假设它是图像...代码如下。

import cv2
import time
frame=cv2.imread("abc.png",1)
timestring = time.strftime("%Y_%m_%d_%H_%M_%S")
face_timestr = 'Motion' + timestring + '.png'
cv2.imwrite(face_timestr, frame)
Facefile = open(face_timestr, mode = "rb")
data = Facefile.read()

这是从您的 TakePicUpload 函数编辑的代码。检查您的 python 版本是 2.7。较新的版本如 3.6opencv 中显示一些问题。

关于Python IOError : [Errno 2] when saving captured image 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45294701/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com