floe / backscrub

Virtual Video Device for Background Replacement with Deep Semantic Segmentation
Apache License 2.0
734 stars 85 forks source link

Error OpenCV while trying to run #125

Closed jkvargas closed 2 years ago

jkvargas commented 2 years ago

So, I have installed everything under /usr/local

[0/1] Install the project...
-- Install configuration: "Release"
-- Up-to-date: /usr/local/bin/backscrub
-- Up-to-date: /usr/local/lib/libbackscrub.a
-- Up-to-date: /usr/local/include/backscrub/libbackscrub.h
-- Up-to-date: /usr/local/share/backscrub/models
-- Up-to-date: /usr/local/share/backscrub/models/segm_lite_v681.tflite
-- Up-to-date: /usr/local/share/backscrub/models/deeplabv3_257_mv_gpu.tflite
-- Up-to-date: /usr/local/share/backscrub/models/selfiesegmentation_mlkit-256x256-2021_01_19-v1215.f16.tflite
-- Up-to-date: /usr/local/share/backscrub/models/segm_full_v679.tflite
-- Up-to-date: /usr/local/share/backscrub/models/body-pix
-- Up-to-date: /usr/local/share/backscrub/models/retrain.md
-- Up-to-date: /usr/local/share/backscrub/models/body-pix-float-050-8.tflite

Running it normally tells me that it couldnt find a model,

"Could not open 'models/selfiesegmentation_mlkit-256x256-2021_01_19-v1215.f16.tflite'."

but lets say that I create a symbolic link to the models location, then I get:

backscrub version heads/main-0-g6fc5d8d
(c) 2021 by floe@butterbrot.org & contributors
https://github.com/floe/backscrub
debug:  2
ccam:   /dev/video2
vcam:   /dev/video10
width:  640
height: 480
flip_h: no
flip_v: no
threads:2
back:   /home/vargasj/Pictures/churrascaria.jpg
model:  models/selfiesegmentation_mlkit-256x256-2021_01_19-v1215.f16.tflite

vid_format->type                = 2
vid_format->fmt.pix.width       = 640
vid_format->fmt.pix.height      = 480
vid_format->fmt.pix.pixelformat = 1448695129
vid_format->fmt.pix.sizeimage   = 614400
vid_format->fmt.pix.field       = 1
vid_format->fmt.pix.bytesperline= 1280
vid_format->fmt.pix.colorspace  = 8

INFO: Created TensorFlow Lite XNNPACK delegate for CPU.
tensor #0: 1
tensor #0: 256
tensor #0: 256
tensor #0: 3
tensor #249: 1
tensor #249: 256
tensor #249: 256
tensor #249: 1
Startup: 306013604ns
main [grab:270146291 retr:  2561261 copy:  1275797 prep:      184 mask:  5439242 post:      256 v4l2:  1382689 FPS:  3.56] ai: [wait:273988645 prep:  619450terminate called after throwing an instance of 'cv::Exception'
  what():  OpenCV(4.5.4) /build/opencv/src/opencv-4.5.4/modules/imgproc/src/filter.dispatch.cpp:145: error: (-215:Assertion failed) 0 <= anchor.x && anchor.x < ksize.width && 0 <= anchor.y && anchor.y < ksize.height in function 'init'

[1]    16244 abort (core dumped)  backscrub -d -d -c /dev/video2 -v /dev/video10 -b ~/Pictures/churrascaria.jpg

What am I missing? Should I be building from a released tag instead? Also, is there a way to increase the width and height? I am using Manjaro, btw. Thanks.

BenBE commented 2 years ago

The experimental branch should detect the model directories automagically when no slashes are part of the model name.

For using a different width/height of the camera you need to specify -w and -h accordingly. Note that some cameras need to also specify a different pixel format to unlock certain resolutions.

jkvargas commented 2 years ago

Hey man, thanks for the answer sorry, but I am still not sure what should I do regarding the opencv error.