(frames_path, keyframes_path)
| 149 | |
| 150 | |
| 151 | def detect_frames(frames_path, keyframes_path): |
| 152 | if not os.path.exists(frames_path) and not os.path.exists(keyframes_path): |
| 153 | return "Please input the directory of guide video and rendered frames" |
| 154 | elif not os.path.exists(frames_path): |
| 155 | return "Please input the directory of guide video" |
| 156 | elif not os.path.exists(keyframes_path): |
| 157 | return "Please input the directory of rendered frames" |
| 158 | frames = [os.path.split(i)[-1] for i in search_for_images(frames_path)] |
| 159 | keyframes = [os.path.split(i)[-1] for i in search_for_images(keyframes_path)] |
| 160 | if len(frames)==0: |
| 161 | return f"No images detected in {frames_path}" |
| 162 | if len(keyframes)==0: |
| 163 | return f"No images detected in {keyframes_path}" |
| 164 | matched_keyframes = KeyFrameMatcher().match_filenames(frames, keyframes) |
| 165 | max_filename_length = max([len(i) for i in frames]) |
| 166 | if sum([i is not None for i in matched_keyframes])==0: |
| 167 | message = "" |
| 168 | for frame, matched_keyframe in zip(frames, matched_keyframes): |
| 169 | message += frame + " " * (max_filename_length - len(frame) + 1) |
| 170 | message += "--> No matched keyframes\n" |
| 171 | else: |
| 172 | message = "" |
| 173 | for frame, matched_keyframe in zip(frames, matched_keyframes): |
| 174 | message += frame + " " * (max_filename_length - len(frame) + 1) |
| 175 | if matched_keyframe is None: |
| 176 | message += "--> [to be rendered]\n" |
| 177 | else: |
| 178 | message += f"--> {matched_keyframe}\n" |
| 179 | return message |
| 180 | |
| 181 | |
| 182 | def check_input_for_interpolating(frames_path, keyframes_path): |
nothing calls this directly
no test coverage detected