{"id":20495199,"url":"https://github.com/samuelebortolotti/feature-detection-and-tracking","last_synced_at":"2025-03-05T18:23:45.969Z","repository":{"id":77067946,"uuid":"489348256","full_name":"samuelebortolotti/feature-detection-and-tracking","owner":"samuelebortolotti","description":"Repository concerning a feature detector and tracker developed for the Computer Vision course of the master's degree in Computer Science at University of Trento ","archived":false,"fork":false,"pushed_at":"2022-07-05T09:34:14.000Z","size":110009,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-16T06:12:58.482Z","etag":null,"topics":["blob-detector","computer-vision","harris-corner-detector","kalman-filter","orb","python","shi-tomasi","sift"],"latest_commit_sha":null,"homepage":"","language":"Python","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/samuelebortolotti.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":"2022-05-06T12:36:10.000Z","updated_at":"2023-11-17T13:07:15.000Z","dependencies_parsed_at":"2024-02-18T16:31:39.757Z","dependency_job_id":null,"html_url":"https://github.com/samuelebortolotti/feature-detection-and-tracking","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuelebortolotti%2Ffeature-detection-and-tracking","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuelebortolotti%2Ffeature-detection-and-tracking/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuelebortolotti%2Ffeature-detection-and-tracking/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuelebortolotti%2Ffeature-detection-and-tracking/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/samuelebortolotti","download_url":"https://codeload.github.com/samuelebortolotti/feature-detection-and-tracking/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242077356,"owners_count":20068339,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["blob-detector","computer-vision","harris-corner-detector","kalman-filter","orb","python","shi-tomasi","sift"],"created_at":"2024-11-15T17:44:55.631Z","updated_at":"2025-03-05T18:23:45.941Z","avatar_url":"https://github.com/samuelebortolotti.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Feature detection and tracking\n\nFeture detection and tracking is a collection of methods concerning feature detection and tracking in videos, developed for the `Computer Vision` course of the master's degree program in Computer Science at the University of Trento.\n\n## Author\n\n| Name    |  Surname   |    MAT     |\n| :-----: | :--------: | :--------: |\n| Samuele | Bortolotti | **229326** |\n\n## Requirements\n\nThe code as-is runs in Python 3.9 with the following dependencies\n\n- [opencv](https://opencv.org/)\n- [matplotlib](https://matplotlib.org/)\n\nAnd the following development dependencies\n\n- [Sphinx](https://www.sphinx-doc.org/en/master/)\n\n## Getting Started\n\nFollow these instructions to set up the project on your PC.\n\nMoreover, to facilitate the use of the application, a Makefile has been provided; to see its functions, simply call the appropriate help command with [GNU/Make](https://www.gnu.org/software/make/)\n\n ```bash\n make help\n ```\n\n### 1. Clone the repository\n\n ```bash\n git clone https://github.com/samuelebortolotti/feature-detection-and-tracking.git\n cd feature-detection-and-tracking\n ```\n\n### 2. Install the requirements\n\n```bash\npip install --upgrade pip\npip install -r requirements.txt\n```\n\n\u003e **Note**: it might be convenient to create a virtual enviroment to handle the dependencies.\n\u003e \n\u003e The `Makefile` provides a simple and convenient way to manage Python virtual environments (see [venv](https://docs.python.org/3/tutorial/venv.html)).\n\u003e In order to create the virtual enviroment and install the requirements be sure you have the Python 3.9 (it should work even with more recent versions, however I have tested it only with 3.9)\n\u003e ```bash\n\u003e make env\n\u003e source ./venv/fdt/bin/activate\n\u003e make install\n\u003e ```\n\u003e Remember to deactivate the virtual enviroment once you have finished dealing with the project\n\u003e ```bash\n\u003e deactivate\n\u003e ```\n\n### 3. Generate the code documentation\n\nThe automatic code documentation is provided [Sphinx v4.5.0](https://www.sphinx-doc.org/en/master/).\n\nIn order to have the code documentation available, you need to install the development requirements\n\n```bash\npip install --upgrade pip\npip install -r requirements.dev.txt\n```\n\nSince Sphinx commands are quite verbose, I suggest you to employ the following commands using the `Makefile`.\n\n```bash\nmake doc-layout\nmake layout\n```\n\nThe generated documentation will be accessible by opening `docs/build/html/index.html` in your browser, or equivalently by running\n\n```bash\nmake open-doc\n```\n\nHowever, for the sake of completness one may want to run the full Sphinx commands listed here\n\n```bash\nsphinx-quickstart docs --sep --no-batchfile --project feature-detection-and-tracking --author \"Samuele Bortolotti\"  -r 0.1  --language en --extensions sphinx.ext.autodoc --extensions sphinx.ext.napoleon --extensions sphinx.ext.viewcode --extensions myst_parser\nsphinx-apidoc -P -o docs/source .\ncd docs; make html\n```\n\n\u003e **Note**: executing the second list of command will lead to a slightly different documentation with respec to the one generated by the `Makefile`.\n\u003e This is because the above listed commands do not customize the index file of Sphinx. This is because the above listed commands do not customise the index file of Sphinx.\n\n### 4. Run the SIFT feature detection\n\nTo run the [SIFT](https://en.wikipedia.org/wiki/Scale-invariant_feature_transform) feature detector on an image you can type:\n\n```bash\npython -m fdt sift path_to_image [--n-features 100]\n```\n\nwhere `path_to_image` is the path to the image you want to process with the SIFT algorithm and `--n-features` refers to the number of features you want to obtain from the detection phase.\n\nAs output, the algorithm will plot the original image with the SIFT keypoint drawn on top of it.\n\nAlternatively, you can obtain the same result in a less verbose manner by tuning the flags in the `Makefile` and then run:\n\n```bash\nmake sift\n```\n\n### 5. Run the ORB feature detection\n\nTo run the [ORB](https://en.wikipedia.org/wiki/Oriented_FAST_and_rotated_BRIEF) feature detector on an image you can type:\n\n```bash\npython -m fdt orb path_to_image [--n-features 100]\n```\n\nwhere `path_to_image` is the path to the image you want to process with the ORB algorithm and `--n-features` refers to the number of features you want to obtain from the detection phase.\n\nAs output, the algorithm will plot the original image with the ORB keypoint drawn on top of it.\n\nAlternatively, you can obtain the same result in a less verbose manner by tuning the flags in the `Makefile` and then run:\n\n```bash\nmake orb\n```\n\n### 6. Run the Harris corner detector\n\nTo run the [Harris corner detector](https://en.wikipedia.org/wiki/Harris_corner_detector) on an image you can type:\n\n```bash\npython -m fdt harris path_to_image [--config-file]\n```\n\nwhere `path_to_image` is the path to the image you want to process with the Harris corner detector and `--config-file` is used in order to load the configuration present in `fdt/config/harris_conf.py`.\n\nAs output, the algorithm will plot the original image with the Harris corners drawn on top of it.\n\nAlternatively, you can obtain the same result in a less verbose manner by tuning the flags in the `Makefile` and then run:\n\n```bash\nmake harris\n```\n\n### 7. Run the Simple Blob detector\n\nTo run the [Simple blob detector](https://docs.opencv.org/3.4/d0/d7a/classcv_1_1SimpleBlobDetector.html) on an image you can type:\n\n```bash\npython -m fdt blob path_to_image [--config-file]\n```\n\nwhere `path_to_image` is the path to the image you want to process with the Simple Blob detector and `--config-file` is used in order to load the configuration present in `fdt/config/blob_conf.py`.\n\nAs output, the algorithm will plot the original image with the blobs center keypoint drawn on top of it.\n\nAlternatively, you can obtain the same result in a less verbose manner by tuning the flags in the `Makefile` and then run:\n\n```bash\nmake blob\n```\n\n### 8. Run the feature matching\n\n```bash\npython -m fdt matcher matcher_method [--n-features 100 --flann --matching-distance 60 --video material/Contesto_industriale1.mp4 --frame-update 30]\n```\n\nAlternatively, you can obtain the same result in a less verbose manner by tuning the flags in the `Makefile` and then run:\n\n```bash\nmake matcher\n```\n\n### 9a. Run the feature detection with a the Kalman filter as tracking algorithm\n\n```bash\npython -m fdt kalman matcher_method [--n-features 100 --flann --matching-distance 60 --video material/Contesto_industriale1.mp4 --frame-update 30 --output-video-name videoname]\n```\n\nIf `output-video-name` is passed, then the program saves the video in [AVI](https://it.wikipedia.org/wiki/Audio_Video_Interleave) format in the `output` folder.\nFor generating the video [XVID](https://www.xvid.com/) codec is employed. \nTherefore, if you want to precisely follow the code you may need to install it unless you already have it. \nOtherwise, feel free to change it or suggest me a better alternative.\n\nAlternatively, you can obtain the same result in a less verbose manner by tuning the flags in the `Makefile` and then run:\n\n```bash\nmake kalman\n```\n\nYou can customise the Kalman filter matrices by modifying the `current_conf` Python dictionary in the `fdt/config/kalman_config.py` file.\n\nThe current configuration is depicted here:\n\n```python\nimport numpy as np\n\n\"\"\"Legend:\n  A (np.ndarray): state transition matrix\n  w (np.ndarray): process noise\n  H (np.ndarray): measurement matrix\n  v (np.ndarray): measurement noise\n  B (np.ndarray): additional and optional control input\n\"\"\"\n\n# Configuration which is running at the moment\ncurrent_conf = {\n    \"dynamic_params\": 6,\n    \"measure_params\": 2,\n    \"control_params\": 0,\n    \"A\": np.array(\n        [\n            [1, 0, 1, 0, 1 / 33, 0],\n            [0, 1, 0, 1, 0, 1 / 33],\n            [0, 0, 1, 0, 1, 0],\n            [0, 0, 0, 1, 0, 1],\n            [0, 0, 0, 0, 1, 0],\n            [0, 0, 0, 0, 0, 1],\n        ],\n        np.float32,\n    ),\n    \"w\": np.eye(6, dtype=np.float32) * 50,\n    \"H\": np.array(\n        [\n            [1, 1 / 33, 0, 0, 0, 0],\n            [0, 1, 0, 0, 0, 0],\n        ],\n        dtype=np.float32,\n    ),\n    \"v\": np.eye(2, dtype=np.float32) * 50,\n    \"B\": None,\n}\n```\n\n\u003e **Note:** if the program raises an error when the name of the output video is passed, it is possible that it is an issue with CODECS, thus consider changing the ``cv2.VideoWriter_fourcc(..)` line in the code (`tracking/kalman.py`).\n\n### 9b. Run the feature detection with a the Kalman filter as tracking algorithm\n\n```bash\npython -m fdt lukas-kanade matcher_method [--nfeatures 100 --video material/Contesto_industriale1.mp4 --frameupdate 30]\n```\n\nIf `output-video-name` is passed, then the program saves the video in [AVI](https://it.wikipedia.org/wiki/Audio_Video_Interleave) format in the `output` folder.\nFor generating the video [XVID](https://www.xvid.com/) codec is employed. \nTherefore, if you want to precisely follow the code you may need to install it unless you already have it. \nOtherwise, feel free to change it or suggest me a better alternative.\n\nAlternatively, you can obtain the same result in a less verbose manner by tuning the flags in the `Makefile` and then run:\n\n```bash\nmake lukas-kanade\n```\n\n\u003e **Note:** if the program raises an error when the name of the output video is passed, it is possible that it is an issue with CODECS, thus consider changing the ``cv2.VideoWriter_fourcc(..)` line in the code (`tracking/lucas_kanade.py`).\n\n## 10 Report\n\nThe report concerning the implementation details and my considerations regarding the feature detectors is present in the `report/paper` folder.\n\nMoreover, a simple LaTeX beamer presentation is presented in the `report/presentation`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamuelebortolotti%2Ffeature-detection-and-tracking","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsamuelebortolotti%2Ffeature-detection-and-tracking","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamuelebortolotti%2Ffeature-detection-and-tracking/lists"}