George Profenza
George Profenza

Reputation: 51847

error retrieving background image from BackgroundSubtractorMOG2

I'm trying to get the background image from BackgroundSubtractorMOG2:

bg->getBackgroundImage(back);

but I get a Thread 1 SIGABRT (which as a c++ n00b puzzles me) and this error:

OpenCV Error: Assertion failed (nchannels == 3) in getBackgroundImage, file /Users/hm/Downloads/OpenCV-2.4.4/modules/video/src/bgfg_gaussmix2.cpp, line 579
libc++abi.dylib: terminate called throwing an exception
(lldb)

I'm not sure what the problem is, suspecting it's something to do with the nmixtures paramater, but I've left that as the default(3). Any hints ?

Upvotes: 2

Views: 1642

Answers (1)

Max Allan
Max Allan

Reputation: 2395

It looks like you need to use 3 channel images rather than grayscale. Make sure the image type you are using is CV_8UC3 or if you are reading from a file use cv::imread('path/to/file') with no additional arguments.

Upvotes: 4

Related Questions