Skip to content

Commit

Permalink
Merge pull request #5 from AleksandrPanov:add_arucoQR_detect
Browse files Browse the repository at this point in the history
Add detect QR code with Aruco method
  • Loading branch information
asmorkalov committed Sep 4, 2023
2 parents 3fe52ba + 30b8be1 commit d26ccad
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions python_benchmarks/qr_codes/qr.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@


class DetectorQR:
TypeDetector = Enum('TypeDetector', 'opencv opencv_wechat')
TypeDetector = Enum('TypeDetector', 'opencv opencv_aruco opencv_wechat')

def __init__(self):
self.detected_corners = np.array([])
Expand All @@ -49,6 +49,12 @@ def decode(self, image):
return True, self.decoded_info, self.detected_corners


class CvArucoDetector(CvObjDetector):
def __init__(self):
super().__init__()
self.detector = cv.QRCodeDetectorAruco()


class CvWechatDetector(DetectorQR):
def __init__(self, path_to_model="./"):
super().__init__()
Expand All @@ -75,6 +81,8 @@ def decode(self, image):
def create_instance_qr(type_detector=DetectorQR.TypeDetector.opencv, path_to_model="./"):
if type_detector is DetectorQR.TypeDetector.opencv:
return CvObjDetector()
if type_detector is DetectorQR.TypeDetector.opencv_aruco:
return CvArucoDetector()
if type_detector is DetectorQR.TypeDetector.opencv_wechat:
return CvWechatDetector(path_to_model)
raise TypeError("this type_detector isn't supported")
Expand Down Expand Up @@ -159,7 +167,7 @@ def main():
parser.add_argument("-a", "--accuracy", help="input accuracy", default="20", action="store", dest="accuracy",
type=float)
parser.add_argument("-alg", "--algorithm", help="QR detect algorithm", default="opencv", action="store",
dest="algorithm", choices=['opencv', 'opencv_wechat'], type=str)
dest="algorithm", choices=['opencv', 'opencv_aruco', 'opencv_wechat'], type=str)
parser.add_argument("--metric", help="Metric for distance between QR corners", default="l2", action="store",
dest="metric", choices=['l1', 'l2', 'l_inf', 'intersection_over_union'], type=str)

Expand Down

0 comments on commit d26ccad

Please sign in to comment.