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

标签 python opencv raspberry-pi motion-detection

我目前正在做一个运动检测项目,当使用 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/

相关文章:

python - (python 3) 从 .h264 自动转换为 .mp4

Python/Arduino : PySerial, Matplotlib,numpy;树莓派

python - 如何在 Python 中将新行附加到旧的 CSV 文件?

java - "Importing test library ' Selenium2Library ' failed: ImportError: No module named decorator"RobotFramework maven插件

python - 在 Google AppEngine 开发上打开 APNS 套接字时出现权限被拒绝错误

linux - 如何使用基于linux的平台在windows硬盘上构建linux共享库?

python - 如何在opencv中计算粗糙度轮廓?

opencv - 将比例信息添加到变换矩阵中

node.js - 在 root 模式下设置 Node-red 密码

python - 数据可视化 - python 中的气泡图