Skip to content

Phototiming of athletics finish by stitching middle vertical pixels of each frame into an image

License

Notifications You must be signed in to change notification settings

djaus2/PhotoTimingDjaus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PhotoTimingDjaus ... AthStitcher App

License: CC0-1.0 Issues [GitHub stars

About

AthStitcher is a simple Photo Timing/Photo Finish app for Athletics etc where a finish line is filmed with say, a phone, and a stitched image is created by taking the middle vertical line of pixels from each video frame and stiching together the phototiming image. Previously had a similar app that used AForge. Note that video FramesPerSecond are typically 30 so each line represents 0.033 of second and hence this is the resolution of any timing. Commercial equipment would be to thousandths or tens of thousandths of a second. Can now set to 60 Fps if phone supports that.
There is a Maui app, djaus2/AthsVideoRecording, that handles the recording of the finish line video along with relevant meta-data. It handles sending of that video over TCP, which AthStitcher is able to receive.
A DBMS has been added using Entity Framework Core to record Meets, Events, Heats and Lane Results, and export results as a PDF.

  • A Competition Series has Rounds of Meets.
  • Each Meet has Events.
  • Each Event has Heats.
  • Each Heat has Lane Results.

Latest Blog Post: AthStitcher -Functionality

V7.8.0 Latest version of related phone app available for sideload via File menu.

Note

As things stand, athletes are manually entered into heat results before or after a heat has been run.


Build PS Packaging Commands

Found can publish x86 from VS, right click on install project Publish, select Folder, set Target Runtime to win-x86, then Publish.
With x64 get error:

Error ... Assets file 'C:\Users\david\source\repos\PhotoTimingDjaus-16-10-2025\AthStitcher\obj\wappublish\win-x64\project.assets.json' not found. Run a NuGet package restore to generate this file.

Use the following commands from Developer Command Prompt for VS 2022 to build x64 (and x86) version/s.

MSBuild.exe ".\AthStitcherInstall\AthStitcherInstall.wapproj" /t:Restore,Rebuild /p:Configuration=Release /p:Platform=x86 /v:m
MSBuild.exe ".\AthStitcherInstall\AthStitcherInstall.wapproj" /t:Restore,Rebuild /p:Configuration=Release /p:Platform=x64 /v:m

Feedback

What features would you like to see implemented?

Ps: Stopping this development for now. Awaiting any feedback before going further.

Eg Athletes Table, Location Table Draw up Heats etc ?? Leave a note thx.


QuestPDF

  • Added QuestPDF NuGet package to AthStitcher WPF app to enable export of Heat, Event results as Pdf file.
  • Requires licensing acceptance on first use.
    • See QuestPDF Licensing
    • If accepting license for Community Non Profit use then uncomment line #46 in Data/ToPdf.cs

AthStitcher Updates History

In Brief: This software package has been created in two parts. Initially a simple Photo Timing app using stitched images from a video was created. Of late a Database Management System was added for recording the timing results in the context of Meets, Events, Heats, and Lane results. An ability to export results as Text PDF files has been added to the DBMS system as well as an ability to import events for a Meet from a Csv or Tabbed text file. The software has undergone progress updates to enhance functionality and user experience.

Version Update Details: See

2Do

  • Reverse the horizontal direction of the stitched image such that athlete on right is fastest which matches the direction that athletes compete.
  • Some tidy up so only using existing Meet-Event-Heat-Results-Video

Features to add

  • Restore Ability: Can send and process a video that doesn't have a Meet-Event-Heat associated with it. Done
  • Send Meets and Events to AthsVideoRecording app over TCP each with a Guid.
    • So that when video is sent over TCP, the Meet and Event can be selected.
    • Sending Events and Heats at this end is Done.
      • AthsVideoRecording app is being updated to receive these._ Done
    • 2Do: _Need to align received video with correct Event and Heat. Done
  • Athletes Table, Location Table Draw up Heats
  • Truncate video option at start(gun) time.
    • Code is written.

Comment

Have posted a blog post wrt GitHub Pilot strengths and weakness in creating this code. GitHub Copilot v Documentation: How far can you go with Copilot

Informatioon:

  • Input a .MP4 video
    • Competitors (Manual entry in lane results)._
  • Outputs:
    • A .png file (stitched image)
    • Result in SqLite database file
    • Results a text or Pdf file

App

  • AthStitcher
    • This is a WPF app so runs on a Windows desktop.
    • Uses PhotoTimingDjausLib.
    • Can measure time for events using mouse click and drag on image.
    • Set video file and press [Stitch Video], or load and stitch from File menu.
      • Generates stitched image file
      • Option to choose timing mode from:
        1. Video Start
        2. Manual Mode (Set start time wonce stitched)
        3. WallClock Mode Set Wallclock time of race start and then work out times wrt this and video start.
        4. Detect Start Gun audio
        5. Detect video flash (Not yet imlemented).
      • (For 2.) Also extracts audio max volume (per audio fame) in dB v time text file from video, generates gun time
        • Assumes video recording is started before gun.
        • Nb: Audio frames are not video frames.
          • Max vol for each frame = max vol for each frame in dB - (the min value in dB for all audio frames)
        • Volume for each audio frame = 10^ (Max vol for frame in /10);
          • Graph of Volume added below ticks for WPF app.
        • Guntime is first time at which Volume >= (Max Volume of all frames) /1000 <-- This 1000 value is in-app settable.
    • Can load previous stitched file but timing doesn't work for that (2Do)
    • Uses Image viewer with zoom and pan from this GitHub project djaus2/ShowImageWPF
      • Zoom etc currently not working
    • DBMS functionality added
      • Using Entity Framework Core with SqLite database
      • Record Meets, Events, Heats, Lane Results
      • Export results as Text or Pdf file using QuestPDF NuGet package
      • Import Events from Csv or Tabbed text file

AthStitcher Libraries

  • PhotoTimingDjausLib
    • Does video stitching
    • Uses NuGet Packages:
      • OpenCvSharp4
      • OpenCvSharp4.runtime.win
      • FFMpegCore
      • NAudio
  • DetectVideoFlash
    • Uses NuGet Packages:
    • OpenCvSharp4
    • OpenCvSharp4.runtime.win
    • And Sportronics.VideoEnums
  • GetVideoWPFLib
    • Receives video over TCP from AthsVideoRecording Maui app
    • Uses DownloadVideoOverTcpLib
    • And Sportronics.VideoEnums
  • Sportronics.VideoEnums From NuGet
    • Various enums used throughout
    • VideoInfo class
      • Meta-Info created on phone for video
        • Passed to AthStitcher over TCP before video and used there.

2Dos

A few issues remain but getting there.

  • Times are not quite accurste.
  • Panning and scrolling need improvement. <- Improved in V3
  • When starting from a time not at start of video, time at bottom scale is not changed (is from 0). But determined time is correct.

Usage

  • You need a video, as .MP4.
    • Film with a phone and transfer to desktop.
  • In WPF app, Once stitched, use mouse to select a time, for which a red line appears vertically and time is shown.
    • Once the mouse releases, the time shows in a box towards the top as a time span string.
    • It is also copied to the clipboard.

Footnote

Found my phone has a few options to try

  • Image stabilisation (Locked)
  • 60 FPS which would halve time resolution to 17 mSec ... about 2 100ths of a sec

Enjoy.

Nb: This was authored up to last 10% using GitHub Copilot. Also the porting of PhotoTimingDjausLibAndroid from OpenCvSharp4 to Emgu.CV was done with help of GitHub Copilot!

About

Phototiming of athletics finish by stitching middle vertical pixels of each frame into an image

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published