Reputation: 313
I wrote a simple QrCode detection and decode code with OpenCV.
But the problem I'm facing is that the QR code gets detected but can't be decoded with the following image (see bottom).
The code I wrote looks like this:
int main(int argc, char* argv[])
{
cv::Mat src = imread("scaled.png");
if(src.empty())
{
cout << "can not open " << "Picture" << endl;
return -1;
}
QRCodeDetector qrDecoder = QRCodeDetector();
std::string data;
data = qrDecoder.detectAndDecode(src);
if(data.length()>0)
{
cout << "data: " << data; //data should be STOP
}
return 0;
}
Does somebody know why the QR code can be detected but not decoded ?
Here the image I used:
Edit: I've searched a little more about QR code detection with OpenCv and found these to code snippets from: https://docs.opencv.org/3.4.9/de/dc3/classcv_1_1QRCodeDetector.html
setEpsX(double epsX)
setEpsY(double epsY)
unfortunately the documentation is very bad so those somebody know what these 2 parameters are and if they can fix my problem ?
Upvotes: 2
Views: 4286
Reputation: 313
I think I found the problem:
The image I use has a Size of 2400x1600 which is to big to decode. Therefore I resized the image before I decode the image so my code looks like this:
int main(int argc, char* argv[])
{
cv::Mat src = imread("scaled.png");
if(src.empty())
{
cout << "can not open " << "Picture" << endl;
return -1;
}
std::string data;
cv::resize(src,src, cv::Size(1600,1200));
QRCodeDetector qrDecoder = QRCodeDetector();
data = qrDecoder.detectAndDecode(src);
if(data.length()>0)
{
cout << "data: " << data; //data should be STOP
}
return 0;
}
Upvotes: 3