2

I am launching a std::async thread as follows;

cv::Point2f opDim = Point2f(1920, 1080);
cv::Point2f ipDim = Point2f(1920, 1080);
CameraToBEV cbevObj(roiBox1, opDim, ipDim);
    
std::vector<CameraToBEV> cbevVec;
for (int j = 0; j < jsonObjects.size(); j++)
        cbevVec.push_back(cbevObj);


// for multithreading
std::vector<std::future<cv::Mat>> processingThread;
std::vector<cv::Mat> opMatArr;
 
processingThread.emplace_back(std::async(std::launch::async, &CameraToBEV::process, &cbevVec[i], std::ref(jsonObjects[i]), roiBox1, opDim,ipDim));

I have the following overloaded process() function definitions;

cv::Mat process(json&);
cv::Mat process(json&, std::vector<cv::Point2f>);
cv::Mat process(json&, std::vector<cv::Point2f>, cv::Point2f);
cv::Mat process(json&, std::vector<cv::Point2f>, cv::Point2f, cv::Point2f);

I clearly have the function definition which I am passing to std::async. Why am I getting the error?

'cannot determine which instance of overloaded function is intended'

The White Cloud
  • 189
  • 1
  • 11
  • 4
    Isn't `&CameraToBEV::process` ambiguous? Which overload should that point to? – chi Feb 01 '21 at 11:18
  • I would guess that at the instance you pass the function pointer into the std::async, it needs to be unambiguous, you may not be able to rely on the additional arguments to disambiguate. – Mansoor Feb 01 '21 at 11:23
  • 2
    Which of the four declared functions to you expect `&CameraToBEV::process` to resolve to? Why do you expect that? It is not the function definitions that matter - it is the fact that the compiler must somehow decide which of the functions you mean. – Peter Feb 01 '21 at 11:24
  • 6
    You have to explicitly indicate which overload you want to use by casting: `(cv::Mat (CameraToBEV::*)(json&, std::vector, cv::Point2f, cv::Point2f))&CameraToBEV::process` – rafix07 Feb 01 '21 at 11:32
  • @rafix07, Your comment should be an answer. – Solomon Slow Feb 01 '21 at 21:43
  • @rafix07 thank you for the comment. It worked. Can you write that as the answer, I will select it. Thanks anyways. – The White Cloud Feb 02 '21 at 04:51

0 Answers0