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