2
votes

in my application i have a function which receives a cv::Mat object by reference. here is function's declaration:

     void getChains(cv::Mat &img,std::vector<chain> &chains,cv::Mat &ch,char p=0,int sx=0,int sy=0);

this function is recursive, and aaa is not really needed at the first call from the main function, so i just declared an empty aaa to pass it to the function call. in subsequent recursive calls function generates its own ch Mat objects.

std::vector<chain> chains1;
cv::Mat aaa();

getChains(bin1,chains1,aaa);

however, the compiler returns an error:

main.cpp:75: error: invalid initialization of non-const reference of type ‘cv::Mat&’ from a temporary of type ‘cv::Mat (*)()’ aux.h:21: error: in passing argument 3 of ‘void getChains(cv::Mat&, std::vector >&, cv::Mat&, char, int, int)’

if i change aaa declaration to

        cv::Mat aaa=cv::Mat();

it compiles without a problem.

the function is passed a binary image img and gets all the pixel groups in which pixels stick together (chains) and stores all the pixels' coordinates in the chains vector. Is there perhaps already an existing function within openCV that does a similar thing?

thanks

1

1 Answers

5
votes

This is a function definition: cv::Mat aaa();. What you actually want to write is cv::Mat aaa;