spiros
spiros

Reputation: 489

no matching function for call to ‘std::thread::thread(<unresolved overloaded function type>)’

void show_image(){
   // Create a Mat to store images
Mat cam_image;
ERROR_CODE err; 

// Loop until 'e' is pressed
char key = '';
while (key != 'e') {

    // Grab images 
    err = cam.grab();

    // Check if successful
    if (err == SUCCESS) {
        // Retrieve left image and show with OpenCV
        cam.retrieveImage(zed_image, VIEW_LEFT);
        cv::imshow("VIEW", cv::Mat(cam_image.getHeight(), cam_image.getWidth(), CV_8UC4, cam_image.getPtr<sl::uchar1>(sl::MEM_CPU)));
        key = cv::waitKey(5);
    } else
        key = cv::waitKey(5);
}
}

the above function is being called -threaded- by this function:

void startCAM()
{

    if(show_left){
     cam_call = std::thread(show_image);
    }
    //Wait for data to be grabbed
    while(!has_data)
      sleep_ms(1);
}

and I get the error:

     error: no matching function for call to ‘std::thread::thread(<unresolved     overloaded function type>)’
      cam_call = std::thread(show_image);

It should be noted I use no classes or objects, so show_image is not a member function

Upvotes: 5

Views: 4708

Answers (2)

David Callanan
David Callanan

Reputation: 5810

This could happen if your thread function is the same name as a function that already exists in the global scope.

For example, in my case, I had a function recv for receiving UDP socket data. When I renamed this to receive, the error vanished.

Upvotes: 0

Maxim Egorushkin
Maxim Egorushkin

Reputation: 136515

The error says std::thread::thread(<unresolved overloaded function type>), which means there are multiple functions named show_image.

You need to choose one of those overloads. E.g.:

std::thread(static_cast<void(*)()>(show_image));

Upvotes: 6

Related Questions