{"id":27796213,"url":"https://github.com/iamleot/imglocate","last_synced_at":"2025-04-30T20:15:01.061Z","repository":{"id":80355043,"uuid":"244440935","full_name":"iamleot/imglocate","owner":"iamleot","description":"Locate objects in images and write annotations of detected objects as TSV","archived":true,"fork":false,"pushed_at":"2025-01-07T15:11:12.000Z","size":481,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-30T20:14:55.561Z","etag":null,"topics":["opencv","python"],"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/iamleot.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":"2020-03-02T18:10:28.000Z","updated_at":"2025-01-07T15:13:26.000Z","dependencies_parsed_at":"2023-06-06T05:15:27.306Z","dependency_job_id":null,"html_url":"https://github.com/iamleot/imglocate","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/iamleot%2Fimglocate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamleot%2Fimglocate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamleot%2Fimglocate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamleot%2Fimglocate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iamleot","download_url":"https://codeload.github.com/iamleot/imglocate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251774920,"owners_count":21641732,"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":["opencv","python"],"created_at":"2025-04-30T20:15:00.380Z","updated_at":"2025-04-30T20:15:01.052Z","avatar_url":"https://github.com/iamleot.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"**NOTE**: As of 2025-01-07 this tool is no longer maintained.\n\n# imglocate\n\nimglocate is a Python 3 script that uses [OpenCV](https://opencv.org/)\nto detect objects in images and write annotations in separate text\nfiles as TSV (tab-separated values) containing: label (object\ndetected), confidence and bounding box (as an x, y, width, height\ntuple).\n\nAnnotating an image is simple as `imglocate annotate`!:\n\n```\n% imglocate annotate office_at_night.jpg\n% cat office_at_night.jpg.txt\nperson\t0.84563\t176\t161\t81\t258\nchair\t0.70672\t109\t264\t87\t141\nperson\t0.60168\t363\t276\t46\t70\ndiningtable\t0.26269\t251\t327\t269\t184\n```\n\n...and, the corresponding image with bounded boxes drawn via\n`draw_bounding_boxes.py` helper script:\n\n![Office at Night, Edward Hopper (1940), oil-on-canvas annotated via imglocate (chair, person, diningtable, person)](/examples/office_at_night.annotated.jpg)\n\n\n## Configuration\n\nimglocate needs to be configured before it can be used.\nA configuration file can be provided via the `-c` option.\nBy default the configuration file `~/.imglocaterc` is used.\n\nThe configuration field should have an `[imglocate]` section and should\ncontains all the following entries:\n\n - `weights`: path to the deep learning network weights\n - `config`: path to the deep learning network config\n - `labels`: path to the labels of the classes returned by the deep learning\n   network. There should be one label per line.\n - `confidence_threshold`: confidence threshold\n - `nms_threshold`: NMS (Non-Maximum Suppression) threshold\n\nFor example, given `weights`, `config`, `labels` in a `~/.imglocate`\ndirectory and using [YOLOv3-tiny](https://pjreddie.com/darknet/yolo/),\na confidence threshold of 0.2 (can be from 0 to 1) and an NMS\nthreshold of 0.3 (can be from 0 to 1):\n\n```\n[imglocate]\nweights = ~/.imglocate/yolov3-tiny.weights\nconfig = ~/.imglocate/yolov3-tiny.cfg\nlabels = ~/.imglocate/yolov3.labels\nconfidence_threshold = 0.2\nnms_threshold = 0.3\n```\n\nThe frameworks supported are the ones supported by\n[`cv.dnn.readNet()`](https://docs.opencv.org/3.4/d6/d0f/group__dnn.html#ga3b34fe7a29494a6a4295c169a7d32422).\n\n\n## Usage\n\nimglocate supports two subcommands: `annotate` and `search`.\nA short usage message of imglocate can be get via the `-h` option:\n\n```\n% imglocate -h\nusage: imglocate [-h] [-c config_file] [-v] {annotate,search} ...\n\nLocate objects in images\n\npositional arguments:\n  {annotate,search}  action\n    annotate         annotate images\n    search           search annotated images\n\noptional arguments:\n  -h, --help         show this help message and exit\n  -c config_file     configuration file\n  -v                 logging level\n```\n\nThe following global options are supported:\n\n - `-h` prints a short usage message about `imglocate` or its subcommands\n - `-c` specify an alternative configuration file instead of using the\n   default `~/.imglocaterc`\n - `-v` increase logging level, can be specified multiple times\n\n\n### annotate\n\n`annotate` subcommand annotate all images passed as arguments and\nstores the annotations in a TSV (tab-separated values) text file in the\nsame path of each image appending to them the `.txt` suffix.\n\nEvery line in the annotations file correspond to a detected object.\nThe fields are, in order:\n\n - label (object detected)\n - confidence\n - x coordinate of the bounding box\n - y coordinate of the bounding box\n - width of the bounding box tuple\n - height of the bounding box\n\nBy default, if the annotations file for the image already exists and\nits last modification time is newer then the last modification time of\nimage no object detection is performed.\n\n```\n% imglocate annotate -h\nusage: imglocate annotate [-h] [-f] [-s] image [image ...]\n\npositional arguments:\n  image       image to annotate\n\noptional arguments:\n  -h, --help  show this help message and exit\n  -f          force regen of already existent annotations\n  -s          only print annotations (do not write them)\n```\n\nThe following options are supported:\n\n - `-h` prints a short usage message\n - `-f` always do the object detection (also if there are annotations with\n   a last modification time newer than the image)\n - `-s` do not write any annotations file, print the annotations to the\n   standard output\n\n\n### search\n\n`search` subcommand, given one or more `image` that were previously\nannotated via `imglocate annotate`, search if label `label` print all\nthe resulting images containing the label to the standard output.\n\n```\n% imglocate search -h\nusage: imglocate search [-h] label image [image ...]\n\npositional arguments:\n  label       force regen of already existent annotations\n  image       image to search\n\noptional arguments:\n  -h, --help  show this help message and exit\n```\n\nThe following options are supported:\n\n - `-h` prints a short usage message\n\n\n## Examples\n\nTo annotate all `*.jpg` images in the current directory:\n\n```\n% imglocate annotate *.jpg\n```\n\nAfter they are annotated, to search all images with a person:\n\n```\n% imglocate search person *.jpg\n```\n\nTo recursively annotate all `*.jpg` and `*.png` images in a directory and\nparallelize the annotation to always have 4 instance of imglocate running at the\nsame time against a set of 5 images per instance (using\n[find(1)](https://netbsd.gw.com/cgi-bin/man-cgi?find+1) and\n[xargs(1)](https://netbsd.gw.com/cgi-bin/man-cgi?xargs+1)):\n\n```\n% find . \\( -iname '*.jpg' -or -iname '*.png' \\) -print0 |\n    xargs -0 -n 5 -P 4 imglocate annotate\n```\n\nGiven the simple TSV format of annotations they can be easily parsed\nvia external tools.\nFor example, to find all images with at least 5 person in it, we can\nwrite a simple AWK one-liner that does that:\n\n```\n% awk -F '\\t' '$1 == \"person\" { a[FILENAME]++ } END { for (i in a) { if (a[i] \u003e= 5) { print substr(i, 1, length(i) - 4) } } }' *.txt\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiamleot%2Fimglocate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiamleot%2Fimglocate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiamleot%2Fimglocate/lists"}