![](/img/trans.png)
[英]I am trying to save an image to a file by using opencv python library using cv2.imwrite() function but it shows an error
[英]How am i able to save a picture using OpenCV imwrite to a specific folder
我又回到了另一個可能很愚蠢的問題:我的新問題如下,我正在嘗試使用 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)
對編輯或修復有什么建議嗎?我試過使用 shutil 復制文件並使用相同的模塊移動它,我也嘗試使用 OS 模塊移動它但它引發了“拒絕訪問”錯誤,所以我更願意不需要每次啟動時都授予應用程序管理員權限提前謝謝!!
((也假設我對 Python 一無所知))
使用完整路徑、正斜杠和 r'' 傳遞原始路徑。 cv2.imwrite(r"D:/....jpg", img)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.