如何使用opencv将帧写入文件夹
从实时网络摄像头视频中提取帧并保存在公共空间中。但如何使用 opencv
代码在特定文件夹中写入框架:
import cv2
# Opens the inbuilt camera of laptop to capture video.
cap = cv2.VideoCapture(0)
i = 0
while(cap.isOpened()):
ret, frame = cap.read()
# This condition prevents from infinite looping
# incase video ends.
if ret == False:
break
# Save Frame by Frame into disk using imwrite method
cv2.imwrite('Frame'+str(i)+'.jpg', frame)
i += 1
cap.release()
cv2.destroyAllWindows()
我尝试了这样的操作,但我不会为我工作
out_path = "/home/fraction/Desktop/extract_webcam_frames/frames"
path = out_path
cv2.imwrite(os.path.join(path + str(i)+'.jpg' , frame)
i += 1
如何使用 opencv python 解决此问题
Extracting frames from live webcam video and save in common space. but how to write frames in specific folder using opencv
code :
import cv2
# Opens the inbuilt camera of laptop to capture video.
cap = cv2.VideoCapture(0)
i = 0
while(cap.isOpened()):
ret, frame = cap.read()
# This condition prevents from infinite looping
# incase video ends.
if ret == False:
break
# Save Frame by Frame into disk using imwrite method
cv2.imwrite('Frame'+str(i)+'.jpg', frame)
i += 1
cap.release()
cv2.destroyAllWindows()
i tried like this but i wont worked for me
out_path = "/home/fraction/Desktop/extract_webcam_frames/frames"
path = out_path
cv2.imwrite(os.path.join(path + str(i)+'.jpg' , frame)
i += 1
How to resolve this issue using opencv python
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你需要正确书写路径。
You need to write the path correctly.
在这种情况下,您可以使用 f-string,它在 Python 3.6+ 中可用。
In this case you can use f-string, which is available in Python 3.6+.