GDAL driver support for OpenCV (Feature #3725)


Added by Marvin Smith almost 11 years ago. Updated almost 10 years ago.


Status:Done Start date:2014-05-28
Priority:Normal Due date:
Assignee:Marvin Smith % Done:

0%

Category:highgui-images
Target version:-
Difficulty:Medium Pull request:

Description

Hello,

I have a fork of OpenCV on my GitHub profile which implements an ImageDecoder for GDAL. I have had code for a long time which will use GDAL to load a raster into an OpenCV Mat. I took that and implemented what I believe are the required components in order to load rasters natively using OpenCV imread. You can clone the repo at https://github.com/marvins/opencv . Let me know if this is something you are interested in including and I can implement whatever is required to get it added.

I am avoiding a Pull Request as this is not tied to a specific bug or issue. Also, this adds a rather large dependency to OpenCV in that GDAL includes a lot of dependencies of its own. It will most certainly cause issues if run on a build farm. To install GDAL on Ubuntu, install the "libgdal-dev" package. On Fedora, install the "gdal-devel" package. I am a little naive with building OpenCV on Windows, so I am not sure if it would work.

In the master branch of my OpenCV fork, I have added the CMake flags to find and include GDAL. I also created a functional example in the Sphinx documentation under the HighGui tutorials.

I have tested the driver with the following formats...

Digital Elevation Models
  • DTED
  • SRTM
Rasters
  • NITF (2.0/2.1)
  • GeoTiff
  • JPEG
  • Tiff
  • J2K

If there is interest in supporting GDAL, I would be more than happy to dig into the ImageEncoder driver. In addition, GDAL can load the image Metadata as well as do coordinate conversions. Also, if there are any bugs, improvements, or fixes in my code that you would like me to make, just let me know.

Thanks,
Marvin

Changed or Added Files
  • CMakeLists.txt
  • cmake/OpenCVFindLibsGrfmt.cmake
  • cmake/templates/cvconfig.h.in
  • doc/tutorials/definitions/tocDefinitions.rst
  • doc/tutorials/highgui/raster-gdal/images/flood-zone.jpg
  • doc/tutorials/highgui/raster-gdal/images/heat-map.jpg
  • doc/tutorials/highgui/raster-gdal/images/output.jpg
  • doc/tutorials/highgui/raster-gdal/raster_io_gdal.rst
  • doc/tutorials/highgui/table_of_content_highgui/images/gdal-io.jpg
  • doc/tutorials/highgui/table_of_content_highgui/table_of_content_highgui.rst
  • modules/highgui/CMakeLists.txt
  • modules/highgui/include/opencv2/highgui.hpp
  • modules/highgui/src/grfmt_gdal.cpp
  • modules/highgui/src/grfmt_gdal.hpp
  • modules/highgui/src/grfmts.hpp
  • modules/highgui/src/loadsave.cpp
  • samples/cpp/tutorial_code/HighGUI/GDAL_IO/gdal-image.cpp

History

Updated by Dmitry Retinskiy almost 11 years ago

Hi Marvin,

thanks for the work you have done! This is always appreciated.
Pull request is nevertheless a right way to proceed with the review.
Reviewers could advice how to proceed with the problems you mentioned.

  • Assignee set to Marvin Smith
  • Status changed from New to Open

Updated by Marvin Smith almost 11 years ago

Submitted the Pull Request. Thanks. Let me know what the desirability of this module is.

Updated by Vadim Pisarevsky almost 10 years ago

thanks! the PR has been merged in

  • Status changed from Open to Done

Also available in: Atom PDF