Ask Your Question
0

SparseMat::ptr<> yields "invalid overload of 'ptr'"

asked 2015-12-20 15:45:15 -0600

Ralph058 gravatar image

This is in static analysis with Eclipse. The compiler also recognizes the instantiation as being in error. Specifically, the line: if (sparseLocL.ptr< cv::Vec6f >(y_R_idx,x_C_idx, false) != NULL){ yields the following error: error: expected primary-expression before ‘>’ token I do not see an extraneous '>' and I don't see a problem with the previous line or two. This link uses the same syntax as my line: http://stackoverflow.com/questions/15...

It is happy with: NewLocValL_H = sparseLocL.ref< cv::Vec6f >(y_R_idx,x_C_idx)[H]; and that is immediately after the if statement.

I'm running Ubuntu 12.04 with gcc 4.7 native compile on an AMD-64 processor. The version of Eclipse that I am using is Luna modified to be TI's Code Composer Studio 6.1.

I declare sparsLocL as: SparseMat sparseLocL( 2, sparseSize, CV_32FC(6)); //only 5 are used

I tried declaring as: SparseMat *sparseLocL( 2, sparseSize, CV_32FC(6)); //only 5 are used and it made no difference.

Any ideas on where to look for the root cause?

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
1

answered 2015-12-20 21:22:01 -0600

berak gravatar image

updated 2015-12-20 22:22:11 -0600

SparseMat::ptr is not a template function , but just returns a uchar *

typedef Vec<float, 5> cv::Vec5f; // take 5, ...

int sz[] = {3,3};
SparseMat sparseLocL(2, sz, CV_32FC(5)); 
if (sparseLocL.ptr(2,2, false) != NULL)
    Vec5f elm = sparseLocL.ref(2,2);
 else
    cerr << "empty";
edit flag offensive delete link more

Comments

damn, i'm unable to edit properly today(timeouts), ofc. it has to be: sparseLocL.ref<Vec5f>(2,2);

berak gravatar imageberak ( 2015-12-21 10:03:11 -0600 )edit

My analysis tool didn't like the way you had written the typedef. It is happy with : typedef Vec<float, 5> Vec5f; In response to your comment, I changed the if statement to: if (sparseLocL.ptr(y_R_idx,x_C_idx, false) != NULL){

It was happy with the usage of .ref as : NewLocValL_H = sparseLocL.ref< cv::Vec6f >(y_R_idx,x_C_idx)[H]; because that is the way it is in Kaehler & Bradski's Learning OpenCV3 and the analysis tool is happy.

I have some compile errors which having nothing to do with OpenCV. When I clear them and try to run it, I may make a change, but I consider it to be answered.

Ralph058 gravatar imageRalph058 ( 2015-12-21 10:09:54 -0600 )edit

yes, you're right. it should have been Vec5f, not cv::Vec5f.

bear with me, i got some probs with this page today, weather or something ..

berak gravatar imageberak ( 2015-12-21 10:14:55 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-12-20 15:42:15 -0600

Seen: 273 times

Last updated: Dec 20 '15