我使用opencv2编写了一个运动检测/视频程序,可以将视频输出保存x秒 . 如果在此期间检测到运动,则输出将保存为备用命名文件,但如果未检测到运动,则会覆盖该文件 . 为了避免基于闪存的内存系统出现不必要的磨损,我想将文件写入RAM,如果检测到运动,则将其保存到非易失性存储器中 .
我试图使用pyfilesystem-fs.memoryfs在RAM中创建此文件
import numpy as np
import cv2, time, os, threading, thread
from Tkinter import *
from fs.memoryfs import MemoryFS
class stuff:
mem=MemoryFS()
output = mem.createfile('output.avi')
rectime=0
delay=0
kill=0
cap = cv2.VideoCapture(0)
#out = cv2.VideoWriter('C:\motion\\output.avi',cv2.cv.CV_FOURCC('F','M','P','4'), 30, (640,480),True)
out = cv2.VideoWriter(output, cv2.cv.CV_FOURCC('F','M','P','4'), 30, (640,480),True)
这是运动检测部分
if value > 100:
print "saving"