{"id":16751023,"url":"https://github.com/elerac/nanobind_opencv","last_synced_at":"2025-10-30T14:24:41.610Z","repository":{"id":157836630,"uuid":"623067348","full_name":"elerac/nanobind_opencv","owner":"elerac","description":" nanobind typecaster for opencv types (i.e., cv::Mat_, cv::Matx, cv::Vec)","archived":false,"fork":false,"pushed_at":"2023-05-19T07:32:03.000Z","size":17,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-04T07:46:04.607Z","etag":null,"topics":["cpp","nanobind","opencv","python"],"latest_commit_sha":null,"homepage":"","language":"C++","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/elerac.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":"2023-04-03T16:18:27.000Z","updated_at":"2025-04-01T19:33:39.000Z","dependencies_parsed_at":"2023-06-30T15:15:09.130Z","dependency_job_id":null,"html_url":"https://github.com/elerac/nanobind_opencv","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/elerac/nanobind_opencv","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elerac%2Fnanobind_opencv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elerac%2Fnanobind_opencv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elerac%2Fnanobind_opencv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elerac%2Fnanobind_opencv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elerac","download_url":"https://codeload.github.com/elerac/nanobind_opencv/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elerac%2Fnanobind_opencv/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276033067,"owners_count":25573472,"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","status":"online","status_checked_at":"2025-09-19T02:00:09.700Z","response_time":108,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["cpp","nanobind","opencv","python"],"created_at":"2024-10-13T02:42:51.593Z","updated_at":"2025-09-20T01:58:35.399Z","avatar_url":"https://github.com/elerac.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nanobind - opencv typecaster\n\nThis repository provides a [nanobind](https://github.com/wjakob/nanobind) typecaster for opencv types.\n\nThe supported types are:\n\n- `cv::Mat_\u003c_Tp\u003e`\n- `cv::Matx\u003c_Tp, m, n\u003e`\n- `cv::Vec\u003c_Tp, n\u003e`\n\n## Build\n\n```bash\npip3 install .\n```\n\n## Example\n\nIn C++:\n\n```cpp\n#include \u003ciostream\u003e\n#include \u003cnanobind/nanobind.h\u003e\n#include \u003copencv2/core.hpp\u003e\n#include \"cv_typecaster.h\"\n\nnamespace nb = nanobind;\nusing namespace nb::literals;\n\ntemplate \u003ctypename _Tp\u003e\nvoid inspect(const cv::Mat_\u003c_Tp\u003e mat)\n{\n    std::cout \u003c\u003c \"[C++] Inspect cv::Mat_\u003c_Tp\u003e\" \u003c\u003c std::endl;\n    std::cout \u003c\u003c \"        rows: \" \u003c\u003c mat.rows \u003c\u003c std::endl;\n    std::cout \u003c\u003c \"        cols: \" \u003c\u003c mat.cols \u003c\u003c std::endl;\n    std::cout \u003c\u003c \"        channels: \" \u003c\u003c mat.channels() \u003c\u003c std::endl;\n    std::cout \u003c\u003c \"        type: \" \u003c\u003c cv::typeToString(mat.type()) \u003c\u003c std::endl;\n}\n\nNB_MODULE(_nanobind_opencv_example_impl, m)\n{\n    m.def(\"inspect\", \u0026inspect\u003cfloat\u003e, nb::arg(\"mat\").noconvert());\n}\n```\n\nIn Python:\n\n```python\nimport numpy as np\nfrom nanobind_opencv_example import inspect\n\n# Prepare numpy data\narray = np.random.rand(128, 256).astype(np.float32)\n\n# Inspect numpy data in Python\nprint(\"[Py]  Inspect np.ndarray\")\nprint(\"        shape: \", array.shape)\nprint(\"        dtype: \", array.dtype)\n\n# Pass numpy data to C++ and inspect it as cv::Mat_\u003c_Tp\u003e\ninspect(array)\n```\n\nAfter running the above example, the output should be:\n\n```\n$ python3 test.py\n[Py]  Inspect np.ndarray\n        shape:  (128, 256)\n        dtype:  float32\n[C++] Inspect cv::Mat_\u003c_Tp\u003e\n        rows: 128\n        cols: 256\n        channels: 1\n        type: CV_32FC1\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felerac%2Fnanobind_opencv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felerac%2Fnanobind_opencv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felerac%2Fnanobind_opencv/lists"}