#include <cvb/global.hpp>
#include <cvb/image.hpp>
#include <cvb/pixel_format_converter.hpp>
#include <iostream>
#include <utility>
std::pair<Cvb::ImagePtr, Cvb::PfncFormat> GetImage(
const Cvb::String &fileName)
{
const auto pixelFormat = Cvb::Pfnc::PfncFormat::BayerGB8;
}
{
converter->Execute(*srcImage, *dstImage);
return dstImage;
}
{
return Cvb::PfncFormatValue::ToString(pixelFormat);
}
{
std::cout << " Saved as: " << path << std::endl;
}
int main()
{
try
{
std::cout << "As a source, a Bayer pattern image is given." << std::endl;
auto srcImageFormatPair =
Save(*srcImageFormatPair.first, baseName + ToString(srcImageFormatPair.second) + extension);
std::cout << "As the destination, an RGB format is given." << std::endl;
const Cvb::PfncFormat dstFormat = Cvb::PfncFormat::RGB8;
std::cout << "Create a pixel format converter." << std::endl;
auto converter = std::make_shared<Cvb::PixelFormatConverter>(srcImageFormatPair.second, dstFormat);
std::cout << "Convert the source to another." << std::endl;
auto dstImage = GetAnotherRepresentation(srcImageFormatPair.first, converter);
std::cout << "Saving the converted image as a file." << std::endl;
Save(*dstImage, baseName + ToString(dstFormat) + extension);
}
catch (const std::exception &error)
{
std::cout << error.what() << std::endl;
}
return 0;
}
static std::unique_ptr< Image > FromPixelFormat(const Cvb::Size2D< int > &size, Cvb::PfncFormat format)
static std::unique_ptr< Image > Load(const String &fileName)
std::shared_ptr< Image > ImagePtr
std::shared_ptr< PixelFormatConverter > PixelFormatConverterPtr