themblem/alg/libqr.h
2024-09-01 21:51:50 +01:00

49 lines
1.1 KiB
C++

#ifndef LIBQR_H
#define LIBQR_H
#include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/core.hpp"
#include "opencv2/calib3d.hpp"
#include <string>
#include <vector>
using namespace cv;
using namespace std;
typedef Mat CvImg;
struct ProcessState {
CvImg *orig;
std::vector<Point> qr_points;
float scale;
Mat transform;
CvImg preprocessed;
CvImg straighten;
Rect qr_rect_in_straighten;
CvImg qr_straighten;
CvImg dot_area;
CvImg dot_area_gray;
string qrcode = "";
double clarity;
float laplacian_thres = 0.1;
};
bool preprocess(ProcessState &ps);
bool emblem_dot_angle(ProcessState &ps, cv::InputArray in, float &angle, std::string &qrcode, std::string &err);
bool detect_qr(ProcessState &ps, float margin_ratio, bool warp, string &err);
enum SimilarityAlg {
CellWeight,
FuzzyPixelCmp,
};
double emblem_roi_similarity(SimilarityAlg alg, InputArray a, InputArray b, string &err);
double laplacian(Mat &gray, string &err);
static inline void showimg_(const char *title, Mat &img) {
imshow(title, img);
waitKey(0);
}
#define show(img) showimg_(#img, img)
#endif