简体   繁体   中英

Python IOError: [Errno 2] when saving captured image

I am currently doing a motion detection project that captures image when motion is detected using raspberry pi & raspberry pi camera module. The image would then be uploaded to dropbox.

However i am having this error:

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

This is my code:

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

screenshot Either you are pointing to wrong location or may be some libraries may be missing. I just implemented a part of your code and it is perfectly working.I don't know what u are passing as frame .assuming it as image...the code follows.

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()

this is the code edited from your TakePicUpload function. Check your python version is 2.7.Newer versions like 3.6 shows some problems in opencv .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM