我目前正在嘗試使用tmpfs來改進python/openCV性能,因爲我在嘗試在640x480上記錄USB攝像頭時在樹莓派3上卡住了5-10 FPS。用tmpfs改進openCV VideoWriter
在我的系統,我得到這些原料的寫入傳輸速率,用dd命令: SD卡:2.5Mo /秒 的tmpfs:380莫/秒
可悲的是,在tmpfs的寫我的OpenCV視頻文件時文件夾,我沒有得到任何改善。這裏是我的基準代碼:
import cv2
import numpy as np
import time
x = np.random.randint(255, size=(480, 640,3)).astype('uint8')
writer1 = cv2.VideoWriter('/home/pi/testDX1.avi',cv2.cv.CV_FOURCC('D','X','5','0'), 10, (640, 480), True)
ctime=time.time()
for i in range(250):
writer1.write(x)
writer1.release()
print("SDCard took : "+`time.time()-ctime`)
writer2 = cv2.VideoWriter('/var/tmp/testDX2.avi',cv2.cv.CV_FOURCC('D','X','5','0'), 10, (640, 480), True)
ctime=time.time()
for i in range(250):
writer2.write(x)
writer2.release()
print("tmpfs took : "+`time.time()-ctime`)
它提供:
SD卡了:8.289990901947021 的tmpfs了:8.240657806396484
的tmpfs的很好啓用,通過mount命令指出: mount | grep "/var/tmp"
給出tmpfs on /var/tmp type tmpfs (rw,nosuid,nodev,relatime)
mount | grep "/ "
給出/dev/mmcblk0p2 on/type ext4 (rw,noatime,data=ordered)
有人知道爲什麼tmfs沒有提高寫入速度嗎?
謝謝老兄,你讓我回到正確的軌道上! – technico