Skip to content

Problem with encodeStructuredAppend function #22205

@Boorgir

Description

@Boorgir
System information (version)
  • OpenCV => 4.5.5 and 4.6.0
  • Operating System / Platform =>Windows 64 Bit
  • Compiler => Visual Studio 2022
  • Language => C++
Detailed description

Hello there ! I’m working with OpenCV in order to generate QR Codes.
I want to use the function encodeStructuredAppend from objdetect.hpp so I used the test test_qrcode_encode.cpp to understand this function.

However, no matter what params.structure_number equal the number of QRcodes generated is one.

If I try with params.structure_number = 1 it generates only one QR code with all the informations in it but if I put more than one it generates only one QR code with only the end of the string minus one.

I asked the question on the forum and a moderator told me to report the bug.
https://forum.opencv.org/t/problem-with-encodestructuredappend-function/9417

Steps to reproduce
main.cpp
// C++ code example

#include <iostream>
#include "opencv2/opencv.hpp"
#include <opencv2/objdetect.hpp>
#include <vector>


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);
    
    if(qrcodes.empty()) std::cout << "Can't generate this QR images";
    std::cout << qrcodes.size() << std::endl;

    for (size_t k = 0; k < qrcodes.size(); k++)
    {
        cv::Mat qrcode = qrcodes[k];
        std::string sav = "qrcode/qr" + std::to_string(k) + ".jpg";
        cv::imwrite(sav, qrcode);
        std::cout << k << 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

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions