1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 07:43:03 +04:00

Calibration, various changes

This commit is contained in:
Fedor Morozov
2013-07-21 13:48:57 +04:00
parent ec668ce3a7
commit 703cf8cef7
7 changed files with 178 additions and 118 deletions
+10 -9
View File
@@ -69,11 +69,13 @@ bool HdrDecoder::readHeader()
{
file = fopen(m_filename.c_str(), "rb");
if(!file) {
CV_Error(Error::StsError, "HDR decoder: can't open file");
return false;
}
RGBE_ReadHeader(file, &m_width, &m_height, NULL);
if(m_width <= 0 || m_height <= 0) {
CV_Error(Error::StsError, "HDR decoder: invalid image size");
fclose(file);
file = NULL;
return false;
}
return true;
}
@@ -82,7 +84,9 @@ bool HdrDecoder::readData(Mat& _img)
{
Mat img(m_height, m_width, CV_32FC3);
if(!file) {
readHeader();
if(!readHeader()) {
return false;
}
}
RGBE_ReadPixels_RLE(file, const_cast<float*>(img.ptr<float>()), img.cols, img.rows);
fclose(file); file = NULL;
@@ -125,13 +129,10 @@ bool HdrEncoder::write( const Mat& _img, const std::vector<int>& params )
} else {
_img.convertTo(img, CV_32FC3, 1/255.0f);
}
if(!(params.empty() || params[0] == HDR_NONE || params[0] == HDR_RLE)) {
CV_Error(Error::StsBadArg, "HDR encoder: wrong compression param");
}
CV_Assert(params.empty() || params[0] == HDR_NONE || params[0] == HDR_RLE);
FILE *fout = fopen(m_filename.c_str(), "wb");
if(!fout) {
CV_Error(Error::StsError, "HDR encoder: can't open file");
return false;
}
RGBE_WriteHeader(fout, img.cols, img.rows, NULL);
@@ -151,7 +152,7 @@ ImageEncoder HdrEncoder::newEncoder() const
}
bool HdrEncoder::isFormatSupported( int depth ) const {
return depth == CV_32F;
return depth != CV_64F;
}
}
+2 -2
View File
@@ -410,8 +410,8 @@ TEST(Highgui_WebP, encode_decode_lossy_webp)
TEST(Highgui_Hdr, regression)
{
string folder = string(cvtest::TS::ptr()->get_data_path()) + "../cv/hdr/";
string name_rle = folder + "grand_canal_rle.hdr";
string name_no_rle = folder + "grand_canal_no_rle.hdr";
string name_rle = folder + "rle.hdr";
string name_no_rle = folder + "no_rle.hdr";
Mat img_rle = imread(name_rle, -1);
ASSERT_FALSE(img_rle.empty()) << "Could not open " << name_rle;
Mat img_no_rle = imread(name_no_rle, -1);