Remove Python duplicate output and output only once

Asked 2 years ago, Updated 2 years ago, 83 views

If the number of fingers is recognized and the number of fingers is satisfied, the print is printed in cmd, but the print is duplicated.

if (now1-before1).seconds >= 2:
    cv2.putText(frame, 'hello', (0, 100), font, 2, (0, 0, 255), 3, cv2.LINE_AA)
    print("mode1")

The sauce is roughly in this format, but how do I have to condition it so that it can be printed once?

opencv python

2022-09-22 19:31

1 Answers

The information in the question alone does not explain the reason.

Python has a built-in debugger called pdb.

Please refer to the tutorial below and try debugging it yourself.

https://realpython.com/python-debugging-pdb/

if (now1-before1).seconds >= 2:
    cv2.putText(frame, 'hello', (0, 100), font, 2, (0, 0, 255), 3, cv2.LINE_AA)
    breakpoint() # python 3.7 or later    
    # import pdb; pdb.set_trace() # python 3.6 or less 
    #print("mode1")


2022-09-22 19:31

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.