Added Aruco-based QR code detection method to python sample.

This commit is contained in:
Alexander Smorkalov 2023-06-13 15:38:26 +03:00
parent e60a7c0d49
commit 3f4ec3596e

View File

@ -33,6 +33,7 @@ class QrSample:
self.multi = args.multi
self.saveDetections = args.save_detections
self.saveAll = args.save_all
self.arucoBased = args.aruco_based
def getQRModeString(self):
msg1 = "multi " if self.multi else ""
@ -104,7 +105,12 @@ class QrSample:
return
print('Run {:s} on image [{:d}x{:d}]'.format(
self.getQRModeString(), inputimg.shape[1], inputimg.shape[0]))
if self.arucoBased:
qrCode = cv.QRCodeDetectorAruco()
else:
qrCode = cv.QRCodeDetector()
count = 10
timer = cv.TickMeter()
for _ in range(count):
@ -152,6 +158,9 @@ class QrSample:
print("Press ' ' (space) to save result into images")
print("Press 'ESC' to exit")
if self.arucoBased:
qrcode = cv.QRCodeDetectorAruco()
else:
qrcode = cv.QRCodeDetector()
while True:
@ -204,6 +213,10 @@ def main():
help="input image path (for example, 'opencv_extra/testdata/cv/qrcode/multiple/*_qrcodes.png)",
default="",
metavar="")
parser.add_argument(
'--aruco_based',
help="use aruco-based detector",
action='store_true')
parser.add_argument(
'-d',
'--detect',