Read a QR code and extract the data Link to heading

In our case, we want to get the TOTP URL out of a QR code. Documentation for the OTP URL format can be found here on the Yubico website.

Sample code to get the data out of a QRCode image using the OpenCV2 library is here.

This should produce some output such as the following:


we can then use the PyOTP library to extract the TOTP values as needed:

import pyotp
import time

totp = pyotp.parse_uri("otpauth://totp/") # => '609257'
time.sleep(30) # => '924749'