简体   繁体   English

我如何使用 OpenCV imwrite 将图片保存到特定文件夹

[英]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.

相关问题 我正在尝试使用 opencv python 库使用 cv2.imwrite() function 将图像保存到文件,但它显示错误 - I am trying to save an image to a file by using opencv python library using cv2.imwrite() function but it shows an error 使用imwrite进行阈值处理后如何在opencv中保存图像 - How to save image in opencv after thresholding using imwrite 使用opencv将图片保存在错误的文件夹中 - Save a picture in wrong folder using opencv 使用OpenCV拍摄后如何将图片保存到特定文件? - How to save a picture to a specific file after using OpenCV to take it? OpenCV cv2.imwrite() 没有循环工作以将图像保存在文件夹中 - OpenCV cv2.imwrite() is not working in loop to save images in folder 如何使用 imwrite 从一个文件夹中获取图像并使用 Opencv 将它们保存到另一个文件夹? - How to use imwrite taking images from one folder and saving them to another using Opencv? 如何在Linux中使用名为“imwrite”的python opencv函数将捕获的图像文件保存在USB中 - How to save the capture image file in USB using python opencv function named "imwrite" in Linux IndexError 使用 OpenCV imwrite - IndexError using OpenCV imwrite 如何使用 OpenCV 只保存一张人脸图片? - How to Save ONLY ONE face picture using OpenCV? 如何正确使用 cv2.imwrite 将图像保存在带有 cv2.selectROI 的 openCV 中 - How to correctly use cv2.imwrite to save an image in openCV with cv2.selectROI
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM