0

First thing: I read related questions & solutions didn't fix the error.

considering:

double foo(cv::InputArray Input1,
           cv::InputArray Input2,
           cv::InputOutputArray InOut,  
           cv::TermCriteria criteria=cv::TermCriteria(cv::TermCriteria::MAX_ITER+cv::TermCriteria::EPS, 50, 0.001)),
           cv::InputArray Input3 = cv::noArray())
{
      return 2;
}

If I call the function with:

cv::Mat In1, In2, InOut; //dummy for test
double ret = foo(In1, In2, InOut);

it compiles; but when I try to thread it I got this error:

no type named "type" in class std::result

double ret = 0;
std::thread th(ret, &foo, &In1, &In2, InOut);

So I tried with std::ref, but it gives me the same error:

double ret = 0;
std::thread th(ret, &foo, std::ref(In1), std::ref(In2), std::ref(InOut));
A.albin
  • 274
  • 2
  • 15
  • you pass a double as the 1st parameter of `std::thread::thread`, I don't think it would work. – apple apple Nov 09 '17 at 07:11
  • Possible duplicate of [C++: Simple return value from std::thread?](https://stackoverflow.com/questions/7686939/c-simple-return-value-from-stdthread) – apple apple Nov 09 '17 at 07:13

1 Answers1

0

First point:

To get your output you'll need to use other tools (check the linked answer), or the simplest will be to use a double& as parameter.

Second point:

You don't need std::ref() on the cv::Mat, but will need if for the double&, you just need to define your default values in the std::thread constructor.

this should compile (not tested, but In confident in the result):

std::thread t(&foo, In1, In2, InOut, cv::TermCriteria(values), cv::noArray(), std::ref(retval));

with:

void foo(cv::InputArray Input1,
       cv::InputArray Input2,
       cv::InputOutputArray InOut,  
       cv::TermCriteria criteria=cv::TermCriteria(cv::TermCriteria::MAX_ITER+cv::TermCriteria::EPS, 50, 0.001)),
       cv::InputArray Input3 = cv::noArray(),
       double& retval)
  {
      retval = 2;
  }
Ebya
  • 428
  • 3
  • 14