#include <iostream>
#include <cvb/code_reader/code_reader.hpp>
#include <cvb/image.hpp>
void PrintResults(const std::vector<Result>& results);
int main()
{
try
{
auto& config = decoder->Config<Symbology::DataMatrix>();
config.Enable();
config.SetPolarity(Config::Polarity::DarkOnLight);
const auto imageFile =
Cvb::InstallPath() + CVB_LIT(
"tutorial/CodeReader/Images/DataMat/Surrounded.bmp");
const auto results = decoder->Execute(image->Plane(0));
PrintResults(results);
}
catch (const std::exception& error)
{
std::cout << error.what() << std::endl;
}
return 0;
}
void PrintResults(const std::vector<Result>& results)
{
std::cout << results.size() << " code(s) found.\n";
for (const auto result : results)
{
if (result.DecodeStatus() == DecodeStatus::Success)
{
std::cout << " ------------------------------------------------------------\n";
std::cout << " code with content:\n";
std::cout << result.Data() << "\n";
std::cout << " found at center: (" << result.Center().X() << "/" << result.Center().Y() << ")\n";
std::cout << " with corners at: ";
for (int k = 0; k < 4; k++)
std::cout << "(" << result.Corners()[k].X() << "/" << result.Corners()[k].Y() << ") ";
std::cout << "\n";
if (result.Result2D())
{
const auto result2D = result.Result2D();
std::cout << " size (width x height): " << result2D->Size().Width() << " x " << result2D->Size().Height() << "\n";
std::cout << " rows x columns: " << result2D->Rows() << " x " << result2D->Columns() << "\n";
std::cout << " Quality: " << result2D->Quality() << "\n";
}
std::cout << " ------------------------------------------------------------\n\n";
}
else
{
std::cout << " Decoding failed.\n";
}
}
}
static std::unique_ptr< Decoder > Create()
static std::unique_ptr< Image > Load(const String &fileName)