From 097cb3fb73a1a736c47e1102d192098c2faaaa5b Mon Sep 17 00:00:00 2001 From: Florian Echtler Date: Mon, 4 Jan 2021 11:00:42 +0100 Subject: [PATCH] fix synchronization issue & file paths --- deepseg.cc | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/deepseg.cc b/deepseg.cc index 97d17d2..2b2c211 100644 --- a/deepseg.cc +++ b/deepseg.cc @@ -120,15 +120,15 @@ int main(int argc, char* argv[]) { int threads= 2; int width = 640; int height = 480; - const char *back = "background.png"; + const char *back = "images/background.png"; const char *vcam = "/dev/video0"; const char *ccam = "/dev/video1"; - const char* modelname = "deeplabv3_257_mv_gpu.tflite"; + const char* modelname = "models/segm_full_v679.tflite"; for (int arg=1; arg] [-v ] [-w ] [-h ] [-t ] [-b ]\n"); + fprintf(stderr, "usage: deepseg [-?] [-d] [-c ] [-v ] [-w ] [-h ] [-t ] [-b ] [-m ]\n"); exit(0); } else if (strncmp(argv[arg], "-d", 2)==0) { ++debug; @@ -155,6 +155,7 @@ int main(int argc, char* argv[]) { printf("height: %d\n", height); printf("back: %s\n", back); printf("threads:%d\n", threads); + printf("model: %s\n", modelname); cv::Mat bg = cv::imread(back); cv::resize(bg,bg,cv::Size(width,height)); @@ -209,17 +210,18 @@ int main(int argc, char* argv[]) { pthread_t grabber; cv::Mat buf1; cv::Mat buf2; + int64 oldcnt = 0; capinfo_t capinfo = { &cap, &buf1, &buf2, 0, PTHREAD_MUTEX_INITIALIZER }; if (pthread_create(&grabber, NULL, grab_thread, &capinfo)) { perror("creating grabber thread"); exit(1); } - // wait for first frame - while (0==capinfo.cnt) - usleep(1000); while (true) { + // wait for next frame + while (capinfo.cnt == oldcnt) usleep(10000); + oldcnt = capinfo.cnt; int e1 = cv::getTickCount(); // switch buffer pointers in capture thread @@ -274,8 +276,7 @@ int main(int argc, char* argv[]) { } // Google Meet segmentation network - if (strstr(modelname,"segm_")) { - // FIXME: not working yet + if (strstr(modelname,"segm_")) /* 256 x 144 x 2 tensor for the full model or 160 x 96 x 2 * tensor for the light model with masks for background * (channel 0) and person (channel 1) where values are in @@ -289,7 +290,6 @@ int main(int argc, char* argv[]) { float p1 = exp1 / (exp0+exp1); if (p0 < p1) out[n] = 0; else out[n] = 255; } - } // denoise cv::Mat tmpbuf;