I want to make QR Code reader with using opencv and Python. My hardware is Raspberry Pi 4B and pi camera.

In the code, When I show the QR Code to camera opencv decode the QR. After that I want to send this code with using requests.post to Node.js server. Everything is okay in there but there is a problem. The problem is that As long as the same QR Code stays in front of the camera, it constantly sends post requests with that code.

In the system, people will read the QR Code from their mobile phone and enter the building according to the code. Nodejs sends unlimited requests to the server, as a person sends the QR Code as long as it is held on the screen.

Actually the system should work like this,

The user keeps the QR Code in the camera.

With requests.post, the code is sent to the server.

The server returns a negative or positive response.

The answer appears on the screen.

No action is taken until the next user arrives.

Please give me your opinion on this matter.

How can I stop sending requests until a different user arrives?

How can I control this with a function?

test.py

```
basic_auth_url= "http://192.168.1.6:3000/test"

def qr_test(code):
    myObj={"code":code}
    response = requests.post(
            url=basic_auth_url,
            data=myObj
            )

    print(response.content)

cap = cv2.VideoCapture(0)

detector = cv2.QRCodeDetector()

while True:
    _, img = cap.read()
    data, bbox, _ = detector.detectAndDecode(img)

    if(bbox is not None):
        for i in range(len(bbox)):
            cv2.line(img, tuple(bbox[i][0]), tuple(bbox[(i+1) % len(bbox)][0]), color=(255,
                     0, 255), thickness=2)
        cv2.putText(img, data, (int(bbox[0][0][0]), int(bbox[0][0][1]) - 10), cv2.FONT_HERSHEY_SIMPLEX,
                    0.5, (0, 255, 0), 2)
        if data:

            code=data
            code1=str(code)
            code=code.split("|")

            code_1=code[1]
            code_1=code_1[0:10]
            qr_test(code_1)
    cv2.imshow("code detector", img)
    if(cv2.waitKey(1) == ord("q")):
        break
cap.release()
cv2.destroyAllWindows()

```