Path: blob/master/modules/imgcodecs/src/grfmt_gdal.hpp
16337 views
/*M///////////////////////////////////////////////////////////////////////////////////////1//2// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.3//4// By downloading, copying, installing or using the software you agree to this license.5// If you do not agree to this license, do not download, install,6// copy or use the software.7//8//9// Intel License Agreement10// For Open Source Computer Vision Library11//12// Copyright (C) 2000, Intel Corporation, all rights reserved.13// Third party copyrights are property of their respective owners.14//15// Redistribution and use in source and binary forms, with or without modification,16// are permitted provided that the following conditions are met:17//18// * Redistribution's of source code must retain the above copyright notice,19// this list of conditions and the following disclaimer.20//21// * Redistribution's in binary form must reproduce the above copyright notice,22// this list of conditions and the following disclaimer in the documentation23// and/or other materials provided with the distribution.24//25// * The name of Intel Corporation may not be used to endorse or promote products26// derived from this software without specific prior written permission.27//28// This software is provided by the copyright holders and contributors "as is" and29// any express or implied warranties, including, but not limited to, the implied30// warranties of merchantability and fitness for a particular purpose are disclaimed.31// In no event shall the Intel Corporation or contributors be liable for any direct,32// indirect, incidental, special, exemplary, or consequential damages33// (including, but not limited to, procurement of substitute goods or services;34// loss of use, data, or profits; or business interruption) however caused35// and on any theory of liability, whether in contract, strict liability,36// or tort (including negligence or otherwise) arising in any way out of37// the use of this software, even if advised of the possibility of such damage.38//39//M*/4041#ifndef __GRFMT_GDAL_HPP__42#define __GRFMT_GDAL_HPP__4344/// OpenCV FMT Base Type45#include "grfmt_base.hpp"4647/// Macro to make sure we specified GDAL in CMake48#ifdef HAVE_GDAL4950/// C++ Libraries51#include <iostream>5253/// Geospatial Data Abstraction Library54#include <cpl_conv.h>55#include <gdal_priv.h>56#include <gdal.h>575859/// Start of CV Namespace60namespace cv {6162/**63* Convert GDAL Pixel Range to OpenCV Pixel Range64*/65double range_cast( const GDALDataType& gdalType,66const int& cvDepth,67const double& value );6869/**70* Convert GDAL Palette Interpretation to OpenCV Pixel Type71*/72int gdalPaletteInterpretation2OpenCV( GDALPaletteInterp const& paletteInterp,73GDALDataType const& gdalType );7475/**76* Convert a GDAL Raster Type to OpenCV Type77*/78int gdal2opencv( const GDALDataType& gdalType, const int& channels );7980/**81* Write an image to pixel82*/83void write_pixel( const double& pixelValue,84GDALDataType const& gdalType,85const int& gdalChannels,86Mat& image,87const int& row,88const int& col,89const int& channel );9091/**92* Write a color table pixel to the image93*/94void write_ctable_pixel( const double& pixelValue,95const GDALDataType& gdalType,96const GDALColorTable* gdalColorTable,97Mat& image,98const int& y,99const int& x,100const int& c );101102/**103* Loader for GDAL104*/105class GdalDecoder CV_FINAL : public BaseImageDecoder{106107public:108109/**110* Default Constructor111*/112GdalDecoder();113114/**115* Destructor116*/117~GdalDecoder() CV_OVERRIDE;118119/**120* Read image data121*/122bool readData( Mat& img ) CV_OVERRIDE;123124/**125* Read the image header126*/127bool readHeader() CV_OVERRIDE;128129/**130* Close the module131*/132void close();133134/**135* Create a new decoder136*/137ImageDecoder newDecoder() const CV_OVERRIDE;138139/**140* Test the file signature141*142* In general, this should be avoided as the user should specifically request GDAL.143* The reason is that GDAL tends to overlap with other image formats and it is probably144* safer to use other formats first.145*/146virtual bool checkSignature( const String& signature ) const CV_OVERRIDE;147148protected:149150/// GDAL Dataset151GDALDataset* m_dataset;152153/// GDAL Driver154GDALDriver* m_driver;155156/// Check if we are reading from a color table157bool hasColorTable;158159}; /// End of GdalDecoder Class160161} /// End of Namespace cv162163#endif/*HAVE_GDAL*/164165#endif/*__GRFMT_GDAL_HPP__*/166167168