Ask Your Question

Speeding up reading PNG images

asked 2020-11-18 05:32:03 -0600

OpenCV version: 4.5.0, compiled from source in release mode with static libraries; Operating system: Ubuntu 18.04;

I am working on optimizing a reasonably computationally-expensive computer vision application and have reached a point where it seems like loading up a dataset takes 20-25% of the time.

I am loading RGB-D pairs stored as PNG sequentially (pre-loading all images is not an option). imread averages 4ms / image (and internally, png_read_image is only a few ns faster).

Any suggestions on how I could speed this up, please?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2020-11-18 08:23:46 -0600

kbarni gravatar image

PNG compression is computationally expensive. If this is a bottleneck of your application, you should choose another file format (like TIFF, which is read faster and can store 8 bit and 16 bit data, so it's well suited to store RGB-D data) or even uncompressed raw data.

Writing/reading RAW data is something like this (in pure C, can be adapted to other languages):

cv::Mat imgRGB,imgD;
//...acquire the images...
FILE *fptr;
fptr = fopen("imageRGB.dat","wb");
fptr = fopen("imageD.dat","wb");
edit flag offensive delete link more

Question Tools

1 follower


Asked: 2020-11-18 05:32:03 -0600

Seen: 316 times

Last updated: Nov 18 '20