rainyl / opencv_dart

OpenCV bindings for Dart language and Flutter.
https://pub.dev/packages/opencv_dart
Apache License 2.0
78 stars 10 forks source link

Face objdetect #91

Closed abdelaziz-mahdy closed 2 weeks ago

abdelaziz-mahdy commented 2 weeks ago

fixing this issue https://github.com/rainyl/opencv_dart/issues/88

i dont know how to implement the tests for the classes, so let me know if you follow example or something i can follow

codecov-commenter commented 2 weeks ago

Codecov Report

Attention: Patch coverage is 93.18182% with 6 lines in your changes missing coverage. Please review.

Project coverage is 90.28%. Comparing base (ee4f263) to head (219c78f).

Files Patch % Lines
lib/src/objdetect/objdetect.dart 93.18% 6 Missing :warning:

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #91 +/- ## ========================================== + Coverage 90.03% 90.28% +0.25% ========================================== Files 36 35 -1 Lines 5277 5334 +57 ========================================== + Hits 4751 4816 +65 + Misses 526 518 -8 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

rainyl commented 2 weeks ago

Great! I will review it later.

rainyl commented 2 weeks ago

@abdelaziz-mahdy I have added a simple test for cv.FaceDetectorYN, referring to https://docs.opencv.org/4.x/d0/dd4/tutorial_dnn_face.html and https://github.com/opencv/opencv/blob/4.x/samples/dnn/face_detect.cpp , you can add more test according to the tutorial of opencv.

It works now.

image

abdelaziz-mahdy commented 2 weeks ago

@abdelaziz-mahdy I have added a simple test for cv.FaceDetectorYN, referring to https://docs.opencv.org/4.x/d0/dd4/tutorial_dnn_face.html and https://github.com/opencv/opencv/blob/4.x/samples/dnn/face_detect.cpp , you can add more test according to the tutorial of opencv.

It works now.

image

the model "test/models/face_detection_yunet_2023mar.onnx" is missing i guess this is why the tests fail, anyway will add another test for the other class too

rainyl commented 2 weeks ago

yes, but just ignore it now, you can find the link of the models in the above link, I will add the models when finished.

abdelaziz-mahdy commented 2 weeks ago

yes, but just ignore it now, you can find the link of the models in the above link, I will add the models when finished.

when running locally

Invalid argument(s): Failed to load dynamic library 'libopencv_dart.dylib': dlopen(libopencv_dart.dylib, 0x0001): tried: 'libopencv_dart.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibopencv_dart.dylib' (no such file), '/Users/AbdelazizMahdy/Developer/flutter/bin/cache/artifacts/engine/darwin-x64/./libopencv_dart.dylib' (no such file), '/usr/local/lib/./libopencv_dart.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/lib/./libopencv_dart.dylib' (no such file), '/Users/AbdelazizMahdy/Developer/flutter/bin/cache/artifacts/engine/darwin-x64/../../../libopencv_dart.dylib' (no such file), '/Users/AbdelazizMahdy/Developer/flutter/bin/cache/artifacts/engine/darwin-x64/Frameworks/libopencv_dart.dylib' (no such file), '/Users/AbdelazizMahdy/Developer/flutter/bin/cache/artifacts/engine/darwin-x64/./libopencv_dart.dylib' (no such file), '/usr/local/lib/./libopencv_dart.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/lib/./libopencv_dart.dylib' (no such file), '/Users/AbdelazizMahdy/Developer/flutter/bin/cache/artifacts/engine/darwin-x64/../../../libopencv_dart.dylib' (no such file), '/Users/AbdelazizMahdy/Developer/flutter/bin/cache/artifacts/engine/darwin-x64/Frameworks/libopencv_dart.dylib' (no such file), '/usr/lib/libopencv_dart.dylib' (no such file, not in dyld cache), 'libopencv_dart.dylib' (no such file)
dart:ffi                                                 new DynamicLibrary.open
package:opencv_dart/src/core/base.dart 43:31             loadNativeLibrary
package:opencv_dart/src/core/base.dart 51:23             CFFI
package:opencv_dart/src/core/base.dart                   CFFI
package:opencv_dart/src/objdetect/objdetect.dart 630:15  new FaceDetectorYN.fromFile.<fn>.<fn>
package:opencv_dart/src/core/base.dart 67:22             cvRun
package:opencv_dart/src/objdetect/objdetect.dart 629:7   new FaceDetectorYN.fromFile.<fn>
package:ffi/src/arena.dart 124:31                        using
package:opencv_dart/src/objdetect/objdetect.dart 626:12  new FaceDetectorYN.fromFile
test/objdetect_test.dart 212:40                          main.<fn>

i was going to depend on ci :)

rainyl commented 2 weeks ago

https://github.com/rainyl/opencv_dart/blob/ee4f263165501347e625e6e9fd4fdf37ffc782b4/.github/workflows/build_test_release.yaml#L246

You need to add the path of libopencv_dart.dylib to DYLD_LIBRARY_PATH,

export DYLD_LIBRARY_PATH=`pwd`/macos:$DYLD_LIBRARY_PATH

or add the path to dart.env in settings.json for vscode (if you are using vscode) to make tests side menu work.

or, you can just change DYLD_LIBRARY_PATH in ~/.zshrc

abdelaziz-mahdy commented 2 weeks ago

https://github.com/rainyl/opencv_dart/blob/ee4f263165501347e625e6e9fd4fdf37ffc782b4/.github/workflows/build_test_release.yaml#L246

You need to add the path of libopencv_dart.dylib to DYLD_LIBRARY_PATH,

export DYLD_LIBRARY_PATH=`pwd`/macos:$DYLD_LIBRARY_PATH

or add the path to dart.env in settings.json for vscode (if you are using vscode) to make tests side menu work.

or, you can just change DYLD_LIBRARY_PATH in ~/.zshrc

yes i found those in cli, but i cant get it to work anyway i added a test case, logically it should work

rainyl commented 2 weeks ago

I have added an option to get OPENCV_DART_LIB_PATH, now you can define the variable to make it work.

export OPENCV_DART_LIB_PATH=`pwd`/macos/libopencv_dart.dylib
dart test test/objdetect_test.dart

But now the coverage is insufficient, more tests are required.

abdelaziz-mahdy commented 2 weeks ago

i added getters and tests for them, can you let me know what is missing, since i cant figure it from the codecov

rainyl commented 2 weeks ago

i added getters and tests for them, can you let me know what is missing, since i cant figure it from the codecov

Looks good to me, but I personally don't like the line length limitation (80 characters), so I am going to format them, then it will be merged.

Thanks for your contributions!

abdelaziz-mahdy commented 2 weeks ago

i added getters and tests for them, can you let me know what is missing, since i cant figure it from the codecov

Looks good to me, but I personally don't like the line length limitation (80 characters), so I am going to format them, then it will be merged.

Thanks for your contributions!

i use the default dart formatter, also i think you can set your own rules in file so it gets used when other people are working on it

rainyl commented 2 weeks ago

i added getters and tests for them, can you let me know what is missing, since i cant figure it from the codecov

Looks good to me, but I personally don't like the line length limitation (80 characters), so I am going to format them, then it will be merged. Thanks for your contributions!

i use the default dart formatter, also i think you can set your own rules in file so it gets used when other people are working on it

Thanks~ I will set the rules in the future. ❤️

abdelaziz-mahdy commented 2 weeks ago

also thank you for your help, i wouldnt have done it without it, i look forward to using the new modules in my app and see how it performs