ZiyuG commited on
Commit
1042c39
1 Parent(s): 33f5e20

Update align.py

Browse files
Files changed (1) hide show
  1. align.py +6 -6
align.py CHANGED
@@ -126,7 +126,7 @@ def create_aligned_videos(seq1_frames, seq2_frames, alignment_path, output_combi
126
  fourcc = cv2.VideoWriter_fourcc(*'H264')
127
 
128
  # 创建并排视频
129
- combined_out = cv2.VideoWriter(output_combined_path, fourcc, fps, (unified_width * 2, unified_height))
130
  # 创建单独的视频
131
  seq1_out = cv2.VideoWriter(output_seq1_path, fourcc, fps, (unified_width, unified_height))
132
  seq2_out = cv2.VideoWriter(output_seq2_path, fourcc, fps, (unified_width, unified_height))
@@ -148,17 +148,17 @@ def create_aligned_videos(seq1_frames, seq2_frames, alignment_path, output_combi
148
  combined_frame = np.hstack((frame1_resized, frame2_resized))
149
 
150
  # 写入到输出视频
151
- combined_out.write(combined_frame)
152
  seq1_out.write(frame1_resized)
153
  seq2_out.write(frame2_resized)
154
 
155
  # 释放资源
156
- combined_out.release()
157
  seq1_out.release()
158
  seq2_out.release()
159
 
160
 
161
- def align_filter(standard, user):
162
  # 示例数据
163
  sequence1 = json.load(open(standard + ".json", 'r'))
164
  sequence2 = json.load(open(user + ".json", 'r'))
@@ -181,7 +181,7 @@ def align_filter(standard, user):
181
  seq2_frames = read_video_frames(user + '.mp4') # Sequence 2: 34 frames
182
 
183
  # 输出视频路径
184
- output_combined_path = 'tmp/aligned_combined_output.mp4' # 合并视频
185
  output_seq1_path = standard + '.mp4' # 对齐后sequence1视频
186
  output_seq2_path = user + '.mp4' # 对齐后sequence2视频
187
 
@@ -195,6 +195,6 @@ def align_filter(standard, user):
195
  # 创建对齐后的视频
196
  create_aligned_videos(seq1_frames, seq2_frames, alignment_path, output_combined_path, output_seq1_path, output_seq2_path)
197
 
198
- print(f"Combined video created at {output_combined_path}")
199
  print(f"Aligned Sequence 1 video created at {output_seq1_path}")
200
  print(f"Aligned Sequence 2 video created at {output_seq2_path}")
 
126
  fourcc = cv2.VideoWriter_fourcc(*'H264')
127
 
128
  # 创建并排视频
129
+ # combined_out = cv2.VideoWriter(output_combined_path, fourcc, fps, (unified_width * 2, unified_height))
130
  # 创建单独的视频
131
  seq1_out = cv2.VideoWriter(output_seq1_path, fourcc, fps, (unified_width, unified_height))
132
  seq2_out = cv2.VideoWriter(output_seq2_path, fourcc, fps, (unified_width, unified_height))
 
148
  combined_frame = np.hstack((frame1_resized, frame2_resized))
149
 
150
  # 写入到输出视频
151
+ # combined_out.write(combined_frame)
152
  seq1_out.write(frame1_resized)
153
  seq2_out.write(frame2_resized)
154
 
155
  # 释放资源
156
+ # combined_out.release()
157
  seq1_out.release()
158
  seq2_out.release()
159
 
160
 
161
+ def align_filter(standard, user, tmpdir):
162
  # 示例数据
163
  sequence1 = json.load(open(standard + ".json", 'r'))
164
  sequence2 = json.load(open(user + ".json", 'r'))
 
181
  seq2_frames = read_video_frames(user + '.mp4') # Sequence 2: 34 frames
182
 
183
  # 输出视频路径
184
+ output_combined_path = tmpdir + '/aligned_combined_output.mp4' # 合并视频
185
  output_seq1_path = standard + '.mp4' # 对齐后sequence1视频
186
  output_seq2_path = user + '.mp4' # 对齐后sequence2视频
187
 
 
195
  # 创建对齐后的视频
196
  create_aligned_videos(seq1_frames, seq2_frames, alignment_path, output_combined_path, output_seq1_path, output_seq2_path)
197
 
198
+ # print(f"Combined video created at {output_combined_path}")
199
  print(f"Aligned Sequence 1 video created at {output_seq1_path}")
200
  print(f"Aligned Sequence 2 video created at {output_seq2_path}")