Ask Your Question

pass cv::MAT as pointer to a function in C++

asked 2017-04-22 18:06:50 -0500

opencvddddd gravatar image

I am new to OpenCV, cv::MAT is class including many components, not like an pure array which I could directly use the pointer to pass it to another function, modify it, and still keep the values after that function.

How can I pass cv::MAT as a pointer?

Appreciate a lot for anyone's comments.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2017-04-22 18:47:32 -0500

berak gravatar image

updated 2017-04-22 19:20:42 -0500

that's probably the last thing on earth you should do.

cv::Mat is already a refcounted smartpointer,pass refs or returrn copies, but NEVER pointers, else you'll wreck the refcounting

see, c++ has evolved a lot over the last 20 years, if pointers are your "favourite weapon", you might be just wrong there.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2017-04-22 18:06:50 -0500

Seen: 1,138 times

Last updated: Apr 22 '17