{"id":16516882,"url":"https://github.com/alkasm/matlab-template-tracking","last_synced_at":"2026-02-06T07:09:52.409Z","repository":{"id":123352126,"uuid":"91056582","full_name":"alkasm/matlab-template-tracking","owner":"alkasm","description":"Two Matlab functions and an example script for template tracking through video","archived":false,"fork":false,"pushed_at":"2017-05-15T19:14:03.000Z","size":8549,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-24T18:13:48.707Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Matlab","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alkasm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-05-12T05:58:37.000Z","updated_at":"2022-09-08T15:58:16.000Z","dependencies_parsed_at":null,"dependency_job_id":"f93bd7f9-23da-43ed-858b-c144b67b017a","html_url":"https://github.com/alkasm/matlab-template-tracking","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/alkasm/matlab-template-tracking","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alkasm%2Fmatlab-template-tracking","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alkasm%2Fmatlab-template-tracking/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alkasm%2Fmatlab-template-tracking/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alkasm%2Fmatlab-template-tracking/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alkasm","download_url":"https://codeload.github.com/alkasm/matlab-template-tracking/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alkasm%2Fmatlab-template-tracking/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29153909,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-06T02:39:25.012Z","status":"ssl_error","status_checked_at":"2026-02-06T02:37:22.784Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T16:27:26.027Z","updated_at":"2026-02-06T07:09:52.393Z","avatar_url":"https://github.com/alkasm.png","language":"Matlab","funding_links":[],"categories":[],"sub_categories":[],"readme":"# File List\n\nREADME - This file  \nsmb_tracking.m - Example MATLAB script  \nmatch_template.m - MATLAB function  \ntrack_template.m - MATLAB function  \ninput/smb_w4-1.mp4 - Example video input  \ninput/template.mat - Data file containing the template and mask for smb_tracking.m\n \n# Project Description\n\nThis project was an extension to a template matching project I worked on before to incorporate tracking through video feed. The idea was to use frame-by-frame template matching to locate a template within a video, and to optimize the code by reducing the search area for the template based on the previous position. This code at its heart uses a template matching function that uses a scaled sum of square differences.\n\nSome unique functionalities of this template tracking algorithm:\n\n1. You can specify a `radius` around the prior matched template area to search in.\n2. You can specify a `threshold` so that matches can be rejected.\n3. You can specify a `growth rate` for `radius` so that if the tracked object leaves the search area, `radius` will grow around the last known position until the template is found again.\n4. Instead of using *normalized* sum of square differences, I opted to make my own scaling factor to normalize the SSD. It computes the *maximum possible SSD* the `template` can have with *any* `image` and scales by that, to get a true 0-to-1 scaled SSD unique for each template. That means a 90% match is a 90% match regardless of the `template`.\n\nThese scripts and functions were built on MATLAB R2017a. The script uses the computer vision toolbox to input and output video and draw a box around Mario, but this can be removed if a license to the toolbox is not possessed and can be read, output, and drawn using the standard Matlab library. The project idea came from a reddit thread in the [r/computervision](https://reddit.com/r/computervision/) subreddit. You can see my subsequent text-post here: [r/computervision/comments/6aqmbo/template_tracking_super_mario/](https://reddit.com/r/computervision/comments/6aqmbo/template_tracking_super_mario/)\n\n# Example Outputs\n\n[https://youtu.be/zo3U3a4nmyY](https://youtu.be/zo3U3a4nmyY)  \nThis video shows the output from running `smb_tracking`.  \n\n[https://youtu.be/m99H6oH46E8](https://youtu.be/m99H6oH46E8)  \nThis video shows how setting a `thresh` and `radius` will dynamically adjust the search area for a `template` by expanding `radius` when no good matches (that is, the scaled SSD is above `thresh`) are found  in the previous search area. The code to generate this video is not included but `track_template` can be easily edited to output the search area of each frame. The included example does, however, use this method.\n\n# Description of .m files\n\n**smb_tracking.m**  *requires match_template.m, track_template.m, CV toolbox*  \nAn example script which reads the included video input and outputs a video drawing a box around a tracked Mario. \n\n**track_template.m**  *requires match_template.m*  \nA function which takes in an `imgseq` (video) and a `template` (with additional optional inputs) and tracks the `template`. The function runs `match_template` on every frame and outputs match locations for each frame, optionally outputting the computed scaled sum of square difference between each `imgseq` frame and `template` at those match locations.  \n\n**match_template.m**  \nA function which takes in an `image` and a `template` (with additional optional inputs) and locates the `template` within the `image`. The function outputs the location of the best match, and optionally outputs the computed scaled sum of square difference between `image` and `template` at those match locations.\n\nRun `help \u003cfunction name\u003e` for detailed usage instructions, additional input options, output options, class support, and basic examples.\n\n\n# Contributors\nAlexander Reynolds  \n  [ar@reynoldsalexander.com](mailto:ar@reynoldsalexander.com)  \n  [https://github.com/alkasm](https://github.com/alkasm)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falkasm%2Fmatlab-template-tracking","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falkasm%2Fmatlab-template-tracking","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falkasm%2Fmatlab-template-tracking/lists"}