Created
October 12, 2018 14:34
-
-
Save prostoiChelovek/3b8ec0a4c1f84604dbe548ee079f0715 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef QRREADER_HPP | |
#define QRREADER_HPP | |
#include <opencv2/opencv.hpp> | |
#include <zbar.h> | |
using namespace cv; | |
using namespace std; | |
using namespace zbar; | |
typedef struct | |
{ | |
string type; | |
string data; | |
vector<Point> location; | |
} decodedObject; | |
void decode(Mat &im, vector<decodedObject> &decodedObjects) | |
{ | |
ImageScanner scanner; | |
scanner.set_config(ZBAR_NONE, ZBAR_CFG_ENABLE, 1); | |
Mat imGray; | |
cvtColor(im, imGray, COLOR_BGR2GRAY); | |
Image image(im.cols, im.rows, "Y800", (uchar *)imGray.data, im.cols * im.rows); | |
int n = scanner.scan(image); | |
for (Image::SymbolIterator symbol = image.symbol_begin(); symbol != image.symbol_end(); ++symbol) | |
{ | |
decodedObject obj; | |
obj.data = symbol->get_data(); | |
cout << "Data : " << obj.data << endl | |
<< endl; | |
for (int i = 0; i < symbol->get_location_size(); i++) | |
{ | |
obj.location.push_back(Point(symbol->get_location_x(i), symbol->get_location_y(i))); | |
} | |
decodedObjects.push_back(obj); | |
} | |
} | |
#endif // !QRREADER_HPP |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment