53 writer->startRelation(L"qr",{ |
54 writer->startRelation(L"qr",{ |
54 {L"type", relpipe::writer::TypeId::STRING}, |
55 {L"type", relpipe::writer::TypeId::STRING}, |
55 // {L"addon_name", relpipe::writer::TypeId::STRING}, |
56 // {L"addon_name", relpipe::writer::TypeId::STRING}, |
56 {L"value", relpipe::writer::TypeId::STRING}, |
57 {L"value", relpipe::writer::TypeId::STRING}, |
57 // {L"xml", relpipe::writer::TypeId::STRING}, |
58 // {L"xml", relpipe::writer::TypeId::STRING}, |
58 {L"location_size", relpipe::writer::TypeId::INTEGER}, |
59 {L"x", relpipe::writer::TypeId::INTEGER}, |
59 {L"x_1", relpipe::writer::TypeId::INTEGER}, |
60 {L"y", relpipe::writer::TypeId::INTEGER}, |
60 {L"y_1", relpipe::writer::TypeId::INTEGER}, |
61 {L"width", relpipe::writer::TypeId::INTEGER}, |
61 {L"x_2", relpipe::writer::TypeId::INTEGER}, |
62 {L"height", relpipe::writer::TypeId::INTEGER}, |
62 {L"y_2", relpipe::writer::TypeId::INTEGER}, |
|
63 {L"x_3", relpipe::writer::TypeId::INTEGER}, |
|
64 {L"y_3", relpipe::writer::TypeId::INTEGER}, |
|
65 {L"x_4", relpipe::writer::TypeId::INTEGER}, |
|
66 {L"y_4", relpipe::writer::TypeId::INTEGER}, |
|
67 }, true); |
63 }, true); |
68 |
64 |
69 int n = scanner.scan(image); |
65 int n = scanner.scan(image); |
70 |
66 |
71 for (zbar::Image::SymbolIterator symbol = image.symbol_begin(); symbol != image.symbol_end(); ++symbol) { |
67 for (zbar::Image::SymbolIterator symbol = image.symbol_begin(); symbol != image.symbol_end(); ++symbol) { |
72 writer->writeAttribute(convertor.from_bytes(symbol->get_type_name())); |
68 writer->writeAttribute(convertor.from_bytes(symbol->get_type_name())); |
73 // writer->writeAttribute(convertor.from_bytes(symbol->get_addon_name())); |
69 // writer->writeAttribute(convertor.from_bytes(symbol->get_addon_name())); |
74 writer->writeAttribute(convertor.from_bytes(symbol->get_data())); |
70 writer->writeAttribute(convertor.from_bytes(symbol->get_data())); |
75 // writer->writeAttribute(convertor.from_bytes(symbol->xml())); |
71 // writer->writeAttribute(convertor.from_bytes(symbol->xml())); |
76 |
72 |
77 relpipe::common::type::Integer locationSize = symbol->get_location_size(); |
73 relpipe::common::type::Integer minX = 0; |
78 writer->writeAttribute(&locationSize, typeid (locationSize)); |
74 relpipe::common::type::Integer minY = 0; |
79 |
75 relpipe::common::type::Integer maxX = 0; |
80 for (int i = 0; i < 4; i++) { |
76 relpipe::common::type::Integer maxY = 0; |
81 relpipe::common::type::Integer x = -5; |
77 |
82 relpipe::common::type::Integer y = -6; |
78 // TODO: return original polygon in XML |
83 if (i < locationSize) { |
79 for (int i = 0, locationSize = symbol->get_location_size(); i < locationSize; i++) { |
84 x = symbol->get_location_x(i); |
80 relpipe::common::type::Integer x = symbol->get_location_x(i); |
85 y = symbol->get_location_y(i); |
81 relpipe::common::type::Integer y = symbol->get_location_y(i); |
86 } |
82 minX = minX ? std::min(minX, x) : x; |
87 writer->writeAttribute(&x, typeid (x)); |
83 minY = minY ? std::min(minY, y) : y; |
88 writer->writeAttribute(&y, typeid (y)); |
84 maxX = std::max(maxX, x); |
|
85 maxY = std::max(maxY, y); |
89 } |
86 } |
90 |
87 |
|
88 relpipe::common::type::Integer width = maxX - minX; |
|
89 relpipe::common::type::Integer height = maxY - minY; |
91 |
90 |
|
91 writer->writeAttribute(&minX, typeid (minX)); |
|
92 writer->writeAttribute(&minY, typeid (minY)); |
|
93 writer->writeAttribute(&width, typeid (width)); |
|
94 writer->writeAttribute(&height, typeid (height)); |
92 } |
95 } |
93 |
96 |
94 image.set_data(nullptr, 0); |
97 image.set_data(nullptr, 0); |
95 } |
98 } |
96 }; |
99 }; |