Skip to content

[G-API]: Performance tests for KalmanFilter#19712

Merged
alalek merged 5 commits intoopencv:masterfrom
OrestChura:oc/Kalm_ptest
Mar 26, 2021
Merged

[G-API]: Performance tests for KalmanFilter#19712
alalek merged 5 commits intoopencv:masterfrom
OrestChura:oc/Kalm_ptest

Conversation

@OrestChura
Copy link
Copy Markdown
Contributor

  • Performance tests for KalmanFilter stateful operation added
  • Accuracy test misprint fixed and a little refactoring applied
  • A bug with changing KalmanParams due to non-copy assignment in KalmanFilter::setup() fixed

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or other license that is incompatible with OpenCV
  • The PR is proposed to proper branch
  • There is reference to original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake
force_builders=Custom
build_gapi_standalone:Linux x64=ade-0.1.1f
build_gapi_standalone:Win64=ade-0.1.1f
build_gapi_standalone:Mac=ade-0.1.1f
build_gapi_standalone:Linux x64 Debug=ade-0.1.1f

build_image:Custom=centos:7
buildworker:Custom=linux-1
build_gapi_standalone:Custom=ade-0.1.1f

xbuild_image:Custom=ubuntu-openvino-2021.1.0:20.04
xbuild_image:Custom Win=openvino-2021.1.0
xbuild_image:Custom Mac=openvino-2021.1.0

test_modules:Custom=gapi
test_modules:Custom Win=gapi
test_modules:Custom Mac=gapi

# disabled due high memory usage: test_opencl:Custom=ON
test_opencl:Custom=OFF
test_bigdata:Custom=1
test_filter:Custom=*

@OrestChura
Copy link
Copy Markdown
Contributor Author

@aDanPin please review

@OrestChura OrestChura requested a review from mpashchenkov March 11, 2021 15:15
@mpashchenkov mpashchenkov changed the title [G-API]: Performance tests for KalmenFilter [G-API]: Performance tests for KalmanFilter Mar 11, 2021
Copy link
Copy Markdown
Contributor

@mpashchenkov mpashchenkov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First wave. Superficially.

@OrestChura
Copy link
Copy Markdown
Contributor Author

@anna-khakimova please take a look

@OrestChura OrestChura force-pushed the oc/Kalm_ptest branch 2 times, most recently from c384aab to 9f43032 Compare March 12, 2021 13:18
Copy link
Copy Markdown
Contributor

@mpashchenkov mpashchenkov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2

@OrestChura OrestChura requested a review from mpashchenkov March 18, 2021 10:09
@anna-khakimova
Copy link
Copy Markdown
Member

Looks good. Approved 👍

PERF_TEST_P_(KalmanFilterControlPerfTest, TestPerformance)
{
MatType2 type = -1;
int dDim = -1, mDim = -1;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

double space

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, thanks!
Fixed

Copy link
Copy Markdown
Contributor

@mpashchenkov mpashchenkov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good for me. Thanks.

@OrestChura
Copy link
Copy Markdown
Contributor Author

@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));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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++)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::size_t

Just size_t

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are both defined in OpenCV scope and have the same meaning.

Function parameter declared as size_t testNumMeasurements, need to be consistent.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, got it
Fixed

Comment on lines +339 to +344
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();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment on lines +275 to +278
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));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the same

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@alalek alalek merged commit ad2f5cc into opencv:master Mar 26, 2021
@alalek alalek mentioned this pull request Apr 9, 2021
a-sajjad72 pushed a commit to a-sajjad72/opencv that referenced this pull request Mar 30, 2023
[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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants