I know, guys, there is s***t load of posts about std::async
, but I just cant figure it out myself (for my defense I can say that today was my first day looking at whole multithread & async thing...). Here's what I have and what I want it to do - I have a camera and a projector and I want to synchronize them. They are connected so the projector signal triggers acquisition of images. HOWEVER I have to call for acquisiton start before I start displaying images via projector. I am using OpenCV
as image processing/handling lib.
class Camera
{
public::
//this one captures images till vector reaches given count of images (while loop)
std::vector<cv::Mat> captureSetOfImages(uint count = 10)
};
class Projector
{
public:
void start();
void stop();
}
int main()
{
Projector *proj = new Projector();
Camera *cam = new Camera();
std::vector<cv::Mat> recvimgs;
recvimgs.reserve(10);
auto f = std::async(&Camera::captureSetOfFrames, cam, PATTERN_10);
proj->start();
while(recvimgs.size() < 10)
recvimgs = f.get();
proj->stop();
}
I get an error:
3 IntelliSense: no operator "=" matches these operands
operand types are: std::vector<cv::Mat, std::allocator<cv::Mat>> = std::vector<cv::Mat, std::allocator<cv::Mat>> (unsigned short)
- From where this
unsigned short
at the end of error is coming from...? - How can I achive this behaviour? (If the code example is not clear enough I want first to prepare for grabbing by calling
Camera::captureSetOfFrames()
then simultaneously callProjector::start()
but knowing camera is ready for capturing, finally terminate displaying by callingProjector::stop()
when all images are captured)
Hope you can figure it out!
PS: Base post which suggested me this (not working) solution How to, in C++11, use std::async on a member function?
Aucun commentaire:
Enregistrer un commentaire