[G-API]: Performance tests for KalmanFilter#19712
Conversation
|
@aDanPin please review |
mpashchenkov
left a comment
There was a problem hiding this comment.
First wave. Superficially.
|
@anna-khakimova please take a look |
c384aab to
9f43032
Compare
|
Looks good. Approved 👍 |
| PERF_TEST_P_(KalmanFilterControlPerfTest, TestPerformance) | ||
| { | ||
| MatType2 type = -1; | ||
| int dDim = -1, mDim = -1; |
There was a problem hiding this comment.
You're right, thanks!
Fixed
a7d56ea to
0f86395
Compare
mpashchenkov
left a comment
There was a problem hiding this comment.
Looks good for me. Thanks.
|
@alalek I believe on our side we are ready to merge this |
| std::vector<cv::Mat>& measurements) | ||
| { | ||
| cv::RNG& rng = cv::theRNG(); | ||
| measurements = std::vector<cv::Mat>(testNumMeasurements, cv::Mat::zeros(mDim, 1, type)); |
There was a problem hiding this comment.
This statement looks wrong and must be avoided.
cv::Mat are not cloned here. All of them points to the same .data.
So initialization below through randu() just rewrites data in all affected containers.
There was a problem hiding this comment.
Yes, thank you! A bad mistake
Fixed
| cv::RNG& rng = cv::theRNG(); | ||
| measurements = std::vector<cv::Mat>(testNumMeasurements, cv::Mat::zeros(mDim, 1, type)); | ||
| haveMeasurements = std::vector<bool>(testNumMeasurements, true); | ||
| for (std::size_t i = 0; i < testNumMeasurements; i++) |
There was a problem hiding this comment.
OK
May I ask, is it an OpenCV convention, or it's just about this particular case for consistency of a function/file?
In any case, I perhaps can search through gapi-code to fix inconsistencies in a separate PR
There was a problem hiding this comment.
They are both defined in OpenCV scope and have the same meaning.
Function parameter declared as size_t testNumMeasurements, need to be consistent.
There was a problem hiding this comment.
OK, got it
Fixed
| MatType2 type = -1; | ||
| int dDim = -1, mDim = -1; | ||
| std::size_t testNumMeasurements = 0; | ||
| bool receiveRandMeas = true; | ||
| cv::GCompileArgs compileArgs; | ||
| std::tie(type, dDim, mDim, testNumMeasurements, receiveRandMeas, compileArgs) = GetParam(); |
There was a problem hiding this comment.
BTW, This approach doesn't make code cleaner.
Just brings unnecessary pre-initialization with -1, 0, true, etc
const auto& param = GetParam();
MatType2/*or auto*/ type = get<0>(param);
const auto dDim = get<1>(param);
const auto mDim = get<1>(param);
...
/cc @dmatveev
There was a problem hiding this comment.
Hm, I agree it's inconvenient about pre-initialization, and variables aren't const.
But std::tie is more "secure" in a way that you can be sure you've got all the data from GetParam and haven't forgotten anything. In case of changing the parameters (adding ones at the end) there will be no errors. Something like that @dmatveev has explained me some time ago
| ctrls = std::vector<cv::Mat>(testNumMeasurements, cv::Mat(cDim, 1, type)); | ||
| for (std::size_t i = 0; i < testNumMeasurements; i++) | ||
| { | ||
| cv::randu(ctrls[i], cv::Scalar::all(-1), cv::Scalar::all(1)); |
[G-API]: Performance tests for KalmanFilter * Kalman perf.tests and some tests refactoring * Input generation moved to a separate function; Slowest case sneario testing added * Generating refactored * Generating refactoring * Addressing comments
Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.