diff --git a/vr180_matting/vr180_processor.py b/vr180_matting/vr180_processor.py index 8051996..72d7cd7 100644 --- a/vr180_matting/vr180_processor.py +++ b/vr180_matting/vr180_processor.py @@ -183,10 +183,28 @@ class VR180Processor(VideoProcessor): if writer is None: raise RuntimeError("Failed to open video writer with any codec") - for frame in eye_frames: + # Debug frame properties + first_frame = eye_frames[0] + print(f"Frame properties: shape={first_frame.shape}, dtype={first_frame.dtype}, " + f"min={first_frame.min()}, max={first_frame.max()}") + + for i, frame in enumerate(eye_frames): + # Ensure frame is in the right format for OpenCV + if frame.dtype != np.uint8: + frame = frame.astype(np.uint8) + + # Ensure frame is contiguous + if not frame.flags['C_CONTIGUOUS']: + frame = np.ascontiguousarray(frame) + success = writer.write(frame) if not success: - raise RuntimeError(f"Failed to write frame to {temp_video_path}") + print(f"Failed to write frame {i}/{len(eye_frames)}") + print(f"Frame {i} properties: shape={frame.shape}, dtype={frame.dtype}, contiguous={frame.flags['C_CONTIGUOUS']}") + raise RuntimeError(f"Failed to write frame {i} to {temp_video_path}") + + if i % 50 == 0: + print(f"Written {i}/{len(eye_frames)} frames") writer.release() del writer # Ensure it's fully released