Skip to content

Commit c290e15

Browse files
author
Pashchenkov Maxim
committed
Removed mistake
1 parent b7fd126 commit c290e15

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

demos/gesture_recognition_demo/cpp_gapi/include/stream_source.hpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class BatchProducer {
5757
}
5858
private:
5959
float batch_fps = 0; // constant FPS for batch
60-
const std::shared_ptr<bool>& drop_batch;
60+
const std::shared_ptr<bool> drop_batch; // drop parameters of batch
6161
std::vector<cv::Mat> batch; // pack of images for graph
6262
size_t first_el = 0; // place of first image in batch
6363
size_t images_in_batch_count = 0; // number of images in batch
@@ -68,8 +68,7 @@ class BatchProducer {
6868
if (images_in_batch_count < batch_size) {
6969
/** case when batch isn't filled **/
7070
return images_in_batch_count++;
71-
}
72-
else {
71+
} else {
7372
if (!is_filled) {
7473
auto ptr = batch[batch.size() - 1].ptr<uint8_t>();
7574
ptr[1] = 1;
@@ -94,10 +93,11 @@ class BatchProducer {
9493
}
9594
};
9695

97-
void runBatchFill(const cv::Mat& frame,
98-
BatchProducer& producer,
99-
std::chrono::steady_clock::time_point& time) {
100-
while (!frame.empty()) {
96+
static void runBatchFill(const cv::Mat& frame,
97+
BatchProducer& producer,
98+
std::chrono::steady_clock::time_point& time,
99+
bool& is_filling_possible) {
100+
while (is_filling_possible) {
101101
producer.fillBatch(frame, time);
102102
}
103103
}
@@ -127,14 +127,14 @@ class CustomCapSource : public cv::gapi::wip::IStreamSource {
127127
if (!fast_frame.data) {
128128
GAPI_Assert(false && "Couldn't grab the frame");
129129
}
130-
131130
producer.fillFastFrame(fast_frame);
132131
fast_frame.copyTo(thread_frame);
133132
/** Batch filling with constant time step **/
134133
std::thread fill_bath_thr(runBatchFill,
135134
std::cref(thread_frame),
136135
std::ref(producer),
137-
std::ref(read_time));
136+
std::ref(read_time),
137+
std::ref(is_filling_possible));
138138
fill_bath_thr.detach();
139139
first_batch = producer.getBatch();
140140
}
@@ -147,8 +147,9 @@ class CustomCapSource : public cv::gapi::wip::IStreamSource {
147147
bool first_pulled = false; // is first already pulled
148148
std::vector<cv::Mat> first_batch; // batch from constructor
149149
cv::Mat thread_frame; // frame for batch constant filling
150-
std::mutex thread_frame_lock;
150+
std::mutex thread_frame_lock; // lock for shared frame
151151
std::chrono::steady_clock::time_point read_time; // timepoint from cv::read()
152+
bool is_filling_possible = true; // access for batch filling
152153

153154
virtual bool pull(cv::gapi::wip::Data& data) override {
154155
/** Is first already pulled **/
@@ -165,6 +166,7 @@ class CustomCapSource : public cv::gapi::wip::IStreamSource {
165166
cv::Mat fast_frame = cap->read();
166167

167168
if (!fast_frame.data) {
169+
is_filling_possible = false;
168170
return false;
169171
}
170172

demos/gesture_recognition_demo/cpp_gapi/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ int main(int argc, char *argv[]) {
189189

190190
/** Share id with graph **/
191191
if (current_id < out_detections.size()) {
192-
*drop_batch = !(last_id != current_id);
192+
*drop_batch = last_id != current_id;
193193
*current_person_id_m = current_id;
194194
last_id = current_id;
195195
}

0 commit comments

Comments
 (0)