简体   繁体   中英

How to use the functions Emgu.CV.QRCodeDetector.Detect and Emgu.CV.QRCodeDetector.Decode?

I'm using Emgu CV v4.6 with C# 6.0 on Visual Studio. I need to scan a QR code using Emgu CV but I have no clue about how to use the functions Emgu.CV.QRCodeDetector.Detect and Emgu.CV.QRCodeDetector.Decode . In the documentation, it is said that Decode() needs Quadrangle vertices found by Detect() method whereas Detect() only returns a bool (that tells wether a QR code is detected or not) and we cannot access anything in a QRCodeDetector object.

Here is my current code for context:

Image<Bgr, Byte> img1 = new Image<Bgr, Byte>(@"C:\Users\Dacapo\source\repos\qrcode_reading\qrcode_reading\qr.jpg");
IInputArray img1arr = img1;
Mat pos = new Mat(1, 2, Emgu.CV.CvEnum.DepthType.Cv32S, 1);

QRCodeDetector detector = new QRCodeDetector();
bool decoded = detector.Detect(img1arr, pos); //this returns true

And here is qr.jpg:
二维码测试代码

According to their docs at: https://www.emgu.com/wiki/files/4.6.0/document/html/Methods_T_Emgu_CV_BarcodeDetector.htm there is now a DetectAndDecode() method which can take two overloads. Hope this helps. I am currently working on a similar implementation so I'll report any progress here.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM