
Announcements
I am trying to run this script using run python script action of power automate desktop. I am imported this script as module in the flow. But I am unable to run this script. I am facing challenges and the script is throwing errors related to the library. I am attaching a snapshot of the same.
def extract(imagepath):
import cv2
# Read the image using OpenCV
image = cv2.imread(imagepath)
# Initialize the QR code detector
detector = cv2.QRCodeDetector()
# Detect and decode the QR code
data, bbox, _ = detector.detectAndDecode(image)
if data:
print data
else:
print None
In my downloads folder this file is stored as QR_Final.py.Steps to decode a QR code
Since the Run Python script action in Power Automate only supports Python 3.4, and OpenCV is not compatible with that version, follow the steps below to decode QR codes using a more recent Python version.
1. install python in your system 3.12
2. install Opencv through CMD (pip install opencv-python, pip install pyzbar)
3. Open notepad paste the code provided below, and save the file with a .py extension
import cv2
from pyzbar.pyzbar import decode
import sys