34 cv::Mat img = cv::imread(file_name);
47 unsigned int channels = input_frame.channels();
50 cv::cvtColor(input_frame, gray_frame, CV_BGR2GRAY);
53 int gaussiansharpenblur = 5;
54 float gaussiansharpenweight = 0.8;
57 normalize(gray_frame, gray_frame, 255, 0, cv::NORM_MINMAX);
58 cv::GaussianBlur(gray_frame, blured, cv::Size(0, 0), gaussiansharpenblur);
59 cv::addWeighted(gray_frame, 1 + gaussiansharpenweight, blured,
60 -gaussiansharpenweight, 0, gray_frame);
62 int width = gray_frame.cols;
63 int height = gray_frame.rows;
64 uchar *raw = gray_frame.data;
66 zbar::Image image(width, height,
"Y800", raw, width * height);
69 zbar::ImageScanner scanner;
70 scanner.set_config(zbar::ZBAR_NONE, zbar::ZBAR_CFG_ENABLE, 0);
71 scanner.set_config(zbar::ZBAR_QRCODE, zbar::ZBAR_CFG_ENABLE, 1);
74 std::vector<QrCode> qrs;
75 for (zbar::Image::SymbolIterator symbol = image.symbol_begin();
76 symbol != image.symbol_end(); ++symbol)
80 temp_qr.
message = symbol->get_data();
82 for(
int i = 0; i < symbol->get_location_size(); i++)
84 temp_qr.
center.x += symbol->get_location_x(i);
85 temp_qr.
center.y += symbol->get_location_y(i);
88 temp_qr.
center.x /= symbol->get_location_size();
89 temp_qr.
center.y /= symbol->get_location_size();
91 qrs.push_back(temp_qr);
107 if( input_frame.empty() )
109 return std::vector<QrCode>();
cv::Mat loadImage(std::string file_name)
Loads an image into a cv::Mat structure.
QrDetector(void)
Default constructor.
std::vector< QrCode > findQrs(std::string file_name)
Detects QRs in an image file.
std::vector< QrCode > detectQrs(const cv::Mat &img)
Detects QRs in a cv::Mat.
Structure holding the essential info for a QR code.