Ask Your Question

What OpenCV functions can read/write floating point arrays?

asked 2016-02-09 14:49:29 -0500

JoeC gravatar image

Neither imread nor imwrite seem to support 32-bit floating point arrays.

I'm developing code in C++ with Visual Studio (v13). I have a 2D array of 32-bit floating point values that I would like to be able to read/write. Are there any functions in OpenCV that would support reading and writing of floating point arrays?

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2016-02-10 00:40:29 -0500

Have a look at cv::FileStorage

edit flag offensive delete link more

answered 2016-02-10 03:21:34 -0500

theodore gravatar image

for 32-bit floating values through Opencv .exr format is also another alternative except cv::Filestorage. If you want your values also in .txt file you can have a look at the cv::formater, there is an example described here. However, my experience shows that both Filestorage and and formater are not feasible for big files and .exr format works better. The way you can save and read .exr files is as follows:


Mat matrix = imread("filename.exr", IMREAD_ANYCOLOR | IMREAD_ANYDEPTH);

and Write:

imwrite("filename.exr", matrix);
edit flag offensive delete link more

Question Tools

1 follower


Asked: 2016-02-09 14:49:29 -0500

Seen: 5,048 times

Last updated: Feb 10 '16