{"id":17686982,"url":"https://github.com/mttgdd/openfabmap-python3","last_synced_at":"2025-03-30T20:48:55.782Z","repository":{"id":187104151,"uuid":"199474484","full_name":"mttgdd/openfabmap-python3","owner":"mttgdd","description":"Pybind11 and numpy array bindings to openFABMAP","archived":false,"fork":false,"pushed_at":"2021-06-16T14:35:05.000Z","size":204,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-05T23:58:20.376Z","etag":null,"topics":["cpp","numpy","openfabmap","pybind11","python","robotics","vision"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mttgdd.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}},"created_at":"2019-07-29T15:00:33.000Z","updated_at":"2021-06-16T14:35:08.000Z","dependencies_parsed_at":"2023-08-09T01:26:02.175Z","dependency_job_id":null,"html_url":"https://github.com/mttgdd/openfabmap-python3","commit_stats":null,"previous_names":["mttgdd/openfabmap-python3"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mttgdd%2Fopenfabmap-python3","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mttgdd%2Fopenfabmap-python3/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mttgdd%2Fopenfabmap-python3/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mttgdd%2Fopenfabmap-python3/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mttgdd","download_url":"https://codeload.github.com/mttgdd/openfabmap-python3/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246379385,"owners_count":20767696,"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":["cpp","numpy","openfabmap","pybind11","python","robotics","vision"],"created_at":"2024-10-24T10:46:36.832Z","updated_at":"2025-03-30T20:48:55.756Z","avatar_url":"https://github.com/mttgdd.png","language":"C++","readme":"# openfabmap_python3\n\nPybind11 bindings for openFABMAP as well as conversions to allow pre-loaded images as numpy arrays to be fed into the FABMAP API.\n\nThis repository was initially forked from [openfabmap-python](\u003chttps://github.com/jskinn/openfabmap-python\u003e) but pybind11 was selected to replace [boost-python](https://github.com/boostorg/python) due to Python2 reaching [end of life](https://legacy.python.org/dev/peps/pep-0373/).\n\n# Requirements\n\nThe major requirement is:\n\n* [OpenCV](https://github.com/opencv/opencv), with nonfree additions\n\nOther requirements, such as [openFABMAP](https://github.com/arrenglover/openfabmap), [pybind11](https://github.com/pybind/pybind11), and [opencv-ndarray-conversion](https://github.com/yati-sagade/opencv-ndarray-conversion/blob/master/README.md) are managed as git submodules.\n\n# Installation\n\n## Docker\n\nThere is a pre-built docker image available: https://hub.docker.com/r/matthewgadd/openfabmap-python3. This can be pulled from the registery using\n\n```bash\ndocker pull matthewgadd/openfabmap-python3:latest\n```\n\nand run using\n\n```bash\ndocker run --rm -it matthewgadd/openfabmap-python3:latest\n```\n\nOr alternatively, from within the directory `/path/to/openfabmap-python3/src/docker`, you can build the docker image from scratch:\n\n```bash\ndocker build -t matthewgadd/openfabmap-python3:latest .\n```\n\n## From source\n\nOpenCV needs to be installed separately. Once that is done, configure the install for your preferred python version.\n\n```bash\ngit clone --recurse-submodules git@github.com:mttgdd/openfabmap-python3.git src\nmkdir build\ncd build\ncmake  ../src -DPYTHON_EXECUTABLE=/usr/local/bin/python3.7\nmake -j\n```\n\n## Path\n\nFor the docker solution, path has already been set. Otherwise, when installing from source:\n\n```bash\nexport PYTHONAPTH=$PYTHONPATH:/path/to/openfabmap-python3/build/lib\n```\n\n## Test installation\n\nTest the installation and path setup were successful as follows:\n\n```bash\npython -c \"import openfabmap_python3\"\n```\n\n# Usage Instructions\n\n## Loading the bindings\n\nOpen an interactive python session from within the installation directory for this library:\n\n```bash\ncd build/lib\npython\n```\n\nThen, the binding module can be imported:\n\n```python\n\u003e\u003e\u003e import openfabmap_python3 as of\n```\n\n## Configuration\n\nThe wrapper methods are configured by a Python dictionary, an example of which is shown below:\n\n```python\n\u003e\u003e\u003e SETTINGS = dict()\n\u003e\u003e\u003e SETTINGS[\"VocabTrainOptions\"] = dict()\n\u003e\u003e\u003e SETTINGS[\"VocabTrainOptions\"][\"ClusterSize\"] = 0.45\n```\n\n## Image Manipulation\n\nYou have a variety of options in delegating image manipulation and feature extraction to OpenCV's native C++ methods or precomputed from your Python routine. In the first case (where for example you are adding a training image to the vocabulary builder):\n\n```python\n\u003e\u003e\u003e png_file = \"example.png\"\n\u003e\u003e\u003e vb.load_and_add_training_image(png_file)\n```\n\nIn the second case (once again adding a training image to the vocabulary) we use the numpy array convertors of [opencv-ndarray-conversion](https://github.com/yati-sagade/opencv-ndarray-conversion/blob/master/README.md): \n\n```python\n\u003e\u003e\u003e from PIL import Image\n\u003e\u003e\u003e png_file = \"example.png\"\n\u003e\u003e\u003e img = Image.open(image_file)\n\u003e\u003e\u003e vb.add_training_image(img)\n```\n\nThis functionality allows image manipulation in Python prior to feature extraction (e.g. cropping, rotating, etc), or even feature extraction in Python, as follows:\n\n```python\n\u003e\u003e\u003e import cv2\n\u003e\u003e\u003e import numpy as np\n\u003e\u003e\u003e orb = cv2.ORB_create(nfeatures=1500)\n\u003e\u003e\u003e _, descriptors = orb.detectAndCompute(cv2.imread(png_file, cv2.IMREAD_GRAYSCALE), None)\n\u003e\u003e\u003e vb.add_training_descs(np.asarray(descs))\n```\n\n## Building a vocabulary\n\nThe wrapper for building a vocabulary is configured and initialised using a dictionary:\n\n```python\n\u003e\u003e\u003e vb = of.VocabularyBuilder(SETTINGS)\n```\n\nThen, add a number of images to the vocabulary using ```add_training_image```, ```load_and_add_training_image```, ```add_training_descs``` before building the vocabulary:\n\n```python\n\u003e\u003e\u003e vb.build_vocabulary() \n```\n\nNote that in the case you wish to use the native C++ feature extraction you should perform ```vb.initDetectorExtractor()``` and prepare the ```SETTINGS``` dictionary appropriately.\nLikewise ```add_training_image```, ```load_and_add_training_image```, or ```add_training_descs``` are then used to populate the Chowliu tree structures before that model is built:\n\n```python\n# inspect the ctor in ChowLiuTree.cpp to see which configuration parameters are required\n\u003e\u003e\u003e clt = of.ChowLiuTree(SETTINGS)\n\u003e\u003e\u003e clt.build_chow_liu_tree()\n```\n\nFinally, the model (including the vocabulary) can be saved to disk using ```save``` (and indeed loaded from disk using ```load```).\n\n# References\n\n* \u003chttps://github.com/arrenglover/openfabmap\u003e\n* \u003chttps://github.com/jskinn/openfabmap-python\u003e\n* \u003chttps://github.com/pybind/pybind11\u003e\n* \u003chttps://github.com/yati-sagade/opencv-ndarray-conversion/blob/master/README.md\u003e\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmttgdd%2Fopenfabmap-python3","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmttgdd%2Fopenfabmap-python3","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmttgdd%2Fopenfabmap-python3/lists"}