Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the performance of at and set, add Mat.atU8, Mat.setU8, etc. #58

Merged
merged 1 commit into from
May 17, 2024

Conversation

rainyl
Copy link
Owner

@rainyl rainyl commented May 17, 2024

Releated:

simple perf test:

Mat(3840, 2160, CV_8UC1).at: 6937ms
Mat(3840, 2160, CV_8UC1).atU8: 4701ms
Mat(3840, 2160, CV_8UC1).set: 6188ms
Mat(3840, 2160, CV_8UC1).setU8: 3124ms

Maybe faster with Native Assets:

00:10 +305 ~2: test\core\mat_test.dart: Mat at set perf
Mat(3840, 2160, CV_8UC1).at: 6394ms
Mat(3840, 2160, CV_8UC1).atU8: 4512ms
Mat(3840, 2160, CV_8UC1).set: 5258ms
Mat(3840, 2160, CV_8UC1).setU8: 2829ms

at: Mat.atU8, Mat.atI8, Mat.atU16, Mat.atI16, Mat.atI32, Mat.atF32, Mat.atF64

set: Mat.setU8, Mat.setI8, Mat.setU16, Mat.setI16, Mat.setI32, Mat.setF32, Mat.setF64

Mat.set support native types, e.g., Mat.set<cv.U8>()

In previous version, determine the Mat type is very expensive, but considering the mat type may change after creation, so it has to be get from native pointer, which costs lots of time, so for performance sensitive occasions, use atU8/setU8-like API.

@rainyl rainyl linked an issue May 17, 2024 that may be closed by this pull request
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 81.44330% with 18 lines in your changes are missing coverage. Please review.

Project coverage is 88.76%. Comparing base (66fa454) to head (f24dab0).

Files Patch % Lines
lib/src/core/mat.dart 81.44% 18 Missing ⚠️

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

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #58      +/-   ##
==========================================
+ Coverage   88.65%   88.76%   +0.11%     
==========================================
  Files          34       34              
  Lines        4777     4789      +12     
==========================================
+ Hits         4235     4251      +16     
+ Misses        542      538       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@rainyl rainyl merged commit 97a7d1d into main May 17, 2024
1 check passed
@rainyl rainyl deleted the at-set-perf branch May 18, 2024 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

More efficient at<T>() and set<T>()?
2 participants