rainyl / opencv_dart

OpenCV bindings for Dart language and Flutter. Support Asynchronous Now!
https://pub.dev/packages/opencv_dart
Apache License 2.0
136 stars 18 forks source link

added more tests #186

Closed abdelaziz-mahdy closed 3 months ago

abdelaziz-mahdy commented 3 months ago

note: i converted matype to class to avoid errors that was showing in the test files Extension type methods can't be used in constant expressions.dart(const_eval_extension_type_method) also using that i was able to add toString

hope thats okay.

rainyl commented 3 months ago

note: i converted matype to class to avoid errors that was showing in the test files Extension type methods can't be used in constant expressions.dart(const_eval_extension_type_method)

hope thats okay.

Please don't. I changed it to extension type to make it simple and act as a wrapper for int.

dart Enum is not suitable for FFI, extension type won't create extra objects in the runtime, so the instances of MatType are just int, which I think may be a little bit more efficient. The reason why it was designed is that Mat.type has to be called from native every time at<>() and set<>() are called for now (I am looking for a proper way to cache it), for large mat, getting such values and construct it to a class will be slower than just use int, at least in my point of view.

And ignore the error, it's just a linter bug https://github.com/dart-lang/sdk/issues/59486 .

Edit: Actually Mat.forEachPixel and Mat.forEachRow are designed for efficient iteration to replace at and set in some cases.

abdelaziz-mahdy commented 3 months ago

Okay sorry, I will revert that change, I was confused why it showed me errors but didn't throw any when running the test cases

Anyway I will check the interface stuff after a while since I will be busy the next two weeks, it may help with implementing the ml module so I will make it to help finish the modules not yet implemented

rainyl commented 3 months ago

Okay sorry, I will revert that change, I was confused why it showed me errors but didn't throw any when running the test cases

Never mind, I didn't explain it in the source code.

Anyway I will check the interface stuff after a while since I will be busy the next two weeks, it may help with implementing the ml module so I will make to help finish the modules not yet implemented

Great! Just do it when you have some time. 😄

BTW, why are you insist on using the ml module from opencv? If you are working on deploying machine/deep learning models, TFLite, onnxruntime and other frameworks may be a better choice, I am not active to support ML module because the models provided by opencv ML module are very limited, I would prefer python scikit-learn to train machine learning models.

abdelaziz-mahdy commented 3 months ago

Okay sorry, I will revert that change, I was confused why it showed me errors but didn't throw any when running the test cases

Never mind, I didn't explain it in the source code.

Anyway I will check the interface stuff after a while since I will be busy the next two weeks, it may help with implementing the ml module so I will make to help finish the modules not yet implemented

Great! Just do it when you have some time. 😄

BTW, why are you insist to use the ml module from opencv? If you are working on deploying machine/deep learning models, TFLite, onnxruntime and other frameworks may be a better choice, I am not active to support ML module because the models provided by opencv ML module are very limited, I would prefer python scikit-learn to train machine learning models.

well i dont plan to use it, i once wanted to make the opencv binding but failed due to not understanding how it can be done, nor did i find any source, so when i saw your work and how you do it cleanly i thought why not make this the opencv binding for dart.

also opencv 5 should be a major rework where they will improve alot of stuff for ai so i think opencv still has some uses

for tflite on flutter desktop binaries has to be compiled not automated like how you did it

pytorch doesnt support desktop

i understand that most training of the models will be done on python since its the leading platform, but if dart can cover needs for inference that will help with serverside and frontend deployments.

edit: if the ml module is only for training then as i mentioned i agree with you that it will not be needed

rainyl commented 3 months ago

Get it.