从opencv获得的图像保存在另一台计算机上

时间:2019-03-04 14:11:58

标签: python opencv ftp

我正在使用摄像头中的opencv拍照,识别出面部之后,我使用cv2.imwrite将面部图像保存在计算机的文件夹中。 现在,我的问题是如何将图像保存在另一台计算机上的路径中? 我的意思是,例如,使用ftp,我可以直接添加另一个路径来将图像存储到cv2.imwrite并将它们放置在另一台计算机上吗?

1 个答案:

答案 0 :(得分:0)

您需要使用cv2.imencodestore the image to memory

retval, buffer = cv2.imencode('.jpg', image)

然后上传buffer

from ftplib import FTP
from io import BytesIO

ftp = FTP('ftp.example.com')
ftp.login('username', 'password')

flo = BytesIO(buffer)
ftp.storbinary('STOR test.jpg', flo)
相关问题