AthStitcher: Functionality
appdev athstitcher
A summary of the AthStitcher app functionality.
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 stitching together the phototiming image. The horizontal axis of the image represents time, and the vertical axis represents the lanes. By clicking on the image at the finish line position for each athlete in their lane, their finish time is determined from the horizontal position on the image. 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 from the phone over TCP, which AthStitcher is then able to receive. You can sideload the app onto an Android phone via a QR code here. (Needs an update)
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.
- A LaneResult has a lane number, time and identifies the athlete.
Post race processing involves determining finish times against lanes, identifying athletes, sorting in order of finish times, and then exporting the results.
This software package has been created in two parts. Initially a simple Photo Timing app for creating “stitched images” from a video was created. An athlete’s finish time is determined by examining the stitched image to determine when they cross the finish line. This is the AthStitcher app. By clicking on the image at the finish line position for each athlete in their lane, their finish time is determined from the horizontal position on the image. To increase accuracy the video frame corresponding to the time is displayed. The user then can “nudge” the position forwards and backwards to get a more accurate position/time.
The Database Management System was added for recording the timing results in the context of Meets, Events, Heats, and Lane results. You can manually setup a Meet with Events, and specify a number of heats or append them later. For each Heat you can record the Lane Results by clicking on the stitched image as before. The results can then be exported as Text or PDF files. When setting up an event you specify the lanes to be used, which then applies to all Heats in that Event. You can also to setup a Meet by importing event details from a Csv or Tabbed text file.

From a commercial Photo Finish system, a typical photo finish stitched image with lane lines and athlete finish positions marked


AthStitcher images
Comment wrt the the stitched images.
Ideally the phone would be held steady on a mount and focused upon the the finish line with the middle pixels of the video frames aligned with the finish line. In practice this is difficult to achieve when handheld. With much effort, some code was developed to “straighten the lane lines by moving vertical lines of pixels up and down. This was found to be cosmetic as it did not improve the timing accuracy as it is the horizontal position that matters. The white sections in the image are what are desired though. If the phone’s camera is precisely positioned, the whole lane area in the stitched image would be white as this is what the finish line looks like (a white line). The lane lines at the finish line are typically marked in black or with sticking up black tape to provide contrast. Some thoughts have been given to moving the selected line of pixels left and right to try to center on the white line, but this is difficult to do reliably. Some slight rotation might help also.
In conclusion, the app works best when the phone is held as steady as possible and focused on the finish line. The closer the video, the better the stitched image and the easier it is to determine finish times. Even with the images such as above, timing accuracy of at least 0.1 seconds can be achieved which is sufficient for many athletics events.
Recording times
As a runner in the image is clocked upon, the time is saved to the clipboard. As the frame is nudged forwards and backwards, the clipboard is is updated. When complete, the time can then be pasted into the results table for the lane for the heat in the table top right of the app.

Results table for a Heat with lane times recorded
The DBMS System
The DBMS system allows Meets, Events, Heats and Lane Results to be recorded. Meets can be setup manually or by importing from a Csv or Tabbed text file. Events are added to the Meet, specifying the lanes to be used. Heats can then be added to each Event. For each Heat the Lane Results are recorded by clicking on the stitched image as before. The results can then be exported as Text or PDF files. A Sqlite database athstitcher.db, as file based database, is used to store the data.
- You setup Meets etc under theProgram Menu.
- You action exporting results under the Print menu.
The AthStitcher SqLite Database Schema
⇧Table Meets
| Name | Type | NULL | Comment |
|---|---|---|---|
| ◆Id | bigint | ☐ | IDENTITY (1,1) |
| Description | text | ☐ | |
| Round | bigint | ☐ | |
| Date | text | ☒ | |
| Location | text | ☒ | |
| MaxLanes | bigint | ☒ |
⇧Table Events
| Name | Type | NULL | Comment |
|---|---|---|---|
| ◆Id | bigint | ☐ | IDENTITY (1,1) |
| MeetId | bigint | ☐ | ⇨ Meets.Id |
| EventNumber | bigint | ☒ | |
| Time | text | ☒ | |
| Description | text | ☒ | |
| Distance | bigint | ☒ | |
| HurdleSteepleHeight | bigint | ☒ | |
| TrackType | bigint | ☐ | |
| Gender | bigint | ☐ | |
| AgeGrouping | bigint | ☐ | |
| UnderAgeGroup | bigint | ☒ | |
| MastersAgeGroup | bigint | ☒ | |
| VideoInfoFile | text | ☒ | |
| VideoStartOffsetSeconds | real (53, 0) | ☒ | |
| MinLane | bigint | ☒ | |
| MaxLane | bigint | ☒ |
⇧Table Heats
| Name | Type | NULL | Comment |
|---|---|---|---|
| ◆Id | bigint | ☐ | IDENTITY (1,1) |
| EventId | bigint | ☐ | ⇨ Events.Id |
| HeatNo | bigint | ☐ |
⇧Table Results
| Name | Type | NULL | Comment |
|---|---|---|---|
| ◆Id | bigint | ☐ | IDENTITY (1,1) |
| HeatId | bigint | ☐ | ⇨ Heats.Id |
| Lane | bigint | ☒ | |
| ResultSeconds | real (53, 0) | ☒ | |
| BibNumber | bigint | ☒ | |
| Name | text | ☒ | |
| Club | text | ☒ |
Uploading a video from AthsVideoRecording app
When you upload a video from the AthsVideoRecording app, a json file is sent first. This contains meta-data about the video such as FramesPerSecond, Orientation, Event name etc. This is used to complete the video download using filename and a checksum. The meta-information also indicates how the heat start is determined. The File menu contains the Download Video command aas well the OpenandStitch command. The File Menu alos has a dialog that show the link to the AthsVideoRecording app for sideloading onto an Android phone, as a QR Code.
Event/Heat Start Modes
- FromVideoStart, //From start of video capture
- FromGunSound, //From gun sound
- The sound track of the video is analyzed to find the gun sound.
- FromGunFlash, //From observed flash of gun on video
- ManuallySelect, //Manually select start time from inspection of the stitched video
- WallClockSelect
- A specific start time for the heat is specified in wall clock time (hh:mm:ss.ff) and sent in the json meta-data.
- In this mode the video can be started before/after the race start as times are calculated relative to the video start and wallclock time.
- Also, this mode allows for the video to start at a specific time after being actioned, thus shortening the video length.,
As an alternative, the start mode can be selected in the AthStitcher app after the video is received.
Other Functionality
The Settings Menu facilitates downloading and setting up of the ExifTool utility which is used to read/write metadata in the video and image files from the downloaded json file. After writing it to these files, the app then uses that rather than the json file for meta-information. This is used to set the wall clock time in the video file if required. Nb: ExifTool is not available in the Maui context.
| Topic | Subtopic | |
| This Category Links | ||
| Category: | Application Dev Index: | Application Dev |
| Next: > | athstitcher | Features not yet included |
| < Prev: | DBMS Tabular Data | Generate PDF in WPF App |