简体   繁体   中英

Fast 16-bit grayscale image writing (30fps)

I have a 16 bit grayscale camera stream with 30fps (1024x768px) and want to write each image as fast as possible to hard disk. The images sould not be compressed with lossy methods, I need every bit for further processing.

I tried it with but unfortunately PNG and TIFF are to slow and BMP does not support 16 bit in openCV.

Do you have an idea how to achieve this? Below there is a sample for writing and reading PNG in OpenCV. Changeing compression level of PNG is not enough. Reading images from camera is still faster than writing. I also tried using multiple threads with boost thread pool, but without success.

Thank you

#include <iostream>
#include <opencv2/imgcodecs.hpp>

int main(int argc, char *argv[])
{
    cv::Mat imOut = cv::Mat::ones(cv::Size(1024, 768), CV_16UC1);
    cv::imwrite("test.png", imOut); 
    return 0;
}

Edit:

System:

  • Windows 10 64 bit
  • MSVC c++ compiler
  • CPU Intel i7
  • 16 GB RAM (but it should be done with less)
  • Disk subsystem: best would be direct write on external USB 3 hard disk, but possible internal hard disk is also ok. Unfortunately SSD is not available

I found an answer, which was not documented.

The PGM Format support 16-bit grayscale with fast writing.

cv::imwrite("test.pgm", imOut); 

I opened an issue to update OpenCV documentation. OpenCV 4.5.0 imwrite Documentation OpenCV Issue

Thank you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM