Skip to content

Commit 92e80a0

Browse files
committed
Allow for per-frame setting of multi-pass processing
1 parent 5e5099d commit 92e80a0

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

app/calcmask.cc

+3-1
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,12 @@ CalcMask::~CalcMask() {
4444
bs_maskgen_delete(maskctx);
4545
}
4646

47-
void CalcMask::set_input_frame(cv::Mat &frame) {
47+
void CalcMask::set_input_frame(const cv::Mat &frame, bool multipass) {
4848
std::lock_guard<std::mutex> hold(lock_frame);
4949

5050
*frame_next = frame.clone();
51+
this->multipass = multipass;
52+
5153
new_frame = true;
5254
condition_new_frame.notify_all();
5355
}

app/calcmask.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ enum class thread_state_t { RUNNING, DONE };
1818
class CalcMask final {
1919
protected:
2020
volatile thread_state_t state;
21+
volatile bool multipass;
2122

2223
void *maskctx;
2324
timestamp_t t0;
@@ -60,6 +61,6 @@ class CalcMask final {
6061
CalcMask(const std::string& modelname, size_t threads, size_t width, size_t height);
6162
~CalcMask();
6263

63-
void set_input_frame(cv::Mat &frame);
64+
void set_input_frame(const cv::Mat &frame, bool multipass);
6465
void get_output_mask(cv::Mat &out);
6566
};

app/deepseg.cc

+12-2
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ int main(int argc, char* argv[]) try {
7474

7575
bool flipHorizontal = false;
7676
bool flipVertical = false;
77+
bool multipass = false;
7778

7879
std::string vcam = "/dev/video1";
7980
std::string ccam = "/dev/video0";
@@ -95,6 +96,8 @@ int main(int argc, char* argv[]) try {
9596
flipHorizontal = !flipHorizontal;
9697
} else if (args[arg] == "-V") {
9798
flipVertical = !flipVertical;
99+
} else if (args[arg] == "-M") {
100+
multipass = !multipass;
98101
} else if (args[arg] == "-v") {
99102
if (hasArgument) {
100103
vcam = args[++arg];
@@ -187,7 +190,7 @@ int main(int argc, char* argv[]) try {
187190
fprintf(stderr, "\n");
188191
fprintf(stderr, "usage:\n");
189192
fprintf(stderr, " backscrub [-?] [-d] [-p] [-c <capture>] [-v <virtual>] [-w <width>] [-h <height>]\n");
190-
fprintf(stderr, " [-t <threads>] [-b <background>] [-m <modell>] [-p <option:value>] [-H] [-V]\n");
193+
fprintf(stderr, " [-t <threads>] [-b <background>] [-m <modell>] [-p <option:value>] [-H] [-V] [-M]\n");
191194
fprintf(stderr, "\n");
192195
fprintf(stderr, "-? Display this usage information\n");
193196
fprintf(stderr, "-d Increase debug level\n");
@@ -206,6 +209,7 @@ int main(int argc, char* argv[]) try {
206209
fprintf(stderr, "-p bgblur:<strength> Blur the video background\n");
207210
fprintf(stderr, "-H Mirror the output horizontally\n");
208211
fprintf(stderr, "-V Mirror the output vertically\n");
212+
fprintf(stderr, "-M Activate multi-pass filtering (for aspect ratio mismatch)\n");
209213
exit(1);
210214
}
211215

@@ -227,6 +231,7 @@ int main(int argc, char* argv[]) try {
227231
printf("height: %zu\n", height);
228232
printf("flip_h: %s\n", flipHorizontal ? "yes" : "no");
229233
printf("flip_v: %s\n", flipVertical ? "yes" : "no");
234+
printf("multi: %s\n", multipass ? "yes" : "no");
230235
printf("threads:%zu\n", threads);
231236
printf("back: %s\n", s_backg ? s_backg.value().c_str() : "(none)");
232237
printf("model: %s\n\n", s_model ? s_model.value().c_str() : "(none)");
@@ -296,7 +301,7 @@ int main(int argc, char* argv[]) try {
296301
// copy new frame to buffer
297302
cap.retrieve(raw);
298303
ti.retrns = timestamp();
299-
ai.set_input_frame(raw);
304+
ai.set_input_frame(raw, multipass);
300305
ti.copyns = timestamp();
301306

302307
if (raw.rows == 0 || raw.cols == 0)
@@ -416,6 +421,7 @@ int main(int argc, char* argv[]) try {
416421
" f: toggle FPS display on/off",
417422
" b: toggle background display on/off",
418423
" m: toggle mask display on/off",
424+
" M: toggle multi-pass processing on/off",
419425
" ?: toggle this help text on/off"
420426
};
421427

@@ -485,6 +491,10 @@ int main(int argc, char* argv[]) try {
485491
showMask = !showMask;
486492
break;
487493

494+
case 'M':
495+
multipass = !multipass;
496+
break;
497+
488498
case '?':
489499
showHelp = !showHelp;
490500
break;

0 commit comments

Comments
 (0)