def openVideo(self, img_dir=None, n_frame=None, plot_dir=None): """Open video/plot and jump to the frame number (if given) Keyword Arguments: img_dir {str} -- Path where the images are located (for the video player) (default: {None}) n_frame {int} -- Frame number from where the video should start from (default: {None}) plot_dir {str} -- Path where the images are located (for the plot player) (default: {None}) """ if n_frame is not None and n_frame < 0: n_frame = 0 img = None if img_dir is not None: self.vid_opened = True self.images = sutils.listDirectory(img_dir, extension=".png") width = self.vid_player.width() height = self.vid_player.height() img = self.image_holder.setup(self.images, width, height, colour=self.user["Colour"], n_frame=n_frame) plot_img = None if plot_dir != None: plots = sutils.listDirectory(plot_dir, extension=".png") logging.info("Plots: {0}".format(len(plots))) width = self.plot_player.width() height = self.plot_player.height() plot_img = self.plot_holder.setup(plots, width, height, colour=self.user["Colour"], n_frame=n_frame) self.changeFrameTo(img, plot_img)
def startCalc(self, update=0): """Start speed calculation with or without superpixels Keyword Arguments: update {int} -- helper for accurate progress update with optimization (default: {0}) Returns: int -- helper for progress update (iteration number) """ img_fns = utils.listDirectory(self.img_dir) fst_img_fns, snd_img_fns = img_fns, img_fns disp_fns = utils.listDirectory(self.depth_dir, extension=".npy") fst_disp_fns, snd_disp_fns = disp_fns, disp_fns flow_fns = utils.listDirectory(self.of_dir, extension=".flo") back_flow = utils.listDirectory(self.back_of_dir, extension=".flo") calculate_velocity = calculateVelocityAndOrientationWrapper assert len(fst_img_fns) == len(snd_img_fns) assert len(fst_disp_fns) == len(snd_disp_fns) if self.back_of_dir != None: assert len(flow_fns) == len(back_flow) if self.super_pixel_method != "": label_fns_files = utils.listDirectory(self.super_pixel_label_dir, extension=".npy") label_fns = [] for label in label_fns_files: label_fns.append(np.load(label)) else: label_fns = fst_img_fns # So it doesn't quit too early params = zip( fst_img_fns, snd_img_fns, fst_disp_fns, snd_disp_fns, label_fns, flow_fns, back_flow, itertools.repeat(self.out_dir), itertools.repeat(self.use_slic), itertools.repeat(self.n_sps), itertools.repeat(self.visualize), itertools.repeat(self.high), itertools.repeat(self.low), itertools.repeat(self.super_pixel_method), itertools.repeat(self.create_draw), itertools.repeat(self.create_velocity), ) with multiprocessing.Pool() as pool: with tqdm.tqdm(total=len(fst_img_fns)) as pbar: count = 1 for _, i in enumerate( pool.imap_unordered(calculate_velocity, params)): self.update.emit(count + update) pbar.update() count += 1 return count + update
def test_plot_run(self): self.run.ui.c_speed_plot.setChecked(True) self.prepare_run(empty=True) plot_speed = os.path.join(self.result, "plot_speed") self.assertEqual(os.path.exists(plot_speed), True) img_num = len(listDirectory(self.img, extension=".png")) speed_num = len(listDirectory(plot_speed, extension=".png")) self.assertEqual(img_num - 1, speed_num)
def test_superpixel_run(self): self.run.ui.combo_superpixel.setCurrentIndex(1) self.run.changeSuperPixelMethod(1) self.prepare_run() superpixel_dir = os.path.join(self.result, "super_pixel") self.assertEqual(os.path.exists(superpixel_dir), True) img_num = len(listDirectory(self.img, extension=".png")) superpixel_num = len(listDirectory(superpixel_dir, extension=".png")) self.assertEqual(img_num - 1, superpixel_num)
def test_simple_run(self): self.prepare_run(empty=True) img_num = len(listDirectory(self.img, extension=".png")) depth_num = len(listDirectory(self.depth, extension=".png")) of_num = len(listDirectory(self.of, extension=".png")) back_of_num = len(listDirectory(self.back_of, extension=".png")) mask_num = len(listDirectory(self.mask, extension=".png")) self.assertEqual(img_num, depth_num) self.assertEqual(of_num, back_of_num) self.assertEqual(img_num - 1, of_num) self.assertEqual(img_num - 1, mask_num)
def minFunc(self, params, count): """Optimization main function. Called by the grid search. Arguments: params {(int,int)} -- Tuple: parameter for low and high count {int} -- count helper for progress update Returns: (float, int) -- Tuple: rmse result for the given parameter run and count helper for progress update """ self.low = params[0] self.high = params[1] count = self.startCalc(count) np_dir = utils.getResultDirs()["Numbers"] speeds_dir = utils.listDirectory(os.path.join(self.out_dir, np_dir), extension="speed.npy") speeds = [] for s in speeds_dir: speeds.append(np.load(s)) rmse = utils.errorComparisonSpeedVectors(speeds, self.speed_gt[1:]) for s in speeds_dir: os.remove(s) logging.info("RMSE {0}, Low {1} High {2}".format( rmse, self.low, self.high)) self.csv_list.append({ "Low": self.low, "High": self.high, "RMSE": rmse }) return rmse, count
def buildRunDict(self): """Create images from video in another thread, loads the image number otherwise """ self.showProgressBar() ori_images = 0 if self.img_exist: ori_images = len(listDirectory(self.savePathJoin("Images"))) self.buildRunDictMain(ori_images) else: self.run_dict["Video"] = { "Run": True, "Progress": ori_images, "Text": "Preparing video", } self.buildParamsDict() self.params_dict["send_video_frame"] = True self.progressLabel.setText("Create images from video") self.worker = calcRunner.CalculationRunner( self.params_dict) # no parent! self.thread = QThread() # no parent! self.worker.labelUpdate.connect(self.labelUpdate) self.worker.update.connect(self.progressUpdate) self.worker.videoFrame.connect(self.setVidFrame) self.worker.moveToThread(self.thread) self.thread.started.connect(self.worker.startThread) self.thread.start()
def createVid(self, images_path, save_path, vid_name, fps=30): """Create video from the images in the given path with the given fps Arguments: images_path {str} -- path to images save_path {str} -- path to save the video vid_name {str} -- the name of the created video Keyword Arguments: fps {int} -- fps for the video (default: {30}) """ images = utils.listDirectory(images_path, extension=".png") frame = cv2.imread(images[0]) height, width, layers = frame.shape out = cv2.VideoWriter( os.path.join(save_path, vid_name), cv2.VideoWriter_fourcc(*"mp4v"), fps, (width, height), ) for i in range(len(images)): logging.info("Writing frame: {0}".format(i)) # writing to an image array img = cv2.imread(images[i]) resized = cv2.resize(img, (width, height)) out.write(resized) self.update.emit(i) out.release()
def createSuperPixel(self): """Start super pixel calculation on multiple cpu cores """ logging.info("Create SUPER pixel label") images = utils.listDirectory(self.img_dir, extension=".png") params = zip( itertools.repeat(self.super_pixel_method), itertools.repeat(images), range(0, len(images)), itertools.repeat(self.super_pixel_label_dir), ) self.startMultiFunc(createSuperPixelMain, params)
def startDepth(self): # A slot takes no params """Start depth estimation """ img_list = utils.listDirectory(self.img_dir) for i, img in enumerate(img_list): logging.info("Running depth estimation on: {0}".format(img)) monodepth.run( image_path=img, checkpoint_path=self.depth_model, save_path=os.path.join(self.depth_dir, ""), ) self.update.emit(i)
def createSpeedPlot(self): """Start speed plot creation on multiple cpu cores """ plt.clf() speeds_dir = utils.listDirectory(os.path.join(self.out_dir, self.numbers_dir), extension="speed.npy") speeds_dir = natsorted(speeds_dir) speeds = [] for i, s in enumerate(speeds_dir): speeds.append(np.load(s)) params = zip( itertools.repeat(speeds), range(1, len(speeds) + 1), itertools.repeat(os.path.join(self.out_dir, self.plot_speed_dir)), ) self.startMultiFunc(createSpeedPlotMain, params)
def startOf(self): """Start optical flow calculation """ img_list = utils.listDirectory(self.img_dir) of_list = [(img_list[ind], img_list[ind + 1], ind) for ind in range(len(img_list) - 1)] for ind in range(len(img_list) - 1): logging.info("Running optical flow on: {0} {1}".format( img_list[ind], img_list[ind + 1])) flo_file = os.path.join(self.of_dir, "{0}.flo".format(ind)) pwc.setupArguments( model=self.of_model, first_img=img_list[ind], second_img=img_list[ind + 1], save_path=flo_file, ) pwc.run() # Transform from flo to png flow = fz.convert_from_file(flo_file) Image.fromarray(flow).save( os.path.join(self.of_dir, "{0}.png".format(ind))) self.update.emit(ind)
def createSpeedErrorPlot(self): """Start speed and ground truth speed comparison plot creation on multiple cpu cores Sends signal with error message if ground truth has wrong shape """ plt.clf() speeds_dir = utils.listDirectory(os.path.join(self.out_dir, self.numbers_dir), extension="speed.npy") speeds_dir = natsorted(speeds_dir) speeds = [] for s in speeds_dir: speeds.append(np.load(s)) ground_truth = self.speed_gt[1:] params = zip( itertools.repeat(speeds), itertools.repeat(ground_truth), range(1, len(ground_truth) + 1), itertools.repeat(os.path.join(self.out_dir, self.plot_speed_dir)), ) self.startMultiFunc(createSpeedErrorPlotMain, params)
def startBackOf(self): # A slot takes no params """Start backward optical flow calculation """ img_list = utils.listDirectory(self.img_dir) for ind in reversed(range(len(img_list) - 1)): logging.info("Running back optical flow on: {0} {1}".format( img_list[ind], img_list[ind - 1])) back_flo_file = os.path.join(self.back_of_dir, "{0}.flo".format(ind)) pwc.setupArguments( model=self.of_model, first_img=img_list[ind], second_img=img_list[ind - 1], save_path=back_flo_file, ) pwc.run() # Transform from flo to png flow = fz.convert_from_file(back_flo_file) Image.fromarray(flow).save( os.path.join(self.back_of_dir, "{0}.png".format(ind))) self.update.emit(abs(ind - len(img_list)))
def createErrorPlot(self): """Start error plot creation on multiple cpu cores Sends signal with error message if ground truth has wrong shape """ plt.clf() speeds_dir = utils.listDirectory(os.path.join(self.out_dir, self.numbers_dir), extension="speed.npy") speeds_dir = natsorted(speeds_dir) speeds = [] for i, s in enumerate(speeds_dir): speeds.append(np.load(s)) csv = None if self.create_csv: csv = os.path.join(self.out_dir, "_error_Simple_OF.csv") try: _ = utils.errorComparisonSpeedVectors(speeds, self.speed_gt[1:], csv=csv) except: self.error.emit( "Error with the Ground Truth file, doesn't have correct shape") self.ground_truth_error = True return error = abs(self.speed_gt[1:] - speeds) params = zip( itertools.repeat(error), range(1, len(error) + 1), itertools.repeat(os.path.join(self.out_dir, self.plot_error_dir)), ) self.startMultiFunc(createErrorPlotMain, params)
def createCrashPlot(self): """Start crash plot creation on multiple cpu cores """ plt.clf() speeds_dir = utils.listDirectory(os.path.join(self.out_dir, self.numbers_dir), extension="speed.npy") velocity_dir = utils.listDirectory(os.path.join( self.out_dir, self.numbers_dir), extension="velocity.npy") mask_dir = utils.listDirectory(os.path.join(self.out_dir, self.numbers_dir), extension="mask.npy") object_det_dir = utils.listDirectory(self.object_detection_dir, extension=".npy") speeds_dir = natsorted(speeds_dir) velocity_dir = natsorted(velocity_dir) mask_dir = natsorted(mask_dir) object_det_dir = natsorted(object_det_dir) speeds = [] for i in range(len(speeds_dir)): v = np.load(speeds_dir[i]) box = np.load(object_det_dir[i]) simple_mask = np.load(mask_dir[i]) logging.info("Found boxes: {0}".format(box.shape[0])) box_mask = np.zeros_like(simple_mask) for j, b in enumerate(box): x, y, w, h = b x_high = x + w y_high = y + h box_mask[y:y_high, x:x_high] = 1 # tmp = np.zeros_like(simple_mask) # tmp[y : y_high, x: x_high] = 1 # plt.matshow(tmp*200) # plt.savefig(os.path.join(self.out_dir, "{0}_{1}_box.png".format(i, j)), bbox_inches='tight', dpi=150) mask = box_mask if box.shape[0] == 0: mask = simple_mask s = np.load(velocity_dir[i]) # t = v / s z = s[:, :, 2] z_thr = z[mask] z_abs = np.abs(z_thr[z_thr != 0]) if len(z_abs) == 0: z_thr = z[simple_mask] z_abs = np.abs(z_thr[z_thr != 0]) ttc = np.mean(np.divide(v, z_abs)) * 360 speeds.append(ttc) params = zip( itertools.repeat(speeds), range(1, len(speeds) + 1), itertools.repeat(os.path.join(self.out_dir, self.plot_crash_dir)), ) self.startMultiFunc(createCrashPlotMain, params)
def prepare_run(self, empty=False): self.run.user["Save"] = os.path.join( os.path.dirname(os.path.realpath(__file__)), "test" ) self.img = os.path.join(self.run.user["Save"], "Images") self.depth = os.path.join(self.run.user["Save"], "Depth") self.of = os.path.join(self.run.user["Save"], "Of") self.back_of = os.path.join(self.run.user["Save"], "Back_Of") self.result = os.path.join(self.run.user["Save"], "results") self.numbers = os.path.join(self.result, "numbers") self.mask = os.path.join(self.result, "mask") if empty: tmp = [self.depth, self.of, self.back_of, self.result] for t in tmp: if os.path.exists(t): shutil.rmtree(t) self.run.checkFiles() self.run.disableButtons() self.run.createDirs() ori_images = len(listDirectory(self.img)) self.run.run_dict["Of"] = { "Run": not self.run.of_exist, "Progress": ori_images, "Text": "Running optical flow", } self.run.run_dict["Back_Of"] = { "Run": not self.run.back_of_exist, "Progress": ori_images, "Text": "Running back optical flow", } self.run.run_dict["Depth"] = { "Run": not self.run.depth_exist, "Progress": ori_images, "Text": "Running depth estimation", } self.run.run_dict["Speed"] = { "Run": True, "Progress": ori_images, "Text": "Running speed estimation", } self.run.run_dict["Optimization"] = { "Run": self.run.ui.c_optimize.isChecked(), "Progress": ori_images * 9, "Text": "Running parameter optimization", } self.run.run_dict["Of_Vid"] = { "Run": self.run.ui.c_of.isChecked(), "Progress": ori_images, "Text": "Creating optical flow video", } self.run.run_dict["Back_Of_Vid"] = { "Run": self.run.ui.c_back_of.isChecked(), "Progress": ori_images, "Text": "Creating backward optical flow video", } self.run.run_dict["Depth_Vid"] = { "Run": self.run.ui.c_depth.isChecked(), "Progress": ori_images, "Text": "Creating depth estimation video", } self.run.run_dict["Speed_Plot"] = { "Run": self.run.ui.c_speed_plot.isChecked(), "Progress": ori_images, "Text": "Creating plot for speed values", } self.run.run_dict["Crash_Plot"] = { "Run": self.run.ui.c_crash_plot.isChecked(), "Progress": ori_images, "Text": "Creating plot for time to crash", } self.run.run_dict["Error_Plot"] = { "Run": self.run.ui.c_error_plot.isChecked() and self.run.gt_exist, "Progress": ori_images, "Text": "Creating plot for speed error", } self.run.run_dict["Speed_Plot_Video"] = { "Run": self.run.ui.c_speed_plot_video.isChecked(), "Progress": ori_images, "Text": "Creating speed plot video", } self.run.run_dict["Error_Plot_Video"] = { "Run": self.run.ui.c_error_plot_video.isChecked() and self.run.gt_exist, "Progress": ori_images, "Text": "Creating error plot video", } self.run.run_dict["Crash_Plot_Video"] = { "Run": self.run.ui.c_crash_plot_video.isChecked(), "Progress": ori_images, "Text": "Creating time to crash plot video", } self.run.run_dict["Super_Pixel_Video"] = { "Run": self.run.ui.combo_superpixel.currentIndex() != 0 and self.run.ui.c_super_pixel_video.isChecked(), "Progress": ori_images, "Text": "Creating super pixel video", } self.run.run_dict["Super_Pixel_Label"] = { "Run": self.run.create_super_pixel_label, "Progress": ori_images, "Text": "Creating {0} superpixel labels".format( self.run.super_pixel_method ), } self.run.run_dict["Object_Detection"] = { "Run": ( self.run.ui.c_object_detection.isChecked() or self.run.ui.c_crash_plot.isChecked() ) and not self.run.object_detection_dir_exist, "Progress": ori_images, "Text": "Running Object Detection", } self.run.addAllProgressBar() self.run.buildParamsDict() runner = calcRunner.CalculationRunner(self.run.params_dict) runner.startThread()
def startObjectDetection(self): """Starts object detection """ # Load Yolo logging.info("Starting Object Detection") # cur = os.path.dirname(os.path.realpath(__file__)) net = cv2.dnn.readNet(self.yolo_weights, self.yolo_v) classes = [] with open(self.coco_names, "r") as f: classes = [line.strip() for line in f.readlines()] layer_names = net.getLayerNames() output_layers = [ layer_names[i[0] - 1] for i in net.getUnconnectedOutLayers() ] colors = np.random.uniform(0, 255, size=(len(classes), 3)) # Loading image img_list = utils.listDirectory(self.img_dir) for ind in range(len(img_list)): logging.info("Running Object Detection on: {0}".format( img_list[ind])) img = cv2.imread(img_list[ind]) # img = cv2.resize(img, None, fx=0.4, fy=0.4) height, width, channels = img.shape # Detecting objects blob = cv2.dnn.blobFromImage(img, 0.00392, (416, 416), (0, 0, 0), True, crop=False) net.setInput(blob) outs = net.forward(output_layers) # Showing informations on the screen class_ids = [] confidences = [] boxes = [] for out in outs: for detection in out: scores = detection[5:] class_id = np.argmax(scores) confidence = scores[class_id] if confidence > 0.5: # Object detected center_x = int(detection[0] * width) center_y = int(detection[1] * height) w = int(detection[2] * width) h = int(detection[3] * height) # Rectangle coordinates x = int(center_x - w / 2) y = int(center_y - h / 2) boxes.append([x, y, w, h]) confidences.append(float(confidence)) class_ids.append(class_id) indexes = cv2.dnn.NMSBoxes(boxes, confidences, 0.5, 0.4) font = cv2.FONT_HERSHEY_PLAIN for i in range(len(boxes)): if i in indexes: x, y, w, h = boxes[i] label = str(classes[class_ids[i]]) color = colors[i] cv2.rectangle(img, (x, y), (x + w, y + h), color, 2) cv2.putText(img, label, (x, y + 30), font, 3, color, 3) cv2.imwrite( os.path.join(self.object_detection_dir, "{0}.png".format(ind)), img) np.save( os.path.join(self.object_detection_dir, "{0}.npy".format(ind)), np.asarray(boxes), ) self.update.emit(ind) cv2.destroyAllWindows()
def errorChecks(self): """Check for errors and inform the user in a QMessageBox if found any Returns: bool -- if true then the execution stops """ stop_calculation = False found_error = False errors = {"Info": [], "Critical": []} error_types = [] ori_images = 0 of_images = 0 depth_images = 0 back_of_images = 0 if os.path.exists(self.savePathJoin("Images")): ori_images = len( listDirectory(self.savePathJoin("Images"), extension="png")) # Check image folder if self.img_exist and not os.path.exists(self.savePathJoin("Images")): if os.path.exists(self.user["Video"]): errors["Info"].append( "Images folder {0} doesn't exist -> Recreate it and recalculate optical flow and depth estimations" .format(self.savePathJoin("Images"))) error_types.append("NoImages") else: stop_calculation = True errors["Critical"].append(( "Images folder {0} and video file {1} don't exist -> Stopping run" .format(self.savePathJoin("Images"), self.user["Video"]))) elif self.img_exist and os.path.exists(self.user["Video"]): errors["Info"].append( "Both the video {0} and Images folder {1} exist -> using Images folder by default" .format(self.user["Video"], self.savePathJoin("Images"))) elif not self.img_exist and not os.path.isfile(self.user["Video"]): stop_calculation = True errors["Critical"].append(( "Images folder {0} and video file {1} don't exist -> Stopping run" .format(self.savePathJoin("Images"), self.user["Video"]))) # Check video file if self.user["Video"] != "" and not os.path.isfile(self.user["Video"]): if os.path.exists(self.savePathJoin("Images")): errors["Info"].append(( "Video file {0} doesn't exist -> Using images in the Images folder instead" .format(self.user["Video"]))) else: stop_calculation = True errors["Critical"].append(( "Images folder {0} and video file {1} don't exist -> Stopping run" .format(self.savePathJoin("Images"), self.user["Video"]))) elif os.path.isfile(self.user["Video"]) and os.path.exists( self.savePathJoin("Images")): pass # Check optical flow if self.of_exist and not os.path.exists(self.savePathJoin("Of")): errors["Info"].append(( "Optical flow folder {0} doesn't exist -> Recalculating optical flow" .format(self.savePathJoin("Of")))) error_types.append("NoOf") elif self.of_exist: of_images = len( listDirectory(self.savePathJoin("Of"), extension="png")) if of_images != ori_images - 1 and ori_images != 0: errors["Info"].append(( "Optical flow image number {0} doesn't match video image number {1} - 1 -> Recalculating optical flow" .format(of_images, ori_images))) error_types.append("NoOf") # Check backward optical flow if self.back_of_exist and not os.path.exists( self.savePathJoin("Back_Of")): errors["Info"].append(( "Backward optical flow folder {0} doesn't exist -> Recalculating backward optical flow" .format(self.savePathJoin("Back_Of")))) error_types.append("NoOf") elif self.back_of_exist: back_of_images = len( listDirectory(self.savePathJoin("Back_Of"), extension="png")) if back_of_images != of_images: errors["Info"].append(( "Backward optical flow image number {0} doesn't match optical flow image number {1} -> Recalculating backward optical flow" .format(back_of_images, of_images))) error_types.append("NoOf") # Check depth estimation if self.depth_exist and not os.path.exists(self.savePathJoin("Depth")): errors["Info"].append(( "Depth folder {0} doesn't exist -> Recalculating depth".format( self.savePathJoin("Depth")))) error_types.append("NoDepth") elif self.depth_exist: depth_images = len( listDirectory(self.savePathJoin("Depth"), extension="png")) if depth_images != ori_images and ori_images != 0: errors["Info"].append(( "Depth image number {0} doesn't match video image number {1} -> Recalculating depth" .format(depth_images, ori_images))) error_types.append("NoDepth") # Check ground truth if self.gt_exist and not os.path.isfile(self.user["GT"]): errors["Info"].append( ("Ground Truth file {0} doesn't exist -> File won't be used". format(self.user["GT"]))) error_types.append("NoGT") # Check super pixel labels if (self.super_pixel_method != "" and os.path.exists( os.path.join(self.savePathJoin("Super_Pixel"), self.super_pixel_method)) and ori_images != 0 and len( listDirectory( os.path.join(self.savePathJoin("Super_Pixel"), self.super_pixel_method), extension=".npy", )) != ori_images): errors["Info"].append(( "Super pixel label number {0} doesn't match image number {1} -> Recalculating super pixel labels" .format( len( listDirectory( os.path.join( self.savePathJoin("Super_Pixel"), self.super_pixel_method, ), extension=".npy", )), ori_images, ))) error_types.append("LabelError") # Check object detection if self.ui.c_object_detection.isChecked() and os.path.exists( self.savePathJoin("ObjectDetection")): if (len( listDirectory(self.savePathJoin("ObjectDetection"), extension=".png")) != ori_images): errors["Info"].append( "Object Detection image number {0} doesn't match image number of video {1} -> Recalculating object detection" .format( len( listDirectory(self.savePathJoin("ObjectDetection"), extension=".png")), ori_images, )) error_types.append("ObDetError") elif (len( listDirectory(self.savePathJoin("ObjectDetection"), extension=".npy")) != ori_images): errors["Info"].append( "Object Detection numpy array number {0} doesn't match image number of video {1} -> Recalculating object detection" .format( len( listDirectory(self.savePathJoin("ObjectDetection"), extension=".npy")), ori_images, )) error_types.append("ObDetError") answer = "" if len(errors["Info"]) > 0 and len(errors["Critical"]) == 0: msg = QMessageBox() msg.setIcon(QMessageBox.Information) msg.setText( "Some calculations might not run the way you expect them.\nIn show details check the right side of the arrows to see what will happen." ) msg.setWindowTitle("Information") all_info = "" for info in errors["Info"]: all_info += info + "\n\n" msg.setDetailedText(all_info) msg.setStandardButtons(QMessageBox.Ok | QMessageBox.Abort) answer = msg.exec_() elif len(errors["Critical"]) > 0: msg = QMessageBox() msg.setIcon(QMessageBox.Critical) msg.setText( "Found critical error\nCouldn't start run, see show details for more information" ) msg.setWindowTitle("Critical Error") all_info = "" for info in errors["Critical"]: all_info += info + "\n" msg.setDetailedText(all_info) msg.setStandardButtons(QMessageBox.Abort) answer = msg.exec_() if answer != int("0x00040000", 16): for ty in error_types: logging.info("Solve error: {0}".format(ty)) if ty == "NoImage": self.img_exist = False self.of_exist = False self.back_of_exist = False self.depth_exist = False elif ty == "NoOf": self.of_exist = False self.back_of_exist = False elif ty == "NoDepth": self.depth_exist = False elif ty == "NoGT": self.gt_exist = False self.user["GT"] = "" elif ty == "LabelError": self.create_super_pixel_label = True shutil.rmtree( os.path.join(self.savePathJoin("Super_Pixel"), self.super_pixel_method)) elif ty == "ObDetError": self.object_detection_dir_exist = False shutil.rmtree(self.savePathJoin("ObjectDetection")) return answer == int("0x00040000", 16) or stop_calculation