diff -r 18bb23fc811f -r 500ce0b934e7 src/QRCommand.h --- a/src/QRCommand.h Thu Apr 15 20:45:10 2021 +0200 +++ b/src/QRCommand.h Fri Apr 16 23:18:03 2021 +0200 @@ -40,6 +40,7 @@ void process(Configuration& configuration, std::shared_ptr writer, std::function relationalWriterFlush) { + // TODO: require PNM input and get rid off the ImageMagick dependency? Magick::Image magick("/dev/stdin"); int width = magick.columns(); int height = magick.rows(); @@ -51,7 +52,8 @@ zbar::Image image(width, height, "Y800", raw, width * height); zbar::ImageScanner scanner; - writer->startRelation(L"qr",{ + writer->startRelation(L"symbol",{ + {L"id", relpipe::writer::TypeId::INTEGER}, {L"type", relpipe::writer::TypeId::STRING}, // {L"addon_name", relpipe::writer::TypeId::STRING}, {L"value", relpipe::writer::TypeId::STRING}, @@ -64,7 +66,9 @@ int n = scanner.scan(image); - for (zbar::Image::SymbolIterator symbol = image.symbol_begin(); symbol != image.symbol_end(); ++symbol) { + relpipe::common::type::Integer id = 0; + for (zbar::Image::SymbolIterator symbol = image.symbol_begin(); symbol != image.symbol_end(); ++symbol, id++) { + writer->writeAttribute(&id, typeid (id)); writer->writeAttribute(convertor.from_bytes(symbol->get_type_name())); // writer->writeAttribute(convertor.from_bytes(symbol->get_addon_name())); writer->writeAttribute(convertor.from_bytes(symbol->get_data())); @@ -94,6 +98,28 @@ writer->writeAttribute(&height, typeid (height)); } + if (configuration.listPolygonPoints) { + relpipe::common::type::Integer id = 0; + + writer->startRelation(L"polygon_point",{ + {L"symbol", relpipe::writer::TypeId::INTEGER}, + {L"point", relpipe::writer::TypeId::INTEGER}, + {L"x", relpipe::writer::TypeId::INTEGER}, + {L"y", relpipe::writer::TypeId::INTEGER}, + }, true); + + for (zbar::Image::SymbolIterator symbol = image.symbol_begin(); symbol != image.symbol_end(); ++symbol, id++) { + for (relpipe::common::type::Integer i = 0, locationSize = symbol->get_location_size(); i < locationSize; i++) { + relpipe::common::type::Integer x = symbol->get_location_x(i); + relpipe::common::type::Integer y = symbol->get_location_y(i); + writer->writeAttribute(&id, typeid (id)); + writer->writeAttribute(&i, typeid (i)); + writer->writeAttribute(&x, typeid (x)); + writer->writeAttribute(&y, typeid (y)); + } + } + } + image.set_data(nullptr, 0); } };