@@ -231,19 +231,9 @@ class CalcMask final {
231
231
size_t height) :
232
232
state{thread_state::INIT},
233
233
thread{&CalcMask::run, this } {
234
- maskctx = bs_maskgen_new (
235
- modelname,
236
- threads,
237
- width,
238
- height,
239
- nullptr ,
240
- onprep,
241
- oninfer,
242
- onmask,
243
- this
244
- );
234
+ maskctx = bs_maskgen_new (modelname,threads,width,height,nullptr ,onprep,oninfer,onmask,this );
245
235
if (!maskctx)
246
- exit ( 1 ) ;
236
+ throw " Could not create mask context " ;
247
237
248
238
// Do all other initialization …
249
239
frame_next = &frame1;
@@ -277,7 +267,7 @@ class CalcMask final {
277
267
}
278
268
};
279
269
280
- int main (int argc, char * argv[]) {
270
+ int main (int argc, char * argv[]) try {
281
271
282
272
printf (" deepseg version %s\n " , _STR (DEEPSEG_VERSION));
283
273
printf (
" (c) 2021 by [email protected] & contributors\n " );
@@ -530,7 +520,7 @@ int main(int argc, char* argv[]) {
530
520
531
521
// timing details..
532
522
printf (" main [grab:%9ld retr:%9ld copy:%9ld prep:%9ld mask:%9ld post:%9ld v4l2:%9ld FPS: %5.2f] ai: [wait:%9ld prep:%9ld tflt:%9ld mask:%9ld FPS: %5.2f] \e[K\r " ,
533
- diffnanosecs (ti.grabns , ti.lastns ),
523
+ diffnanosecs (ti.grabns ,ti.lastns ),
534
524
diffnanosecs (ti.retrns ,ti.grabns ),
535
525
diffnanosecs (ti.copyns ,ti.retrns ),
536
526
diffnanosecs (ti.prepns ,ti.copyns ),
@@ -571,4 +561,7 @@ int main(int argc, char* argv[]) {
571
561
572
562
printf (" \n " );
573
563
return 0 ;
564
+ } catch (const char * msg) {
565
+ fprintf (stderr, " Error: %s\n " , msg);
566
+ return 1 ;
574
567
}
0 commit comments