{"id":15976747,"url":"https://github.com/tobybreckon/correlation-ga","last_synced_at":"2026-04-15T23:31:38.535Z","repository":{"id":152041993,"uuid":"126625062","full_name":"tobybreckon/correlation-ga","owner":"tobybreckon","description":"A C++ Teaching Example for a Genetic Algorithm (GA) based on Image Correlation","archived":false,"fork":false,"pushed_at":"2020-08-18T23:14:22.000Z","size":15,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-26T17:27:08.922Z","etag":null,"topics":["correlation","genetic-algorithm","opencv"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tobybreckon.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-24T17:48:32.000Z","updated_at":"2023-08-15T13:34:47.000Z","dependencies_parsed_at":null,"dependency_job_id":"3c696c89-cd07-488f-8717-3e60bccbaa4b","html_url":"https://github.com/tobybreckon/correlation-ga","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tobybreckon/correlation-ga","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tobybreckon%2Fcorrelation-ga","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tobybreckon%2Fcorrelation-ga/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tobybreckon%2Fcorrelation-ga/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tobybreckon%2Fcorrelation-ga/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tobybreckon","download_url":"https://codeload.github.com/tobybreckon/correlation-ga/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tobybreckon%2Fcorrelation-ga/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31864963,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-15T15:24:51.572Z","status":"ssl_error","status_checked_at":"2026-04-15T15:24:39.138Z","response_time":63,"last_error":"SSL_read: 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":["correlation","genetic-algorithm","opencv"],"created_at":"2024-10-07T22:40:45.559Z","updated_at":"2026-04-15T23:31:38.519Z","avatar_url":"https://github.com/tobybreckon.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# C++ Genetic Algorithm - Teaching Example\n\nA Genetic Algorithm (GA) example based on using correlation of a selected image region against all other regions in the image to find the location of selection.\nImplemented as a C++ header class (_ga.h_) with an interface (_ga_interface.cpp_) to allow for variable population size (P), mutation (M) and cross-over (C) probability settings.\n\nIllustrates all of the key elements of a GA approach including:\n\n- **genes / phenotypes**: _(xi,yi)_ locations of image regions (i.e. chromosomes / genetic representation)\n- **population**: random set of _(X x Y)_ dimension regions from the image each at _(xi,yi)_.\n- **fitness function**: correlation between mouse selected (click and drag) image region and each region in the population.\n- **selection**: fitness proportional selection, roulette wheel.\n- **cross-over**: uniform cross-over based on crossing _xi_ and _yi_ co-ordinates between two selected regions.\n- **mutation**: randomly perturb bit-pattern of  _xi_ and _yi_ co-ordinates of each region in the population.\n\n-- within a readily adaptable C++ class structure.\n\nRequires [OpenCV](http://www.opencv.org) - all tested with OpenCV 2.4.x / 3.x and GCC (Linux) and known to work with MS Visual Studio 20xx on Win32 / Win64.\n\nExample video (click to watch):\n[![Example Video](http://img.youtube.com/vi/7cjkJ7xa84Q/0.jpg)](http://www.youtube.com/watch?v=7cjkJ7xa84Q)\n\n---\n\n### Background:\n\nIf I taught you between 2010 and 2013 at [Cranfield University](http://www.cranfield.ac.uk) or [ESTIA](http://www.estia.fr) - this is the C++ GA example from class.\n\nDemo source code is provided _\"as is\"_ to aid your learning and understanding.\n\n---\n\n### How to download and run:\n\nDownload each file as needed or to download the entire repository and run each try:\n\n```\ngit clone https://github.com/tobybreckon/correlation-ga.git\ncd correlation-ga\ncmake .\nmake\n./correlation_ga\n\u003c use sliders to select population size (P), mutation (M) and cross-over (C) probability settings \u003e\n\u003c use mouse to click/drag to select image region \u003e\n\u003c hold down - x key to exit / r key to reset  \u003e\n```\n\nThe GA example runs with a webcam connected or from a command line supplied video file of a format OpenCV supports on your system (otherwise edit the code to provide your own image source).\n\n_N.B._ you may need to change the line near the top that specifies the camera device to use on this example - change \"0\" if you have one webcam, I have to set to \"1\" to skip my built-in laptop webcam and use the connected USB camera.\n\n---\n\nIf referencing this example in your own work please use:\n```\n@TechReport{breckon2010,\n  author =       {Breckon, T.P. and Barnes, S.E.},\n  title =        {Machine Learning - MSc Course Notes},\n  institution =  {Cranfield University},\n  year =         {2010},\n  address =      {Bedfordshire, UK},\n}\n```\n\n---\n\nIf you find any bugs please raise an issue (or better still submit a pull request, please) - toby.breckon@durham.ac.uk\n\n_\"may the source be with you\"_ - anon.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftobybreckon%2Fcorrelation-ga","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftobybreckon%2Fcorrelation-ga","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftobybreckon%2Fcorrelation-ga/lists"}