rainyl / opencv_dart

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

More efficient at<T>() and set<T>()? #53

Closed rainyl closed 4 months ago

rainyl commented 4 months ago

Discussed in https://github.com/rainyl/opencv_dart/discussions/44

Originally posted by **msmartin4470** May 8, 2024 What is the best way to loop though a Mat in dart? In C I did this using pointers as follows. Thanks in advance. ``` for (int i = 0; i < mat.rows; i++) { uint16_t* matRow = mat.ptr(i); for (int j = 0; j < mat.cols; j++) { uint16_t value = matRow[j]; matRow[j] = lut.at(value); } } ```
rainyl commented 4 months ago

Releated:

rainyl commented 4 months ago

Confirmed, current at() and set() is very slow, explicitly povide type like at or atU8 will improve the performance significantly.