0

I need a gaussian blur function, which with big parameter takes a lot of time (1.8 s) to do. I want to make this function to work on its own, without stopping my entire code. This is a solution that I made. I was wondering - is there a proper way to do this?

is_done = False
done_blur = []
def get_blur(imag):
    global is_done, done_blur
    done_blur = cv2.GaussianBlur(imag, (333, 333), 0)
    is_done = True


_thread.start_new_thread(get_blur, (an_image,))
while True:## big loop, which has to keep working without waiting for blur function
    time.sleep(0.01)
    if is_done == True:
        back_blurred = done_blur
        is_done = False
Ri Di
  • 163
  • 5
  • It says something about "thread" in the code. Was there a problem with that? – mkrieger1 Jan 17 '21 at 12:46
  • Does this answer your question? [background function in Python](https://stackoverflow.com/questions/7168508/background-function-in-python) – mkrieger1 Jan 17 '21 at 12:47

0 Answers0