Skip to content

Commit bb5407a

Browse files
author
Pashchenkov Maxim
committed
Wrapped time_step
1 parent 6926cf6 commit bb5407a

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

demos/gesture_recognition_demo/cpp_gapi/include/stream_source.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ class BatchProducer {
4747
ptr[0] = first_el; // position of start of batch in cyclic buffer
4848
batch_lock.unlock();
4949
const auto cur_step = std::chrono::steady_clock::now() - time;
50-
const auto gap = std::chrono::duration_cast<std::chrono::milliseconds>(cur_step).count();
51-
const int time_step = int(1000.f / batch_fps); // 1/15 sec
50+
const auto gap = std::chrono::duration_cast<std::chrono::milliseconds>(cur_step);
51+
const auto time_step = std::chrono::milliseconds(int(1000.f / batch_fps)); // 1/15 sec
5252
if (gap < time_step) {
53-
std::this_thread::sleep_for(std::chrono::milliseconds(time_step - gap)); // wait for constant step of batch update
53+
std::this_thread::sleep_for(time_step - gap); // wait for constant step of batch update
5454
}
5555
}
5656
private:
@@ -157,10 +157,10 @@ class CustomCapSource : public cv::gapi::wip::IStreamSource
157157
producer.fillFastFrame(fast_frame);
158158
if (wait_gap) {
159159
const auto cur_step = std::chrono::steady_clock::now() - read_time;
160-
const auto gap = std::chrono::duration_cast<std::chrono::milliseconds>(cur_step).count();
161-
const int time_step = int(1000. / source_fps);
160+
const auto gap = std::chrono::duration_cast<std::chrono::milliseconds>(cur_step);
161+
const auto time_step = std::chrono::milliseconds(int(1000.f / source_fps));
162162
if (gap < time_step) {
163-
std::this_thread::sleep_for(std::chrono::milliseconds(time_step - gap));
163+
std::this_thread::sleep_for(time_step - gap);
164164
}
165165
}
166166

0 commit comments

Comments
 (0)