Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 从BackgroundSubtractorMOG2检索背景图像时出错_C++_Opencv - Fatal编程技术网

C++ 从BackgroundSubtractorMOG2检索背景图像时出错

C++ 从BackgroundSubtractorMOG2检索背景图像时出错,c++,opencv,C++,Opencv,我正在尝试从BackgroundSubtractorMOG2获取背景图像: bg->getBackgroundImage(back); 但是我得到了一个线程1 Sigabt < /Cube >(作为C++ N0B使我困惑) 这个错误是: OpenCV Error: Assertion failed (nchannels == 3) in getBackgroundImage, file /Users/hm/Downloads/OpenCV-2.4.4/modules/video/src/

我正在尝试从BackgroundSubtractorMOG2获取背景图像:

bg->getBackgroundImage(back);

但是我得到了一个<代码>线程1 Sigabt < /Cube >(作为C++ N0B使我困惑) 这个错误是:

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)

我不确定问题是什么,怀疑这与nmixtures参数有关,但我将其保留为默认值(3)。有什么提示吗?

看起来您需要使用3通道图像,而不是灰度图像。确保您使用的图像类型是CV_8UC3,或者如果您正在从文件读取,请使用
CV::imread('path/to/file')
,无需其他参数。

看起来您需要使用3通道图像,而不是灰度图像。确保您使用的图像类型是CV_8UC3,或者如果您正在从文件中读取,请使用
CV::imread('path/to/file')
,不带其他参数。

那么BackgroundSubtractorMOG2只能用于3通道图像吗?我用1是因为它是深度传感器stream@GeorgeProfenza我对这个类使用的方法不是很熟悉,但在给定assert的情况下似乎就是这样。使用灰度图像进行前景/背景分割的一种流行方法是使用opencv中实现的。感谢Max,我还检查了Otsu阈值,非常整洁!对我来说,我首先将帧转换为3通道图像,如下所示:Imgproc.CvtColor(frame,frame,Imgproc.ColorRgba2bgr);那么BackgroundSubtractorMOG2只能用于3通道图像吗?我用1是因为它是深度传感器stream@GeorgeProfenza我对这个类使用的方法不是很熟悉,但在给定assert的情况下似乎就是这样。使用灰度图像进行前景/背景分割的一种流行方法是使用opencv中实现的。感谢Max,我还检查了Otsu阈值,非常整洁!对我来说,我首先将帧转换为3通道图像,如下所示:Imgproc.CvtColor(frame,frame,Imgproc.ColorRgba2bgr);