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

export Mat properies as leaf functions #191

Closed rainyl closed 3 months ago

rainyl commented 3 months ago

fix: #190

test Code ```dart import 'package:opencv_dart/opencv_dart.dart' as cv; void main(List args) { final mat = cv.Mat.zeros(3840, 2160, cv.MatType.CV_32SC3); final sw = Stopwatch(); { sw.reset(); sw.start(); for (var row = 0; row < mat.rows; row++) { for (var col = 0; col < mat.cols; col++) { mat.at(row, col); } } sw.stop(); print('Mat(${mat.rows}, ${mat.cols}, ${mat.channels}).at: ${sw.elapsedMilliseconds}ms'); } { var currentPix = 0; mat.set(mat.rows - 1, mat.cols - 1, cv.Vec3i(241, 241, 241)); sw.reset(); sw.start(); mat.forEachPixel((_, __, pix) => currentPix = pix[0].toInt()); sw.stop(); print('Mat(${mat.rows}, ${mat.cols}, ${mat.channels}).iterPixel At: ${sw.elapsedMilliseconds}ms'); } { sw.reset(); sw.start(); for (var row = 0; row < mat.rows; row++) { for (var col = 0; col < mat.cols; col++) { mat.set(row, col, 1); } } sw.stop(); print('Mat(${mat.rows}, ${mat.cols}, ${mat.channels}).set: ${sw.elapsedMilliseconds}ms'); } { sw.reset(); sw.start(); mat.forEachPixel((_, __, pix) => pix[0] = 241); sw.stop(); print('Mat(${mat.rows}, ${mat.cols}, ${mat.channels}).iterPixel set: ${sw.elapsedMilliseconds}ms'); } } ```
item isLeaf=false isLeaf=true isLeaf=true + uchar *Mat_Ptr_u8() isLeaf=true + native-assets isLeaf=true + native-assets + uchar *Mat_Ptr_u8()
at 691ms 561ms 325ms 472ms 301ms
forEachPixel At 177ms 176ms 179ms 184ms 183ms
set 556ms 430ms 267ms 437ms 245ms
forEachPixel Set 175ms 162ms 177ms 179ms 175ms
codecov-commenter commented 3 months ago

:warning: Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 91.18%. Comparing base (22318bb) to head (c98e506). Report is 5 commits behind head on main.

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

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #191 +/- ## ======================================= Coverage 91.18% 91.18% ======================================= Files 57 57 Lines 8394 8394 ======================================= Hits 7654 7654 Misses 740 740 ```

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