将属性设置为背景减法器MOG2,提供访问冲突异常 [英] Setting properties to background subtractor MOG2 giving access violation exception

查看:81
本文介绍了将属性设置为背景减法器MOG2,提供访问冲突异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在visual studio 2015中使用opencvsharp 3.1.0来检测移动物体。我正在使用 BackgroundsubtractorMOG2 来创建前台蒙版。我可以使用默认值成功运行程序,但如果我尝试设置或获取 BackgroundsubtractorMOG2



我尝试过:



I am using opencvsharp 3.1.0 with visual studio 2015 for a project detecting moving objects. I am using BackgroundsubtractorMOG2 for creating foreground mask.I can successfully run the program with default values but throws access violation exception if I try to set or get properties of BackgroundsubtractorMOG2

What I have tried:

VideoCapturecap = new VideoCapture();
cap.Open(0);
BackgroundSubtractorMOG2 pMOG =BackgroundSubtractorMOG2.Create();
pMOG.shadowThreshold=0.6; // Exception thrown here
while(true)
{
    Mat readframe = new Mat();
    cap.Read(readframe);

    if(!readframe.Empty())
    {

            frame = readframe.Clone();
            frameresult = fc.violationcheck(frame, pMOG);

        }
        else
        {
            frameresult = readframegray;
        }
      }

推荐答案

参见OpenCV:cv :: BackgroundSubtractorMOG2类参考 [ ^ ];你很可能需要调用 setShadowThreshold
See OpenCV: cv::BackgroundSubtractorMOG2 Class Reference[^]; you most likely need to call setShadowThreshold.


这篇关于将属性设置为背景减法器MOG2,提供访问冲突异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