@@ -170,7 +170,7 @@ typedef struct {
170
170
timinginfo_t *pti;
171
171
pthread_mutex_t lock_raw;
172
172
pthread_mutex_t lock_mask;
173
- pthread_cond_t condition_new_frame ;
173
+ bool new_frame ;
174
174
bool running;
175
175
} calcinfo_t ;
176
176
@@ -212,7 +212,7 @@ void init_tensorflow(calcinfo_t &info) {
212
212
213
213
info.lock_raw = PTHREAD_MUTEX_INITIALIZER;
214
214
info.lock_mask = PTHREAD_MUTEX_INITIALIZER;
215
- info.condition_new_frame = PTHREAD_COND_INITIALIZER ;
215
+ info.new_frame = false ;
216
216
info.running = false ;
217
217
218
218
info.raw_next = &info.buf1 ;
@@ -223,12 +223,16 @@ void calc_mask(calcinfo_t &info) {
223
223
timestamp_t t = timestamp ();
224
224
cv::Mat *raw_tmp;
225
225
226
- // change frame buffer pointer
227
- pthread_mutex_lock (&info.lock_raw );
226
+ // wait for new frame to arrive
228
227
timestamp_t t0 = timestamp ();
229
- pthread_cond_wait (&info.condition_new_frame , &info.lock_raw ); // wait for new frame to arrive
228
+ while (!info.new_frame ) {
229
+ usleep (1000 );
230
+ }
230
231
info.pti ->ai_condns = diffnanosecs (timestamp (), t0);
231
232
t0 = timestamp ();
233
+ // change frame buffer pointer
234
+ pthread_mutex_lock (&info.lock_raw );
235
+ info.new_frame = false ;
232
236
raw_tmp = info.raw_next ;
233
237
info.raw_next = info.raw_current ;
234
238
info.raw_current = raw_tmp;
@@ -525,7 +529,7 @@ int main(int argc, char* argv[]) {
525
529
pthread_mutex_lock (&calcinfo.lock_raw );
526
530
ti.lockns =timestamp ();
527
531
*calcinfo.raw_next = raw.clone ();
528
- pthread_cond_signal (& calcinfo.condition_new_frame ) ;
532
+ calcinfo.new_frame = true ;
529
533
pthread_mutex_unlock (&calcinfo.lock_raw );
530
534
ti.copyns =timestamp ();
531
535
0 commit comments