Skip to content

QRCodeEncoder generateQR() method data loss because of wrong indexing #23105

@neg-c

Description

@neg-c

System Information

OpenCV version : 4.7.0
Operating System : Arch Linux
Compiler & compiler version: GCC 12.2.0

Detailed description

While generating QR codes with Structured Append mode (encodeStructuredAppend()) it loses some data.

e.g. while the input data is : Some text to test, more or less big, i tried differents things

We get 3 QR codes with data:

  • Part 1 : Some text to test, m
  • Part 2 : ore or less big, i t
  • Part 3 : ried differents thin

Steps to reproduce

Sample code:

int main()
{
    std::string input_info = "Some text to test, more or less big, i tried differents things";
    cv::QRCodeEncoder::Params params;
    params.structure_number = 3;
    params.mode = cv::QRCodeEncoder::EncodeMode::MODE_STRUCTURED_APPEND;

    cv::Ptr<cv::QRCodeEncoder> encoder = cv::QRCodeEncoder::create(params);

    std::vector<cv::Mat> qrcodes;

    encoder->encodeStructuredAppend(input_info, qrcodes);
    
    for (size_t k = 0; k < qrcodes.size(); k++)
    {
        cv::Mat qrcode = qrcodes[k];
        std::string sav = std::to_string(k) + ".jpg";
        cv::imwrite(sav, qrcode);
        std::cout<<"Path :"<<sav<<std::endl;
    }
}

Issue submission checklist

  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
  • I updated to the latest OpenCV version and the issue is still there
  • There is reproducer code and related data files (videos, images, onnx, etc)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions