[英]How am i able to save a picture using OpenCV imwrite to a specific folder
Im back with another probably stupid question,: my new issue is the following, im trying to save a picture from my webcam into a specific folder using OpenCV imwrite: its not working obviously here is my code:我又回到了另一个可能很愚蠢的问题:我的新问题如下,我正在尝试使用 OpenCV imwrite 将网络摄像头中的图片保存到特定文件夹中:它显然不起作用这是我的代码:
import cv2 as cv
cam = cv.VideoCapture(0)
s, img = cam.read()
if s:
path = r"\imgtest\selfietest.jpg"
cv.imwrite(path, img)
Any suggestions for edits or fixes?, i've tried copying the file using shutil and moving it using the same module, i also tried to use the OS module to move it but it threw an "Access Denied" error so i would prefer to not need to grant the application admin rights every time i launched it thanks in advance!!对编辑或修复有什么建议吗?我试过使用 shutil 复制文件并使用相同的模块移动它,我也尝试使用 OS 模块移动它但它引发了“拒绝访问”错误,所以我更愿意不需要每次启动时都授予应用程序管理员权限提前谢谢!!
((ALSO ASSUME I KNOW NOTHING ABOUT PYTHON)) ((也假设我对 Python 一无所知))
Use a full path, forward slashes, and r'' to pass a raw path.使用完整路径、正斜杠和 r'' 传递原始路径。 cv2.imwrite(r"D:/....jpg", img)
cv2.imwrite(r"D:/....jpg", img)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.