Giter Site home page Giter Site logo

adityamulgundkar / flutter_opencv Goto Github PK

View Code? Open in Web Editor NEW
124.0 124.0 55.0 453 KB

Flutter plug-in providing (a few) basic bindings to OpenCV-4.x. OpenCV methods implemented without the Core packages. WIP.

Home Page: https://pub.dev/packages/opencv

License: Other

Java 48.29% Objective-C 1.64% Dart 49.11% Ruby 0.96%
android dart flutter flutter-plugin opencv pubdev

flutter_opencv's People

Contributors

adityamulgundkar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

flutter_opencv's Issues

[BUG] I/System.out(11892): OpenCV Error: java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.Integer

Describe the bug
the following error occurs when using the warpPerspectiveTransform function
I/System.out(11892): OpenCV Error: java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.Integer

To Reproduce

Future<dynamic> WarpPerspective() async {
    Uint8List image = widget.file.readAsBytesSync();
    List<dynamic> sourcepoints = [
      tl_x,
      tl_y,
      tr_x,
      tr_y,
      bl_x,
      bl_y,
      br_x,
      br_y
    ];
    double tld_x = widget.tl.dx;
    double tld_y = widget.tl.dy;
    double trd_x = widget.tr.dx;
    double trd_y = widget.tr.dy;
    double bld_x = widget.bl.dx;
    double bld_y = widget.bl.dy;
    double brd_x = widget.br.dx;
    double brd_y = widget.br.dy;
    List<dynamic> destinationpoints = [
      tld_x,
      tld_y,
      trd_x,
      trd_y,
      bld_x,
      bld_y,
      brd_x,
      brd_y
    ];
    List<double> size = [100.0, 200.0];
    print(sourcepoints);
    print(destinationpoints);
    var bytesArray = await ImgProc.warpPerspectiveTransform(image,
        sourcePoints: sourcepoints,
        destinationPoints: destinationpoints,
        outputSize: size);
    setState(() {
      bytes = bytesArray;
    });
    return await bytesArray;
  }

Linux support

Is the requested feature available in the C++/Java/Python interfaces for OpenCV?
Yes, OpenCV supports Linux.

Describe the solution you'd like
I would like to use OpenCV in Flutter apps for Linux. Flutter supports Linux as a platform, would be great to be able use OpenCV in Linux Flutter apps.

