Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Enhance cv::TickMeter to be able to get the last elapsed time#26212

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
asmorkalov merged 1 commit intoopencv:4.xfromjamacias:feature/TickMeter-lasttime
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 32 additions & 5 deletionsmodules/core/include/opencv2/core/utility.hpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -309,11 +309,12 @@ class CV_EXPORTS_W TickMeter
//! stops counting ticks.
CV_WRAP void stop()
{
int64 time = cv::getTickCount();
constint64 time = cv::getTickCount();
if (startTime == 0)
return;
++counter;
sumTime += (time - startTime);
lastTime = time - startTime;
sumTime += lastTime;
startTime = 0;
}

Expand All@@ -336,11 +337,35 @@ class CV_EXPORTS_W TickMeter
}

//! returns passed time in seconds.
CV_WRAP double getTimeSec()const
CV_WRAP double getTimeSec() const
{
return (double)getTimeTicks() / getTickFrequency();
}

//! returns counted ticks of the last iteration.
CV_WRAP int64 getLastTimeTicks() const
{
return lastTime;
}

//! returns passed time of the last iteration in microseconds.
CV_WRAP double getLastTimeMicro() const
{
return getLastTimeMilli()*1e3;
}

//! returns passed time of the last iteration in milliseconds.
CV_WRAP double getLastTimeMilli() const
{
return getLastTimeSec()*1e3;
}

//! returns passed time of the last iteration in seconds.
CV_WRAP double getLastTimeSec() const
{
return (double)getLastTimeTicks() / getTickFrequency();
}

//! returns internal counter value.
CV_WRAP int64 getCounter() const
{
Expand DownExpand Up@@ -373,15 +398,17 @@ class CV_EXPORTS_W TickMeter
//! resets internal values.
CV_WRAP void reset()
{
startTime = 0;
sumTime = 0;
counter = 0;
sumTime = 0;
startTime = 0;
lastTime = 0;
}

private:
int64 counter;
int64 sumTime;
int64 startTime;
int64 lastTime;
};

/** @brief output operator
Expand Down
1 change: 1 addition & 0 deletionssamples/cpp/tutorial_code/snippets/core_various.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -78,6 +78,7 @@ int main()
tm.start();
// do something ...
tm.stop();
cout << "Last iteration: " << tm.getLastTimeSec() << endl;
}
cout << "Average time per iteration in seconds: " << tm.getAvgTimeSec() << endl;
cout << "Average FPS: " << tm.getFPS() << endl;
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp