sensor.reset()
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.QQVGA)
sensor.set_vflip(True)
sensor.set_hmirror(True)
jps_cnt=0
while True:
img = sensor.snapshot()
img.save("./%d.jpg" % (jps_cnt))如上述的代码,在保存图片时候,随着运行时间的延长而速度越来越慢,这是啥原因引起的呢?如何去解决呢?
你代码写全好不好。
@kidswong999
import sensor, image, time,pyb
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)
clock = time.clock()
jps_cnt=10000000000
while(True):
clock.tick()
if jps_cnt <=10000001000:
time_start = pyb.millis()
img = sensor.snapshot()
img.save("./pic2/%d.jpg" % (jps_cnt))
time_end = pyb.millis()
jps_cnt +=1
print("time:%d"%(time_end-time_start))
print(clock.fps())应该是和文件系统的缓冲有关系,图片太多了就慢了。如果文件名一致就比较稳定。你可以写一个逻辑,覆盖之前的文件。
@kidswong999 想保存好文件才这样做的,其实保存还好,但是删除照片的话,同一个文件夹下面的图片越多,删除的速度越慢,特别是到7000张的时候,删一张就需要一两秒,想问一下有没有什么方法来提速这个删除的速度
你可以考虑保存成mjpeg视频