I want to continue application after waiting a thread complete in PyQt5. In this code, self.capture_handle.relabeling_thread() gets current image in widget and after display it into new widget. I use time.sleep(0.3) to wait thread getting image. I think this way is so bad. So how can I do without the need to use time.sleep(0.3)?
def relabeling(self):
self.capture_handle.relabeling_thread() # get image
time.sleep(0.3) # wait thread complete
self.labeling.mainWidget.setCurrentImage(path_save_cvImage) # displai image into new widget
self.labeling.setBtnEnable(1)
self.labeling.reset_json()
self.labeling.show()
relabeling_thread() function to emit a signal requiring a thread of camera to get a image (the same capture image in camera)
def relabeling_thread(self):
signal = 1
self.proxy_relabeling_signal.my_signal_relabeling.emit(signal)
here thread of camera:
def stream_predict_thread(self):
try:
if threashold > 0 and threashold < 1 and self.model_yolo != 0:
self.thread[2] = PREDICT_IMAGE(index=2, cv_image_path = path_save_edited_Image, model=self.model_yolo, threashold = threashold)
self.thread[2].start()
self.proxy_relabeling_signal.my_signal_relabeling.connect(self.thread[2].proxy_relabeling.my_signal_relabeling.emit)