{"id":15519259,"url":"https://github.com/alnitak/flutter_ffi_opencv","last_synced_at":"2025-04-23T04:39:08.803Z","repository":{"id":158861606,"uuid":"275366093","full_name":"alnitak/flutter_ffi_opencv","owner":"alnitak","description":"Test OpenCV in Flutter using dart:ffi","archived":false,"fork":false,"pushed_at":"2020-06-27T12:33:51.000Z","size":697,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-29T22:11:23.987Z","etag":null,"topics":["dart","ffi","flutter","flutter-plugin","opencv"],"latest_commit_sha":null,"homepage":"","language":"CMake","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/alnitak.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2020-06-27T12:18:24.000Z","updated_at":"2025-01-11T21:07:57.000Z","dependencies_parsed_at":null,"dependency_job_id":"c104d8d8-8790-407e-b51e-414652d9f375","html_url":"https://github.com/alnitak/flutter_ffi_opencv","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/alnitak%2Fflutter_ffi_opencv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alnitak%2Fflutter_ffi_opencv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alnitak%2Fflutter_ffi_opencv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alnitak%2Fflutter_ffi_opencv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alnitak","download_url":"https://codeload.github.com/alnitak/flutter_ffi_opencv/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250372692,"owners_count":21419720,"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":["dart","ffi","flutter","flutter-plugin","opencv"],"created_at":"2024-10-02T10:20:47.456Z","updated_at":"2025-04-23T04:39:08.780Z","avatar_url":"https://github.com/alnitak.png","language":"CMake","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ffi_opencv\n\nPlugin to use OpenCV with dart:ffi\n\n## Getting Started\n\nDownload OpenCV sources for Android from\n[here](https://opencv.org/releases/),\nthen edit **android/CMakeLists.txt** to point **OPENCV_DIR** variable to the unzipped OpenCV path.\n\nBy subclassing ImgProc to add a new image filter, you should averride *compute()* or *computeSync()* or both.\n\n**compute()** is used by *OpenCVImageProvider* asynchronously. That means that the image is read and decompressed every time it is needed by *OpenCVImageProvider*.\n\n**computeSync()** calls the C filter with an already loaded image cv::Mat. Use *preloadUriImage()* or *preloadBytesImage()* to store the iamge before calling *computeSync()*.\n\nBy now there are only 2 image proc filters: *blur* and *dilate*.\n\n#\n***using OpenCVImageProvider***\n```\nImage(\n      image: OpenCVImageProvider(\n        'assets/solar-system.jpg', // only assets images for now\n        [ // list of filters\n          Dilate(kernelSize: 9),\n          Blur(kernelSize: 15),\n        ]\n  )),\n)\n```\n***using computeSync()***  \ndefine your subclassed ImgProc classes:\n\n```\n  Blur _blur;\n  Dilate _dilate;\n\n  @override\n  void initState() {\n    super.initState();\n    _blur = Blur();\n    _dilate = Dilate();\n    _init();\n  }  \n```\nthe *_init()* method is used to preload asynchronously the image into the first to process ImgProc class:\n```\n  _init() async{\n    // when using ImgProc.computeSync(), we must use Blur.preloadImage() before\n    await _blur.preloadUriImage('assets/solar-system.jpg');\n\n    setState(() {\n      canBuild = true;\n    });\n  }\n```\nwhen done, the *build()* can be called.\n\n\nThe preloaded image is processed by *Blur* and the resulting image bytes are then passed to *Dilate* to be processed.\n```\nWidget _computeFilters() {\n    Uint8List bytes = _blur.computeSync().bytes;\n\n    if (bytes != null) {\n      // feed dilate with the output of blur\n      _dilate.preloadBytesImage(bytes);\n      bytes = _dilate.computeSync().bytes;\n    }\n\n    if (bytes != null)\n      return Image.memory(bytes);\n\n    return Container(child: Text('Image filter error'));\n  }\n```\n\n#### issues\nSometimes the 2nd *computeSync()* returns wrong image bytes.  \nOn my Asus Zenfone there is some kind of about freeing pointer.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falnitak%2Fflutter_ffi_opencv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falnitak%2Fflutter_ffi_opencv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falnitak%2Fflutter_ffi_opencv/lists"}