mirror of
https://github.com/opencv/opencv.git
synced 2024-11-24 03:00:14 +08:00
Added Aruco-based QR code detection method to python sample.
This commit is contained in:
parent
e60a7c0d49
commit
3f4ec3596e
@ -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]))
|
||||
qrCode = cv.QRCodeDetector()
|
||||
|
||||
if self.arucoBased:
|
||||
qrCode = cv.QRCodeDetectorAruco()
|
||||
else:
|
||||
qrCode = cv.QRCodeDetector()
|
||||
|
||||
count = 10
|
||||
timer = cv.TickMeter()
|
||||
for _ in range(count):
|
||||
@ -152,7 +158,10 @@ class QrSample:
|
||||
print("Press ' ' (space) to save result into images")
|
||||
print("Press 'ESC' to exit")
|
||||
|
||||
qrcode = cv.QRCodeDetector()
|
||||
if self.arucoBased:
|
||||
qrcode = cv.QRCodeDetectorAruco()
|
||||
else:
|
||||
qrcode = cv.QRCodeDetector()
|
||||
|
||||
while True:
|
||||
ret, frame = cap.read()
|
||||
@ -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',
|
||||
|
Loading…
Reference in New Issue
Block a user