gait-analysis-backend / save_results.py
techSnipe's picture
Upload folder using huggingface_hub
83ee618 verified
from gait_analysis import EnhancedGaitAnalyzer
import os
import json
def main():
# Path to test.mp4
video_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "test.mp4"))
print(f"Looking for video at: {video_path}")
if not os.path.exists(video_path):
print("Error: test.mp4 not found!")
return
print("Initializing EnhancedGaitAnalyzer...")
analyzer = EnhancedGaitAnalyzer()
print("Processing video... this might take a moment.")
try:
results = analyzer.process_video(video_path)
# Save to JSON file
output_file = os.path.join(os.path.dirname(video_path), "analysis_results.json")
with open(output_file, 'w') as f:
json.dump(results, f, indent=2, default=str)
print(f"\n✅ Results saved to: {output_file}")
# Print summary
summary = results.get("summary", {})
print("\n" + "="*60)
print("SUMMARY")
print("="*60)
print(json.dumps(summary, indent=2))
except Exception as e:
print(f"An error occurred during processing: {e}")
import traceback
traceback.print_exc()
if __name__ == "__main__":
main()