Is it possible to create an instance of a threaded class within a custom class, or does it have to be under the ofApp?
I use ofxCv to train a face recognition model. I regularly need to update the model while the application is running, so I need to put the model->train() function to different thread to prevent interrupting the rest of the application.
Some basic code in ThreadedModel.h
#pragma once
#include "ofMain.h"
#include "ofxCv.h"
#include "ofxOpenCv.h"
#include "ofThread.h"
using namespace ofxCv;
using namespace cv;
class ThreadedModel : public ofThread {
void setup() {
this->model = createEigenFaceRecognizer(80, 5000);
}
void threadedFunction() {
}
public:
Ptr<FaceRecognizer> model;
vector<Mat> modelFaces;
vector<ofImage> modelOfFaces;
vector<int> modelLabels;
};
If I add the class in my app.h the application runs fine
#include "ThreadedModel.h"
class ofApp : public ofBaseApp {
....
ThreadedModel threadedModel;
}
But if I move it in a a class called manager.h which is responsible for all the images and eventually the model, I get this error at the ofApp point where I construct the manager:
1>src\ofApp.cpp(24): error C2280: 'manager &manager::operator =(const manager &)': attempting to reference a deleted function
1> d:\mystuff\ch3\dev\visual studio 2015\of_v0.9.8_vs_release\apps\myapps\we\src\manager.h(82): note: compiler has generated 'manager::operator =' here
Any ideas?
This is the first time I attempt to use threading so I may be missing something fundamental.
Thanks