Describe alternatives you've considered
An alternative might be to implement the web version instead (using WebAssembly or OpenCV.js. It would be just as accessible to Linux users; however, it would seem to be more complex to implement.

Add support of Hough Lines

In my project, I would need line detection. Therefore it would be awesome if you could extend the library with the houghLines-function as you already did with the houghCirlces-function.

The feature is implemented in the Andoird/IOS/Python libraries of open OpenCV (here) and allows detecting lines.
A solution should look like the pictures described in their documentation.

Edge detection and crop

Is there a plan to add edge detection and crop images?
I am working on an application to take a photo of an ID or document, automatically detect the edges and crop the image.

Regards

Please add the Findcontour feature

Is the requested feature available in the C++/Java/Python interfaces for OpenCV?
If yes, please describe the function/method & class that contains the feature. If not, please explain why Flutter/Dart requires said feature nonetheless.

Describe the solution you'd like
A clear and concise description of what you want to happen. Provide links to existing documentation, if possible.

Describe alternatives you've considered
Have you tried any alternative solutions? If yes, please provide links to the same. If not, can the same feature be achieved by cascading the existing set of effects/methods available in the latest build?

Additional context
Add any other context or screenshots about the feature request here.

Extract frames from a video

Is the requested feature available in the C++/Java/Python interfaces for OpenCV?
Yes.

# Python
cap = cv2.VideoCapture(Video_path)
while True:
    ok, frame_image = cap.read()

Describe the solution you'd like
Some way to extract the frames of the video in a loop similar to above implementation.

Describe alternatives you've considered
No alternatives found till now.

[BUG] Function calls block main UI thread

The function calls are futures, but they still block the main UI thread causing jank, frozen app.

Steps to reproduce the behavior:

  1. Load a bigger image as Uint8List. The bigger the image, the longer the freezing time.
  2. Use on this any of the ImgProc methods, ex ImgProc.resize, ImgProc.blur
  3. See freeze

Expected behavior
The method call shouldn't block the main UI thread.

Additional context
If the methods would be sync calls we could use compute, isolates avoiding this issue.

Consider using null safety

Describe the solution you'd like
It would be useful, if this library would use sound null safety, like basically every new library does nowadays.
This is annoying since flutter forces you to explicitly disable null safety, if ANY dependency does not use it, which means that all the work that I already put in, to make my code null safe is completely invalidated by this library.

Describe alternatives you've considered
I have considered using other dependencies such as opencv_4, however none of the dependencies support the feature that I need (warpPerspectiveTransform).

Questions about HoughCircle API

Hi, thank you for your great works. I'm a student currently doing a university project to perform Iris and pupil detection for covid patients. For HoughCircle API, could I ask whether there's any way to get the detected circles' radius only instead of the whole processed output picture?

Add basic examples for function cascading/successive functions

Verbatim from the project README:
Since you're never going to just implement one function, there's a need to be able to cascade. Inputs & outputs to all functions are common - byte arrays. Hence output from one function can directly be fed to the next.

This means that all functions take the same byte arrays (exceptions include functions that need a grayscale image instead of a binary one, but the grayscale image too is in a byte array form!), e.g. houghCircles. In general, in OpenCV, a lot can be achieved by using 2-3 different functions in succession. For example, something as simple as Canny edge detection (https://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_imgproc/py_canny/py_canny.html) would require one to convert the source image to grayscale, then apply some blur to it, then run the Canny function.

Find any good use case for the same and add your function to the examples in example/lib/main.dart which showcases the demo app.

To add an example to the app:

  • Simply add a new switch case in runAFunction
  • Add the string calling this function in the Dropdown Widget
    After you do this, every time someone selects your new function name from the dropdown and clicks on run, your own cascaded/successive function(s) run in the runAFunction method and throw an output image.

OpenCV's HoughCircles API.

I have a requirement to use hough transform to detect circles. How can I do that with opencv? OpenCV's HoughCircles API.

Hi. Could you add cv2.inRange func please? Thanks a lot!! By the way flutter_opencv package is excellent!!!

Is the requested feature available in the C++/Java/Python interfaces for OpenCV?
If yes, please describe the function/method & class that contains the feature. If not, please explain why Flutter/Dart requires said feature nonetheless.

Describe the solution you'd like
A clear and concise description of what you want to happen. Provide links to existing documentation, if possible.

Describe alternatives you've considered
Have you tried any alternative solutions? If yes, please provide links to the same. If not, can the same feature be achieved by cascading the existing set of effects/methods available in the latest build?

Additional context
Add any other context or screenshots about the feature request here.

Image Stitching

Does this plugin support image stitching (horizontal and vertical)?

Windows Desktop Support

Is the requested feature available in the C++/Java/Python interfaces for OpenCV?
Yes, OpenCV Support of Windows, and even backed by Microsoft.

Describe the solution you'd like
As Flutter expands its support for more platforms, camera access on the Windows desktop platform is becoming a challenge, and to write a plugin we need OpenCV integration, which is a much more complex process, thus camera operations are the main concern for the request.

Describe alternatives you've considered
So far there are no packages in Flutter supporting camera support for Windows Desktop, and I have tried to create a plugin with OpenCV integration, which is very time-consuming as I am not from a C++ background.

Need some guidance in adding bindings for `grabCut`

Is the requested feature available in the C++/Java/Python interfaces for OpenCV?
It is available in OpenCV and the bindings for Python and Java, example: https://www.docs.opencv.org/trunk/d7/d1b/group__imgproc__misc.html#ga909c1dda50efcbeaa3ce126be862b37f

I need it for a pet project I'm working on, and overall I think it would be beneficial to have it in flutter_opencv because it will make the bindings more complete.

I've followed the guidelines in the readme and here is my current draft implementation: #7

Note that I've hardcoded some of the things (number of iterations, the rectangle, etc.) because I am just exploring the feasibility of this approach. Although the code runs without an error, the result is a black image.

grabCut is a bit tricky, because it uses an InputOutputArray variable, which is not featured in any of the existing wrapper-functions and is not mentioned in the readme either. Something might be odd with dst, perhaps it has to be initialized somehow.

@AdityaMulgundkar, can you provide some guidance? Your assistance would be greatly appreciated, thank you forward.

Why not use dart:ffi?

The android and ios versions are just wrappers over opencv c++ library. Won't it be beneficial if you can use dart:ffi to create bindings directly to c++. That way you won't have to deal with writing platform specific codes, and at the same time make your library work with not just android and ios, but also on desktop platforms.

crop,rotate,normalize functionality

Is the requested feature available in the C++/Java/Python interfaces for OpenCV?
Yes, It is available in Opencv Python direct function available cv2.rotate or cv2.crop

Describe the solution you'd like
Here crop,rotate shall have direct function like others we have.

Can you guide me, how can I implement it in my own.

Document usage of functions in the official documentation

Currently, we have no documentation of the existing functions, but they are demonstrated in the examples at example/lib/main.dart under the runAFunction method.

Write base level documentation for the same in Sphinx, in the doc/source/index.rst file. Making changes to this file (or the files in this directory) will directly affect the documentation generated at https://flutter-opencv.readthedocs.io/en/latest/

Just fork the code; write the documentation; send across a pull request to this repository. Once the request is accepted, the documentation pages will rebuild. (i.e. you might want to run Sphinx locally in order to ensure everything works fine, but this is an extra step).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.