opencv/modules/imgcodecs/src/grfmt_pfm.hpp
pasbi 9f5f64e14e Merge pull request #12192 from pasbi:pfm
* created new decoder and encoder for PFM

pfm file format stores binary RGB or grayscale float images.

* added test for pfm codec

* replaced large with short licence header

* little/big-endian-check is now compile time

* fixed width/height confusion, improved big/little endian recognition, fixed scaling issue and Improved signature check

* adapted tests to handle float images well

* removed data-dependency: lena.pfm

the lena image is now loaded is pam and converted to pfm.

* fixed bug in endianess detection macro

* Added endianess detection for android and win

* removed fancy endianess detection

endianess detection will be implemented in cmake scripts soonish.

* fixed minor warnings

* fixed stupid elif defined bug

* silenced some implicit cast warnings

* replaced std::to_string with std::stringstream solution

std::to_string variant did not build on android.

* replaced new endianess macros with existing ones

* improved readability
2018-08-13 13:14:12 +03:00

57 lines
1.2 KiB
C++

// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#ifndef _GRFMT_PFM_H_
#define _GRFMT_PFM_H_
#include "grfmt_base.hpp"
#include "bitstrm.hpp"
#ifdef HAVE_IMGCODEC_PFM
namespace cv
{
class PFMDecoder CV_FINAL : public BaseImageDecoder
{
public:
PFMDecoder();
virtual ~PFMDecoder() CV_OVERRIDE;
bool readData( Mat& img ) CV_OVERRIDE;
bool readHeader() CV_OVERRIDE;
void close();
size_t signatureLength() const CV_OVERRIDE;
bool checkSignature( const String& signature ) const CV_OVERRIDE;
ImageDecoder newDecoder() const CV_OVERRIDE
{
return makePtr<PFMDecoder>();
}
private:
RLByteStream m_strm;
double m_scale_factor;
bool m_swap_byte_order;
};
class PFMEncoder CV_FINAL : public BaseImageEncoder
{
public:
PFMEncoder();
virtual ~PFMEncoder() CV_OVERRIDE;
bool isFormatSupported( int depth ) const CV_OVERRIDE;
bool write( const Mat& img, const std::vector<int>& params ) CV_OVERRIDE;
ImageEncoder newEncoder() const CV_OVERRIDE
{
return makePtr<PFMEncoder>();
}
};
}
#endif // HAVE_IMGCODEC_PXM
#endif/*_GRFMT_PFM_H_*/