diff --git a/.gitignore b/.gitignore index 0979e5e..8e7e46b 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ backups/* input/* logs/* out/* -test_video/* \ No newline at end of file +test_video/* +capture_image/* \ No newline at end of file diff --git a/20211012_pillar_detection.pptx b/20211012_pillar_detection.pptx new file mode 100644 index 0000000..32e0a3b Binary files /dev/null and b/20211012_pillar_detection.pptx differ diff --git a/dockerfile b/dockerfile new file mode 100644 index 0000000..0e0aff5 --- /dev/null +++ b/dockerfile @@ -0,0 +1,25 @@ +# docker build -t pixtree/pillar_detection . +# docker run -it --name jhkim_pillar_detection --shm-size=60G -w /app -v /mnt/DataSet:/DataSet pixtree/pillar_detection:latest bash +# python pillar_detection.py -i /DataSet/Pixtree-NDA/SME/20220114_01주차/input/SMTOWN/ -c 0 + +FROM python:3.8.12-buster + +LABEL name="PillarDetection" +LABEL date="2022-01-11" + +RUN mkdir /app/ +WORKDIR /app/ + +COPY pillar_detection.py /app/ +COPY pillar_detection_core.py /app/ +COPY pillar_detection_utils.py /app/ +COPY requirements.txt /app/ + +RUN apt-get update -y \ + && apt-get upgrade -y \ + && apt-get dist-upgrade -y \ + && apt-get install -y \ + ffmpeg + +RUN pip install --upgrade pip \ + && pip install -r /app/requirements.txt \ No newline at end of file diff --git a/pillar_detection.py b/pillar_detection.py index f70a769..a3d04c7 100644 --- a/pillar_detection.py +++ b/pillar_detection.py @@ -5,16 +5,20 @@ parser = argparse.ArgumentParser() # file path options parser.add_argument("-i", "--input_dir", default="./input", help="Input source vid directory") parser.add_argument("-o", "--output_dir", default="./out", help="Output vid directory") +parser.add_argument("-l", "--logfile_dir", help="Log txt file directory") # ffmpeg encoding option -parser.add_argument("-c", "--crf", default=18, type=int, help="set crf level") -parser.add_argument("-fps", '-fr', "--frame_rate", default=-1, type=float, help="if minus value, same fps as input") +parser.add_argument("-c", "--crf", default=0, type=int, help="set crf level") # 0: SD, 18: HD +parser.add_argument("-ivtc", "--inverse_telecine", default='fm', help="add ffmpeg telecine option [fm, bw, fmbw, False]") + parser.add_argument("-uhd", "--uhd_output", default=False, action="store_true", help="set output resolution to 3840:2160") -parser.add_argument("-lb", "--add_letterbox", default=False, action="store_true", help="add letterbox to make 16:9 ratio") -parser.add_argument("-sp", "--add_sharpening", default=False, action="store_true", help="add ffmpeg sharpening filter") +parser.add_argument("-fps", '-fr', "--frame_rate", default=-1, type=float, help="if minus value, same fps as input") +parser.add_argument("-lb", "--letterbox", default=False, action="store_true", help="add letterbox to make 16:9 ratio") +parser.add_argument("-sp", "--sharpening", default=False, action="store_true", help="add ffmpeg sharpening filter") + # program option -parser.add_argument("-mul", "--multi_encoding", default=2, type=int, help="when log file exist, encoding mutiple videos by this args") +parser.add_argument("-mul", "--multi_encoding", default=1, type=int, help="when log file exist, encoding mutiple videos by this args") parser.add_argument("-d", "--debug", default=False, action="store_true", help="for debugging. (short length video output)") # logfile option @@ -28,12 +32,18 @@ args = parser.parse_args() # options when only edit log file that already exists (no encoding) : -log -edit def main(): - vid_types = ('*.avi', '*.mov', '*.mp4', '*.mxf') + vid_types = ('*.avi', '*.mov', '*.mp4', '*.mxf', '*.mkv') manual_mode = args.manual_mode edit_mode = args.edit_mode input_dir = args.input_dir output_dir = args.output_dir - logs_dir = input_dir + + ''' + TODO : + ivtc folder select + mkdir 위치 main / core 한 쪽으로 정렬 + ''' + temp_ivtc_dir = './tmp_fm_output' if args.cropsize_scale < 1 : print(f"[!!! ERROR !!!]\t Invalid scale option [scale : {args.cropsize_scale}]") @@ -41,22 +51,30 @@ def main(): elif args.multi_encoding < 1 : print(f"[!!! WARRNING !!!]\t \"multi_encoding\" option should be more then 0 [multi_encoding : {args.multi_encoding}]") return - + input_list = [] for types in vid_types : input_list += glob.glob(os.path.join(input_dir, types)) input_list = sorted(input_list) + + ''' + hard coding for specific file process (use "/" not "\") + ''' +# input_dir = "Y:/Pixtree-NDA/SME/20220121_02주차/Input/중화질" +# input_list = [ +# os.path.join(input_dir, "문희준 - Our Story (우리이야기).avi"), +# os.path.join(input_dir, "보아 - 늘... MV_고화질.avi"), +# ] + + if args.logfile_dir is not None : + logs_dir = args.logfile_dir + else : + logs_dir = input_dir + print("[INFO]\t Input dir :", input_dir) print("[INFO]\t Ouput dir :", output_dir) print("") - # for specific file process (use "/" not "\") - # input_dir = "Y:/Pixtree-NDA/SME/20211209_3차우선순위/output-20211222/source/" - # input_list = [ - # os.path.join(input_dir, "01. 샤이니_누난너무예뻐 MV_xfm_dec_ver3_edit.mov") - # ] - - crop_cfg = VideoCropCfg() for vid_index, fpath in enumerate(input_list): vid_name = os.path.basename(fpath)[:-4] vid_num = len(input_list) @@ -66,8 +84,9 @@ def main(): print("[INFO]\t Log dir :", logs_dir) # init crop configuration class - # crop_cfg = VideoCropCfg() + crop_cfg = VideoCropCfg() crop_cfg.vid_name = vid_name + crop_cfg.temp_ivtc_dir = temp_ivtc_dir # Read log file if exist if not manual_mode: @@ -87,10 +106,16 @@ def main(): cropPos = [crop_cfg.frame_width, crop_cfg.frame_height, 0, 0] cropPos = adjustCropArea(cropPos, crop_cfg.frame_width, crop_cfg.frame_height) + print(cropPos) cv2.namedWindow(f'{vid_name}', cv2.WINDOW_NORMAL | cv2.WINDOW_KEEPRATIO) # Display crop size control UI while True: + # retCode value mean + # 0 : keep playing + # 1 : done with cropping (to next vid) + # 2 : replay + # 3 : program exit retCode, cropPos = videoCropping(crop_cfg, cropPos) if retCode == 1: break @@ -107,12 +132,27 @@ def main(): if not crop_cfg.isSkipped: writeLog(logs_dir, log_path, cropPos) + + if args.inverse_telecine != False : + if not os.path.exists(temp_ivtc_dir): + os.mkdir(temp_ivtc_dir) # Set ffmpeg commands, actual ffmpeg encoding if not (args.only_logfile or crop_cfg.isSkipped): - retCode = ffmpegEncoding(args, vid_index, vid_num, cropPos, vid_name, fpath, crop_cfg.ffmpeg_process) + retCode = ffmpegEncoding(args, vid_index, vid_num, cropPos, vid_name, fpath, crop_cfg) if retCode < 0 : return retCode + + if args.inverse_telecine != False : + if os.path.exists(temp_ivtc_dir): + ivtc_file_list = os.listdir(temp_ivtc_dir) + for idx, files in enumerate(ivtc_file_list): + file_path = os.path.join(temp_ivtc_dir, files) + if not os.path.isdir(file_path): + print(f"[INFO]\t Delete temporary ivtc file : {file_path}") + os.remove(file_path) + print(f"[INFO]\t Delete temporary ivtc folder : {temp_ivtc_dir}") + os.rmdir(temp_ivtc_dir) if __name__ == "__main__": main() diff --git a/pillar_detection_core.py b/pillar_detection_core.py index ef0c87b..c8144a3 100644 --- a/pillar_detection_core.py +++ b/pillar_detection_core.py @@ -20,6 +20,8 @@ class VideoCropCfg(): self.frame_height = 0 self.fps = 0 + self.temp_ivtc_dir = '' + def getVidInfo(self, fpath): self.captured_vid = cv2.VideoCapture(fpath) self.frame_width = int(self.captured_vid.get(cv2.CAP_PROP_FRAME_WIDTH)) @@ -42,7 +44,7 @@ def videoCropping(crop_cfg, cropPos): # search_distance unit : second search_distance = 5 # play_speed unit : millisecond - play_speed = 10 + play_speed = 18 key = cv2.waitKeyEx(play_speed) # Close button(X button) event @@ -134,14 +136,14 @@ def videoCropping(crop_cfg, cropPos): # deep copy current frame, use that frame for draw rectangle. crop_cfg.boxedFrame = copy.deepcopy(crop_cfg.cleanFrame) cv2.rectangle(crop_cfg.boxedFrame, (cropPos[2], cropPos[3]), (cropPos[2] + cropPos[0], - cropPos[3] + cropPos[1]), (0, 0, 255), thickness=2, lineType=cv2.LINE_8) + cropPos[3] + cropPos[1]), (0, 0, 255), thickness=1, lineType=cv2.LINE_8) cv2.imshow(f'{crop_cfg.vid_name}', crop_cfg.boxedFrame) else : _, crop_cfg.frame = crop_cfg.captured_vid.read() # deep copy current frame for clean preview. crop_cfg.cleanFrame = copy.deepcopy(crop_cfg.frame) cv2.rectangle(crop_cfg.frame, (cropPos[2], cropPos[3]), (cropPos[2] + cropPos[0], - cropPos[3] + cropPos[1]), (0, 0, 255), thickness=2, lineType=cv2.LINE_8) + cropPos[3] + cropPos[1]), (0, 0, 255), thickness=1, lineType=cv2.LINE_8) cv2.imshow(f'{crop_cfg.vid_name}', crop_cfg.frame) crop_cfg.boxedFrame = copy.deepcopy(crop_cfg.frame) @@ -151,18 +153,21 @@ def videoCropping(crop_cfg, cropPos): return retCode, cropPos -def ffmpegEncoding(args, vid_index, vid_num, cropPos, vid_name, fpath, ffmpeg_process): +def ffmpegEncoding(args, vid_index, vid_num, cropPos, vid_name, fpath, crop_cfg): retCode = -1 + output_dir = args.output_dir + temp_ivtc_dir = crop_cfg.temp_ivtc_dir + uhd_output = args.uhd_output debug = args.debug - add_letterbox = args.add_letterbox - output_dir = args.output_dir - add_sharpening = args.add_sharpening + letterbox = args.letterbox + sharpening = args.sharpening manual_mode = args.manual_mode - crf = args.crf fps = args.frame_rate + ffmpeg_process = crop_cfg.ffmpeg_process + output_name_args = [] debug_shortOutput = "" @@ -188,7 +193,7 @@ def ffmpegEncoding(args, vid_index, vid_num, cropPos, vid_name, fpath, ffmpeg_pr pad_arg syntax: pad= {width after padding}:{height after padding}:{x offset of pad}:{y offset of pad} """ - if add_letterbox : + if letterbox : output_name_args.append("lb") # Always target 16:9 display ratio target_ratio = 16 / 9 @@ -200,7 +205,7 @@ def ffmpegEncoding(args, vid_index, vid_num, cropPos, vid_name, fpath, ffmpeg_pr tmp_height = int(tmp_height) if (tmp_height % 4) != 0: tmp_height -= (tmp_height % 4) - pad_arg = f",pad={cropPos[0]}:{tmp_height}:(ow-iw)/2:(ih-oh)/2" + pad_arg = f",pad={cropPos[0]}:{tmp_height}:(ow-iw)/2:(oh-ih)/2" scale_arg = f",scale=w={cropPos[0]}:h={tmp_height}" output_width, output_height = cropPos[0], tmp_height else: @@ -209,7 +214,7 @@ def ffmpegEncoding(args, vid_index, vid_num, cropPos, vid_name, fpath, ffmpeg_pr tmp_width = int(tmp_width) if (tmp_width % 4) != 0: tmp_width -= (tmp_width % 4) - pad_arg = f",pad={tmp_width}:{cropPos[1]}:(ow-iw)/2:(ih-oh)/2" + pad_arg = f",pad={tmp_width}:{cropPos[1]}:(ow-iw)/2:(oh-ih)/2" scale_arg = f",scale=w={tmp_width}:h={cropPos[1]}" output_width, output_height = tmp_width, cropPos[1] @@ -218,21 +223,31 @@ def ffmpegEncoding(args, vid_index, vid_num, cropPos, vid_name, fpath, ffmpeg_pr # print(f'[INFO]\t folder created : {output_dir}') ## ffmpeg command setting - if add_sharpening : - sharpen_arg = ',unsharp=7:7:1.5:7:7:1.5' - output_name_args.append("sharp") - else : - sharpen_arg = '' - fps_arg = "" + sharpen_arg = "" + crf = args.crf + if crf >= 0 : + output_name_args.append(f"crf{crf}") + elif crf < 0 : + print(f"[!!! ERROR !!!] invalid option. fps = {crf}") + crf = 0 if fps > 0 : output_name_args.append(f"fps{fps}") fps_arg = f"-r {fps}" elif fps == 0 : print(f"[!!! ERROR !!!] invalid option. fps = {fps}") + if args.uhd_output : + output_name_args.append(f"uhd") + if args.letterbox : + output_name_args.append(f"lb") + if sharpening : + sharpen_arg = ',unsharp=7:7:1.5:7:7:1.5' + output_name_args.append("sharp") + if args.inverse_telecine != False: + output_name_args.append(args.inverse_telecine) if len(output_name_args) > 0 : - output_file_name= f"{vid_name}_box({','.join(output_name_args)}).mov" + output_file_name= f"{vid_name}_box({'_'.join(output_name_args)}).mov" else: output_file_name= f"{vid_name}_box.mov" output_path = os.path.join(output_dir, output_file_name) @@ -248,17 +263,36 @@ def ffmpegEncoding(args, vid_index, vid_num, cropPos, vid_name, fpath, ffmpeg_pr info : defualt ''' loglevel = 'quiet' - ffmpeg_command = f"ffmpeg {debug_shortOutput} -i \"{fpath}\" {fps_arg} -vf \"{crop_arg}{scale_arg}{pad_arg}{sharpen_arg}\"\ - -y -pix_fmt yuv420p -c:v libx264 -crf {crf} -c:a copy -preset medium -loglevel {loglevel}\ - {uhd_output_args} \"{output_path}\"" + if args.inverse_telecine != False : + temp_ivtc_path = f"\"{temp_ivtc_dir}/{vid_name}_crf0_fm.mov\"" + + if args.inverse_telecine == 'fmbw': + ffmpeg_ivtc_command = f"ffmpeg -y -i \"{fpath}\" -vf fieldmatch=mode=pc_n:combmatch=full,bwdif=0:-1:1 -c:v libx264 -crf 0 -preset ultrafast \ + -stats -loglevel {loglevel} {temp_ivtc_path}" + elif args.inverse_telecine == 'bw': + ffmpeg_ivtc_command = f"ffmpeg -y -i \"{fpath}\" -vf bwdif=0:-1:1 -c:v libx264 -crf 0 -preset ultrafast \ + -stats -loglevel {loglevel} {temp_ivtc_path}" + else: + ffmpeg_ivtc_command = f"ffmpeg -y -i \"{fpath}\" -vf fieldmatch=mode=pc_n:combmatch=full -c:v libx264 -crf 0 -preset ultrafast \ + -stats -loglevel {loglevel} {temp_ivtc_path}" + + ffmpeg_command = f"ffmpeg {debug_shortOutput} -i {temp_ivtc_path} {fps_arg} -vf \"{crop_arg}{scale_arg}{pad_arg}{sharpen_arg}\"\ + -y -pix_fmt yuv420p -c:v libx264 -crf {crf} -c:a copy -preset medium -loglevel {loglevel} -stats\ + {uhd_output_args} \"{output_path}\"" + else : + ffmpeg_command = f"ffmpeg {debug_shortOutput} -i \"{fpath}\" {fps_arg} -vf \"{crop_arg}{scale_arg}{pad_arg}{sharpen_arg}\"\ + -y -pix_fmt yuv420p -c:v libx264 -crf {crf} -c:a copy -preset medium -loglevel {loglevel} \ + {uhd_output_args} \"{output_path}\"" + vid_duration = getVideDuration(fpath) vid_hour = vid_duration[0] vid_min = vid_duration[1] vid_sec = vid_duration[2] print(ffmpeg_command) - # print("====================================================================") - print("[INFO]\t Encoding start \"%s\" ..." % vid_name) + print("====================================================================") + print("[INFO]\t Encoding Arguments") + print("[INFO]\t Input File : \"%s\"" % os.path.split(fpath)[1]) print("[INFO]\t CRF : %d" % int(crf)) print("[INFO]\t Video Duration : %02d:%02d:%02d" % (vid_hour, vid_min, vid_sec)) print("[INFO]\t Pixel format : YUV420p") @@ -266,54 +300,86 @@ def ffmpegEncoding(args, vid_index, vid_num, cropPos, vid_name, fpath, ffmpeg_pr print("[INFO]\t Ffmpeg Preset : medium") print(f"[INFO]\t Cropping Info : [W : {cropPos[0]} H : {cropPos[1]} X : {cropPos[2]} Y : {cropPos[3]}]") print("[INFO]\t Crop area ratio : %.5f" %current_crop_ratio) - if add_letterbox : + if letterbox : print("[INFO]\t Target ratio : %.5f" %target_ratio) if uhd_output : print("[INFO]\t Output Resolution : 3840x2160") else: print("[INFO]\t Output Resolution : %dx%d" %(output_width, output_height)) - if add_sharpening : + if sharpening : print("[INFO]\t Sharpening arg : %s" %sharpen_arg[1:]) if fps > 0 : print("[INFO]\t Frame Rate : %.2f" %fps) + print("[INFO]\t Field Match apply : %s" %args.inverse_telecine) print("[INFO]\t Output File Name : %s" %output_file_name) print("====================================================================") - - # st_time = time.time() vid_index += 1 start_time = getTime() - - ''' - TODO : count running ffmpeg process asynch. - ''' - running_process = 0 if manual_mode: # Manual Mode (always cropping one by one) # Hold process when encoding last video if vid_index == vid_num : print(f"[INFO]\t Video Duration : {vid_hour:02d}:{vid_min:02d}:{vid_sec:02d}\ Start Time : {getTime('string')}") - ffmpeg_process.append(subprocess.Popen(ffmpeg_command + ' -stats', shell=False).wait()) + ffmpeg_process.append(subprocess.Popen(ffmpeg_command, shell=False).wait()) else : ffmpeg_process.append(subprocess.Popen(ffmpeg_command, shell=False)) else: # Log file mode (encoding simultaneously n videos) if args.multi_encoding == 0: - subprocess.Popen(ffmpeg_command + ' -stats', shell=False).wait() + if args.inverse_telecine != False: + subprocess.Popen(ffmpeg_ivtc_command, shell=False).wait() + subprocess.Popen(ffmpeg_command, shell=False).wait() + + else : + subprocess.Popen(ffmpeg_command, shell=False).wait() elif (vid_index % args.multi_encoding == 0) or (vid_index == vid_num): print(f"[INFO]\t Video Duration : {vid_hour:02d}:{vid_min:02d}:{vid_sec:02d}\ Start Time : {getTime('string')}") - p = subprocess.Popen(ffmpeg_command + ' -stats', shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='utf-8') - ffmpeg_process.append(p.pid) - # print(ffmpeg_process) - while p.poll() is None: - displayRemainTime(vid_duration, p.stderr, start_time) + + if args.inverse_telecine != False: + p = subprocess.Popen(ffmpeg_ivtc_command, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='utf-8') + print(f"[INFO]\t Step 1. Field match...\t(File Path : {temp_ivtc_path})", end="\n") + while p.poll() is None: + displayRemainTime(vid_duration, p.stderr, start_time) + print("",end="\n") + + p = subprocess.Popen(ffmpeg_command, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='utf-8') + print(f"[INFO]\t Step 2. Cropping...", end="\n") + while p.poll() is None: + displayRemainTime(vid_duration, p.stderr, start_time) + print("\n") + else : + # p = subprocess.Popen(ffmpeg_command, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='utf-8') + # ffmpeg_process.append(p.pid) + # while p.poll() is None: + # displayRemainTime(vid_duration, p.stderr, start_time) + # print("\n") + + subprocess.Popen(ffmpeg_command, shell=False).wait() + else : - p = subprocess.Popen(ffmpeg_command, shell=False) - ffmpeg_process.append(p.pid) - running_process += 1 + if args.inverse_telecine != False: + print(f"[INFO]\t Video Duration : {vid_hour:02d}:{vid_min:02d}:{vid_sec:02d}\ + Start Time : {getTime('string')}") + p = subprocess.Popen(ffmpeg_ivtc_command, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='utf-8') + print(f"[INFO]\t Step 1. Field match...\t(File Path : {temp_ivtc_path})", end="\n") + while p.poll() is None: + displayRemainTime(vid_duration, p.stderr, start_time) + print("",end="\n") + + p = subprocess.Popen(ffmpeg_command, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='utf-8') + print(f"[INFO]\t Step 2. Cropping...", end="\n") + while p.poll() is None: + displayRemainTime(vid_duration, p.stderr, start_time) + print("\n") + else : + # p = subprocess.Popen(ffmpeg_command, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='utf-8') + subprocess.Popen(ffmpeg_command, shell=False) + + # ffmpeg_process.append(p.pid) retCode = 0 @@ -325,18 +391,18 @@ def ffmpegEncoding(args, vid_index, vid_num, cropPos, vid_name, fpath, ffmpeg_pr # if vid_index == vid_num : # print(f"[INFO]\t Video Duration : {vid_hour:02d}:{vid_min:02d}:{vid_sec:02d}\ # Start Time : {getTime('string')}") - # ffmpeg_process.append(subprocess.Popen(ffmpeg_command + ' -stats', shell=False).wait()) + # ffmpeg_process.append(subprocess.Popen(ffmpeg_command, shell=False).wait()) # else : # ffmpeg_process.append(subprocess.Popen(ffmpeg_command, shell=False)) # else: # # Log file mode (encoding simultaneously n videos) # if args.multi_encoding == 0: - # subprocess.Popen(ffmpeg_command + ' -stats', shell=False).wait() + # subprocess.Popen(ffmpeg_command, shell=False).wait() # elif (vid_index % args.multi_encoding == 0) or (vid_index == vid_num): # print(f"[INFO]\t Video Duration : {vid_hour:02d}:{vid_min:02d}:{vid_sec:02d}\ # Start Time : {getTime('string')}") - # p = subprocess.Popen(ffmpeg_command + ' -stats', shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='utf-8') + # p = subprocess.Popen(ffmpeg_command, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='utf-8') # ffmpeg_process.append(p.pid) # while p.poll() is None: # displayRemainTime(vid_duration, p.stderr, start_time) diff --git a/pillar_detection_utils.py b/pillar_detection_utils.py index 9acdc5e..13e5e50 100644 --- a/pillar_detection_utils.py +++ b/pillar_detection_utils.py @@ -55,7 +55,7 @@ def displayRemainTime(vid_duration, ffmpeg_stream, start_time): eta = (100 - current_percentage) / encoding_speed eta_time = datetime.datetime.now() + datetime.timedelta(seconds=eta) eta_time = eta_time.strftime('[ETA : %Y-%m-%d %H:%M:%S]') - print(f"[INFO]\t now encoding ... {eta_time} [{current_percentage:.2f}%] [Speed : {encoding_speed:.2f} %/s]", end='\r') + print(f"[INFO]\t now processing ... {eta_time} [{current_percentage:.2f}%] [Speed : {encoding_speed:.2f} %/s]", end='\r') def resizeCropInfo(key, cropPos, frame_width, frame_height): @@ -151,10 +151,24 @@ def parseLog(log_path, edit_mode, manual_mode, scale): cropPos = [] if not os.path.exists(log_path): - print(f"[INFO]\t Can`t find log file. [{log_path}]") - manual_mode = True - edit_mode = False - else : + if log_path.find('_avs') > 0 : + avs_log_path = log_path.split(sep='_avs') + avs_log_path = avs_log_path[0] + avs_log_path[1] + if os.path.exists(avs_log_path): + print(f"[INFO]\t Using log file for avs input. \ + [{os.path.basename(log_path)} => {os.path.basename(avs_log_path)}]") + log_path = avs_log_path + else : + print(f"[INFO]\t Can`t find log file for avs input. [{avs_log_path}]") + manual_mode = True + edit_mode = False + else : + print(f"[INFO]\t Can`t find log file. [{log_path}]") + manual_mode = True + edit_mode = False + + + if not manual_mode : print(f"[INFO]\t Loading log file... [{log_path}]") try : f = open(log_path, "r")