Ask Your Question
0

cv::BackgroundSubtractorMOG2, cv::CascadeClassifier(), thread contest

asked 2014-03-02 07:20:55 -0600

The objects in the subject send immediately my application to crash at the rows:

    CCEyes= new cv::CascadeClassifier();
    MOG2Background= new cv::BackgroundSubtractorMOG2();

The rows are in a thread, non in the mai crocess. That happens on Windows. On Linux all works well.

Have you got any suggestion?

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
0

answered 2014-03-04 14:57:35 -0600

After many hours of research now I think it is a OpenCV bug. The behaviour happens with OpenCV 2.4.6.1 and OpenCV 2.4.8 usando MinGW32. In order to compile OpenCV 2.4.8 with MinGW is necessary to patch the source code as is described here:

http://stackoverflow.com/questions/21103042/error-while-building-opencv-monitorfromrect-was-not-declared-in-this-scope

After that, if you want to obtain the behaviour, the only thing to do is to create a Qt project and in the main class add the following rows:

include "mainwindow.h"

include "ui_mainwindow.h"

include "opencv2/objdetect/objdetect.hpp"

include "opencv2/highgui/highgui.hpp"

include "opencv2/imgproc/imgproc.hpp"

include <iostream>

include <stdio.h>

using namespace std; using namespace cv;

MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); CascadeClassifier face_cascade; }

MainWindow::~MainWindow() { delete ui; }

Now which is the fastest way to obtain a good OpenCV release for MinGW?

edit flag offensive delete link more

Comments

Hi Dennis, I use Qt 5.2 with MSVC 2012, OpenCV 2.4.8 Release and did not encouter any problem with the code you give. So I do not think it is a OpenCV bug.

tuannhtn gravatar imagetuannhtn ( 2014-03-04 15:11:14 -0600 )edit
0

answered 2014-03-02 12:08:21 -0600

updated 2014-03-02 12:08:49 -0600

I think this is a memory-leak error. From your code, CCEyes is a pointer, if it is a global pointer, your object (in previous thread) will be lost in current thread (as the pointer is assigned to a new object). If it is not a global pointer (I mean it is a local variable in each thread code), this may be caused since CascadeClassifier is a non thread-safe class.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2014-03-02 07:20:55 -0600

Seen: 718 times

Last updated: Mar 04 '14