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