Merge pull request #10051 from sturkmen72:upd_grfmt_gdal_cpp

pull/10057/head
Alexander Alekhin 7 years ago
commit 22dfc1daf1
  1. 48
      modules/imgcodecs/src/grfmt_gdal.cpp

@ -104,58 +104,32 @@ int gdal2opencv( const GDALDataType& gdalType, const int& channels ){
/// UInt8
case GDT_Byte:
if( channels == 1 ){ return CV_8UC1; }
if( channels == 3 ){ return CV_8UC3; }
if( channels == 4 ){ return CV_8UC4; }
else { return CV_8UC(channels); }
return -1;
return CV_8UC(channels);
/// UInt16
case GDT_UInt16:
if( channels == 1 ){ return CV_16UC1; }
if( channels == 3 ){ return CV_16UC3; }
if( channels == 4 ){ return CV_16UC4; }
else { return CV_16UC(channels); }
return -1;
return CV_16UC(channels);
/// Int16
case GDT_Int16:
if( channels == 1 ){ return CV_16SC1; }
if( channels == 3 ){ return CV_16SC3; }
if( channels == 4 ){ return CV_16SC4; }
else { return CV_16SC(channels); }
return -1;
return CV_16SC(channels);
/// UInt32
case GDT_UInt32:
case GDT_Int32:
if( channels == 1 ){ return CV_32SC1; }
if( channels == 3 ){ return CV_32SC3; }
if( channels == 4 ){ return CV_32SC4; }
else { return CV_32SC(channels); }
return -1;
return CV_32SC(channels);
case GDT_Float32:
if( channels == 1 ){ return CV_32FC1; }
if( channels == 3 ){ return CV_32FC3; }
if( channels == 4 ){ return CV_32FC4; }
else { return CV_32FC(channels); }
return -1;
return CV_32FC(channels);
case GDT_Float64:
if( channels == 1 ){ return CV_64FC1; }
if( channels == 3 ){ return CV_64FC3; }
if( channels == 4 ){ return CV_64FC4; }
else { return CV_64FC(channels); }
return -1;
return CV_64FC(channels);
default:
std::cout << "Unknown GDAL Data Type" << std::endl;
std::cout << "Type: " << GDALGetDataTypeName(gdalType) << std::endl;
return -1;
}
return -1;
}
/**
@ -163,7 +137,6 @@ int gdal2opencv( const GDALDataType& gdalType, const int& channels ){
*/
GdalDecoder::GdalDecoder(){
// set a dummy signature
m_signature="0";
for( size_t i=0; i<160; i++ ){
@ -182,7 +155,6 @@ GdalDecoder::GdalDecoder(){
*/
GdalDecoder::~GdalDecoder(){
if( m_dataset != NULL ){
close();
}
@ -383,10 +355,7 @@ bool GdalDecoder::readData( Mat& img ){
// make sure the image is the proper size
if( img.size().height != m_height ){
return false;
}
if( img.size().width != m_width ){
if( img.size() != Size(m_width, m_height) ){
return false;
}
@ -398,7 +367,6 @@ bool GdalDecoder::readData( Mat& img ){
// set the image to zero
img = 0;
// iterate over each raster band
// note that OpenCV does bgr rather than rgb
int nChannels = m_dataset->GetRasterCount();
@ -452,8 +420,6 @@ bool GdalDecoder::readData( Mat& img ){
// delete our temp pointer
delete [] scanline;
}
return true;

Loading…
Cancel
Save