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

use Mat::Ptr in Mat.ptrAt #193

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

Much more acceptable now.

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

Attention: Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 91.17%. Comparing base (c98e506) to head (4d2f562). Report is 6 commits behind head on main.

Files Patch % Lines
lib/src/core/mat.dart 75.00% 1 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 #193 +/- ## ========================================== - Coverage 91.18% 91.17% -0.02% ========================================== Files 57 57 Lines 8394 8393 -1 ========================================== - Hits 7654 7652 -2 - Misses 740 741 +1 ```

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