MCPcopy Create free account
hub / github.com/CiaraStrawberry/TemporalKit / interpolate_frames

Function interpolate_frames

scripts/Berry_Method.py:537–546  ·  view source on GitHub ↗
(frame1, frame2, alpha)

Source from the content-addressed store, hash-verified

535
536
537def interpolate_frames(frame1, frame2, alpha):
538 gray1 = cv2.cvtColor(frame1, cv2.COLOR_BGR2GRAY)
539 gray2 = cv2.cvtColor(frame2, cv2.COLOR_BGR2GRAY)
540
541 flow = cv2.calcOpticalFlowFarneback(gray1, gray2, None, pyr_scale=0.5, levels=3, winsize=15, iterations=3, poly_n=5, poly_sigma=1.2, flags=0)
542 h, w = flow.shape[:2]
543
544 flow_map = -alpha * flow + np.indices((h, w)).transpose(1, 2, 0)
545 flow_map = flow_map.astype(np.float32) # Convert flow_map to float32 data type
546 return cv2.remap(frame1, flow_map, None, cv2.INTER_LINEAR)
547
548def interpolate_video(input_path, output_path, output_fps):
549 clip = VideoFileClip(input_path)

Callers 1

interpolate_videoFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected