{"id":23011894,"url":"https://github.com/chriamue/object-detector-rust","last_synced_at":"2025-08-14T06:32:18.003Z","repository":{"id":118702607,"uuid":"582907015","full_name":"chriamue/object-detector-rust","owner":"chriamue","description":"Object detection using feature-based algorithms in Rust. Compiles to WebAssembly.","archived":false,"fork":false,"pushed_at":"2023-12-26T13:36:40.000Z","size":2518,"stargazers_count":26,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-12-13T18:09:24.719Z","etag":null,"topics":["feature-based","hog","object-detection","orb","rust","wasm"],"latest_commit_sha":null,"homepage":"https://blog.chriamue.de/hog-detector/","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chriamue.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2022-12-28T07:41:56.000Z","updated_at":"2024-10-15T21:23:15.000Z","dependencies_parsed_at":null,"dependency_job_id":"8958c670-d0cc-4341-991a-4eca34cc8afa","html_url":"https://github.com/chriamue/object-detector-rust","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/chriamue%2Fobject-detector-rust","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chriamue%2Fobject-detector-rust/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chriamue%2Fobject-detector-rust/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chriamue%2Fobject-detector-rust/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chriamue","download_url":"https://codeload.github.com/chriamue/object-detector-rust/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229805132,"owners_count":18126808,"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":["feature-based","hog","object-detection","orb","rust","wasm"],"created_at":"2024-12-15T10:11:42.325Z","updated_at":"2024-12-15T10:11:42.799Z","avatar_url":"https://github.com/chriamue.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Object Detector Rust 🔍\n\n[![Github Repo](https://img.shields.io/badge/github-repo-green)](https://github.com/chriamue/object-detector-rust/)\n[![codecov](https://codecov.io/gh/chriamue/object-detector-rust/branch/main/graph/badge.svg?token=RJ6T5D9DZT)](https://codecov.io/gh/chriamue/object-detector-rust)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Docs](https://img.shields.io/badge/Docs-online-green.svg)](https://chriamue.github.io/object-detector-rust/object_detector_rust/)\n\nObject Detector Rust is a framework for detecting objects in images using feature-based algorithms. It includes implementations of the HOG and ORB algorithms, as well as functions for feature matching and object localization. The framework is written in Rust, a statically-typed, memory-safe language that can be compiled to WebAssembly for use in web browsers or other environments.\n\n## Features 💪\n\n- Object detection using HOG and ORB feature-based algorithms\n- Feature matching and object localization functions\n- Written in Rust, compiled to WebAssembly\n\n## Architecture 🧱\n\nThe overall architecture of the Object Detector Rust system is shown in the following diagram:\n\n![Object Detection Diagram](https://www.plantuml.com/plantuml/proxy?cache=no\u0026src=https://raw.github.com/chriamue/object-detector-rust/main/docs/object-detection-diagram.puml)\n\nIn this system, the input image is passed to the feature extractor, which extracts features from the image. The extracted features are then matched against features in a template image using a matcher. The matcher passes the locations of the matched features to a localizer, which determines the location of the object in the input image and annotates the image with a bounding box around the object.\n\n## Training 🏋️‍♀️\n\nTo train a model for object detection, you will need a dataset of labeled images that includes examples of the objects you want to detect. You can use tools such as [Image Label Tool](https://chriamue.github.io/image-label-tool/) to label your images.\n\nOnce you have collected and labeled your dataset, you can use image processing and machine learning libraries to extract features from the images and train a model using these features.\n\nTo train a model, you will need to:\n\n1. Load and preprocess the images in your dataset. You can use image processing libraries to load the images from files and apply any desired transformations, such as resizing or converting to grayscale.\n\n2. Extract features from the images. You can use image processing libraries to extract features such as HOG, or ORB from the images.\n\n3. Create a model using a machine learning library. You can choose a model that is suitable for object detection, such as an SVM classifier.\n\n4. Train the model on the features using the `fit` method provided by the model.\n\n![Training](https://www.plantuml.com/plantuml/proxy?cache=no\u0026src=https://raw.github.com/chriamue/object-detector-rust/main/docs/training.puml)\n\n## Usage 📖\n\nTo use the Object Detector Rust library, you will need to add it to your project as a dependency. You can do this by adding the following to your `Cargo.toml` file:\n\n```toml\n[dependencies]\nobject-detector-rust = \"0.1\"\n```\n\nThen, use the crate in your Rust code:\n\n```rust\nuse object_detector_rust::prelude::*;\n\nfn main() {\n}\n```\n\nYou can then use the library to train and use a classifier or detector on your annotated images.\n\nTo train a classifier, you will need to create a `DataSet` object and populate it with annotated images. You can then create a `Classifier` object, such as a `BayesClassifier` or `SVMClassifier`, and pass it the `DataSet` object to train it.\n\n```rust .ignore}\nuse image::DynamicImage;\nuse object_detector_rust::prelude::*;\nuse object_detector_rust::utils::extract_data;\nuse object_detector_rust::feature::HOGFeature;\n// Create a memory-based DataSet\nlet mut dataset = MemoryDataSet::new();\n\n// Add some annotated images to the DataSet\ndataset.add_annotated_image(AnnotatedImage {\n    image: DynamicImage::new_rgba8(128, 128),\n    annotations: vec![Annotation {\n        bbox: BBox { x: 0, y: 0, width: 32, height: 32 },\n        class: 0,\n    }],\n});\ndataset.add_annotated_image(AnnotatedImage {\n    image: DynamicImage::new_rgba8(128, 128),\n    annotations: vec![Annotation {\n        bbox: BBox { x: 50, y: 50, width: 32, height: 32 },\n        class: 1,\n    }],\n});\nlet class = 1;\nlet feature = HOGFeature::default();\n// Create a BayesClassifier and train it on the DataSet\nlet mut classifier = BayesClassifier::new();\nlet (x, y) = dataset.get_data();\nlet x: Vec\u003cVec\u003cf32\u003e\u003e = x\n        .iter()\n        .map(|image| feature.extract(image).unwrap())\n        .collect();\n    let y = y\n        .iter()\n        .map(|y| if *y == class { true } else { false })\n        .collect();\nlet (x, y) = extract_data(x, y);\nclassifier.fit(\u0026x.view(), \u0026y.view());\n```\n\nTo use a classifier to predict the class of an image, you can call the `predict` method on the classifier and pass it the image.\n\n```rust .ignore\nlet prediction = classifier.predict(\u0026image);\n```\n\nTo use a detector in Object Detector Rust, you will need to do the following:\n\n1. Create a `Detector` object. This can be done using one of the provided implementations, such as `HOGSVMDetector` or `BriefSVMDetector`, or by creating a custom implementation of the `Detector` trait.\n2. Train the `Detector` object on a `DataSet` object. The `DataSet` trait includes methods for adding annotated images and iterating over them.\n3. Use the Detector object's detect method to detect objects in images and return their bounding boxes and class predictions.\n\nFor example:\n\n```rust .ignore\nuse object_detector_rust::prelude::{DataSet, Detector, HOGSVMDetector};\n\n// Create a HOGSVMDetector object\nlet mut detector = HOGSVMDetector::new();\n\n// Create a DataSet object and add some annotated images to it\nlet mut dataset = MemoryDataSet::new();\ndataset.add_annotated_image(annotated_image_1);\ndataset.add_annotated_image(annotated_image_2);\n\n// Train the detector on the dataset\ndetector.train(\u0026dataset);\n\n// Use the detector to detect objects in an image\nlet detections = detector.detect(\u0026image);\n```\n\n## Building and Testing 🛠️\n\nTo build the Object Detector Rust crate, run `cargo build` from the command line. To run the unit tests, use `cargo test`.\n\n## Running Benchmarks 🏋️‍♀️\n\nTo run the benchmarks for the Object Detector Rust crate, use the cargo bench command. This will run all the benchmarks defined in the benches directory.\n\nYou can also run a specific benchmark by specifying its name, like this:\n\n```sh\ncargo bench\n```\n\nIf you want to see the output of the benchmarks as they are running, you can use the --verbose flag:\n\n```sh\ncargo bench --verbose\n```\n\n## ORB Support 🚧\n\nORB support is currently planned, but not yet implemented. Stay tuned for updates!\n\n## Contributing 🙏\n\nWe welcome contributions to Object Detector Rust! If you have a bug fix or feature you would like to add, please open a pull request.\n\n## License 📜\n\nObject Detector Rust is licensed under the [MIT License](https://github.com/chriamue/object-detector-rust/blob/main/LICENSE).\n\n## Note 📝\n\nThis project is a remake of [Hog Detector](https://github.com/chriamue/hog-detector).\nIt was made with assistance of chatgpt.\nFind the dialog [here](https://github.com/chriamue/object-detector-rust/blob/main/transcript.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchriamue%2Fobject-detector-rust","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchriamue%2Fobject-detector-rust","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchriamue%2Fobject-detector-rust/lists"}