Skip to content

Instantly share code, notes, and snippets.

@mshabunin
Last active June 5, 2023 08:11
Show Gist options
  • Save mshabunin/0e6a719761777ce2020553014b3783e6 to your computer and use it in GitHub Desktop.
Save mshabunin/0e6a719761777ce2020553014b3783e6 to your computer and use it in GitHub Desktop.

QRCode

bool detect(InputArray img, OutputArray points) const;
string decode(InputArray img, InputArray points, OutputArray straight_qrcode = noArray()) const;
string detectAndDecode(InputArray img, 
                       OutputArray points=noArray(), 
                       OutputArray straight_qrcode = noArray()) const;
// + curved
bool detectMulti(InputArray img, OutputArray points) const;
bool decodeMulti(InputArray img, 
                 InputArray points,
                 vector<string>& decoded_info, 
                 OutputArrayOfArrays straight_qrcode = noArray()) const;
bool detectAndDecodeMulti(InputArray img, 
                          vector<string>& decoded_info, 
                          OutputArray points = noArray(),
                          OutputArrayOfArrays straight_qrcode = noArray()) const;

Barcode

bool detect(InputArray img, OutputArray points) const;
bool decode(InputArray img, 
            InputArray points, 
            vector<string> &decoded_info, 
            vector<BarcodeType> &decoded_type) const;
bool detectAndDecode(InputArray img, 
                     vector<string> &decoded_info,
                     vector<BarcodeType> &decoded_type, 
                     OutputArray points = noArray()) const;

WeChat

vector<string> detectAndDecode(InputArray img, OutputArrayOfArrays points = noArray());

Aruco

void detectMarkers(InputArray image, OutputArrayOfArrays corners, OutputArray ids,
                               OutputArrayOfArrays rejectedImgPoints = noArray()) const;

Charuco

void detectBoard(InputArray image,
                 OutputArray charucoCorners, 
                 OutputArray charucoIds,
                 InputOutputArrayOfArrays markerCorners = noArray(),
                 InputOutputArray markerIds = noArray()) const;
void detectDiamonds(InputArray image, 
                    OutputArrayOfArrays diamondCorners,
                    OutputArray diamondIds,
                    InputOutputArrayOfArrays markerCorners = noArray(),
                    InputOutputArrayOfArrays markerIds = noArray()) const;

Chessboard

bool findChessboardCorners(InputArray image, Size patternSize, OutputArray corners,
                           int flags = CALIB_CB_ADAPTIVE_THRESH + CALIB_CB_NORMALIZE_IMAGE );

Proposal 1

struct CodeResult
{
    string text; // can it by byte array?
    code_type type; // bar, qr, Data Matrix, JAB, Aztec
    code_subtype subtype; // combine with previous? needed?
    vector<Point> location; // 4 points, should it be vector?
};

vector<CodeResult> detect(InputArray img);
vector<CodeResult> detectAndDecode(InputArray img);
void decode(InputArray img, vector<CodeResult> & results);

Proposal 2

struct CodeResults
{
    // Java-style iterator
    void next();
    bool isDone();
    // Data
    string getText();
    code_type getType();
    code_subtype getSubtype();
    vector<Point> getLocation();
    // add more fields preserving API/ABI(?) compatibility
};
struct ICodeDetector
{
    CodeResults detect(InputArray img) = 0;
    CodeResults detectAndDecode(InputArray img) = 0;
    void decode(InputArray img, CodeResults & results) = 0;
    // advanced?
    void refine(InputArray img, CodeResults & results, Ptr<IRefiner> refiner);
};
struct ICodeDecoder {}; // separate interface for decoding? refining?

Inverse (looks strange?):

Ptr<BarcodeDetector> det = makeBarcodeDetector();

CodeResults res;
res.detect(det);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment