A simple phototiming 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 stitching 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.

Apps

  • PhotoTimingDjaus
    • A Console app that does the image stitching.
      • Originally called by VideoStitcher apps to do such but that functionality is separate library.
      • Currently unloaded as code hasn’t been updated for code changes in library.
  • AthStitcher .. Use this
    • This is a WPF app so runs on a Windows desktop.
    • Uses PhotoTimingDjausLib as above.
    • 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
      • Gets StartTimeMode from video file
      • Option to choose timing mode from:
        1. Video Start
        2. Manual Mode (Set start time once 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 implemented).
      • (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
    • Can show Video frame for any point in time by clicking on the image.
  • StitchInTimeMaui Maui version of PhotoTimingDjaus Console app
    • Uses PhotoTimingDjausLibAndroid as above.
    • Tested on Google Pixel 6 phone
    • Now performs stitch of limited video:
      • Limited to 1000 frames = 33 seconds
    • Now displays stitched image
      • On phone scroll up from bottom
      • 2D: Display on separate page
    • Uses Emgu.CV.runtime.maui.mini.android via PhotoTimingDjausLibAndroid library
    • Now runs in Android Device
    • Ticks added at bottom by overwriting image
      • 1, 5, 10 sec and minute different colors and sizes
      • No labels yet
    • Cancel button added
      • Some times there is a buffer issue.

Libraries

  • PhotoTimingDjausLib
    • Uses NuGet Packages:
      • OpenCvSharp4
      • OpenCvSharp4.runtime.win
      • FFMpegCore
      • NAudio
    • Does video stitching
  • PhotoTimingDjausLibAndroid
    • Uses Emgu.CV.runtime.maui.mini.android instead of OpenCvSharp4
    • Not as functional as *PhotoTimingDjausLib 2Do.

TimeFromMode

When the video is to be recorded on the phone, a selection is made as to which TimeFromMode is to be used:

    public enum TimeFromMode
    {
        FromVideoStart, //From start of video capture
        FromGunSound, //From gun sound
        FromGunFlash,  //From observed flash of gun on video
        ManuallySelect, //Manually selected start time
        WallClockSelect,
    }

As the video is recorded, the selected TimeFromMode will determine how the timing information is extracted and processed from the video frames. This allows for flexibility in handling different types of events and scenarios during the race.

The first mode is the simplest but least accurate. It relies solely on the video start time, which may not align accurately with the actual start of the race. Other modes, like FromGunSound or FromGunFlash, can provide more precise timing by detecting specific events in the video. ManuallySelect allows the user to specify the start time upon inspection of the stitched image, which can be useful in situations where the other modes are not sufficient. WallClockSelect enables the user to “fire”” an event for the race start independent to the video start with the gun time being encoded with the video.With WallClock mode there is an option to set the video recording to start after a specific period This would be useful for a longer race such as a 400m where the video may start, say 40 seconds after the race actually begins reducing significantly the length of the video. Commercial systems used to have a light beam just before the finish to trigger the video recording.

The video when recorded, encodes the TimeFromMode as a prefix to the video filename which is interpreted by the desktop AthsStitcher app. Also for WallClock mode, the WallClock gun time is included in that prefix for parsing by the desktop app. Once determined that meta-information is encoded formally as video meta-information in the copy of the video file.

The prefix REGEX patterns searched for are in the video filename at the desktop end are:

  videoStart =  @"_VIDEOSTART_\.mp4$";  // Default
  wallClockPattern = @"_WALLCLOCK_(\d{4}-\d{2}-\d{2} \d{2}--\d{2}--\d{2}\.\d{3})_\.mp4$"; <-- A DateTime string (sort of)
  gunPattern = @"_GUNSOUND_\.mp4$";
  flashPattern = @"_GUNFLASH_\.mp4$";
  manualPattern = @"_MANUAL_\.mp4$";

Note that the second pattern searches for a DateTime string as well, where all occurrences of “:” have been substituted for by “–” which is reversed at the desktop end.

The prefix information is stripped from the filename at the desktop end, interpreted and stored as embedded metadata in a copy of the video file file. Going forwards, it would be better to embed this information directly into the video file itself but this wqs found to be problematic.



 TopicSubtopic
   
 This Category Links 
Category:Application Dev Index:Application Dev
  Next: > Photo Finish Update
<  Prev:   Photo Finish Update