[英]OpenCV loading video in the memory
when using cv::VideoCapture
to read video from the disk, what does exactly happens?当使用cv::VideoCapture
从磁盘读取视频时,究竟发生了什么?
If the second option is the answer, is it possible to do it in the first way?如果第二个选项是答案,是否可以用第一种方式来做?
To accomplish this in Python on Linux, I simply made a copy of the input file to /dev/shm
, which is a RAM-backed filesystem.为了在 Linux 上的 Python 中实现这一点,我简单地将输入文件复制到/dev/shm
,这是一个 RAM 支持的文件系统。
tempdir = tempfile.TemporaryDirectory(dir='/dev/shm')
copypath = os.path.join(tempdir.name, os.path.basename(args.video))
shutil.copy(args.video, copypath)
args.video = copypath
Of course there is the cost of the copy operation as well but it shouldn't be much more than simply reading the entire file (since there is no slow disk that's being written to on the other side of the copy).当然,复制操作也有成本,但它不应该只是简单地读取整个文件(因为在副本的另一侧没有写入慢速磁盘)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.