Table of contents

概要

実装

fn save_file(frame: &Video, index: usize) -> std::result::Result<(), std::io::Error> {
    let mut file = File::create(format!("frame{}.ppm", index))?;
    file.write_all(format!("P6\n{} {}\n255\n", frame.width(), frame.height()).as_bytes())?;
    file.write_all(frame.data(0))?;
    Ok(())
}
Camera /dev/video0: 1920 * 1080, 50 FPS
save ppm by directly
Process 21.945 msec
save png by image
Process 94.467 msec
Camera /dev/video0: 640 * 360, 330 FPS
save ppm by directly
Process 3.509 msec
save png by image
Process 8.609 msec
  • 結果としては大体2-4倍の高速化ができたので満足
    • 一方でdataの大きさは3倍くらいになっていたのでトレードオフになっている点には注意
    • というか画像保存って結構時間かかる処理なんだなと改めて認識