Ask Your Question
1

cv::Mat::size() cannot be found here

asked 2017-09-11 10:22:41 -0600

2ros0 gravatar image

Hi,

I cannot find the size() in the class reference but I know that it is there. So what am I missing?

Here is a link to the documentation

Thank you

edit retag flag offensive close merge delete

Comments

I saw that but it returned the MatSize object

2ros0 gravatar image2ros0 ( 2017-09-11 11:02:54 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
2

answered 2017-09-11 10:59:56 -0600

updated 2017-09-11 11:00:46 -0600

I stand to be corrected but according to their documentation, there are two ways of attaining the size of a Matrix.

So let us say we have Mat temp. If we want to find its size, you could either:

1. Old School method

From their documentation, a Mat consists of a size attribute which returns a MatSize struct object. By doing temp.size, you will get the correct matrix size but in MatSize return type and of height X width format.

2. Operator method

A look into MatSize, you will see that it implements the () operator. With this method though, its return type is Size and of the famously adapted format width X height. So by doing temp.size(), the MatSize's operator() method gets called.

You might ask, so which one should be used? It depends on your scenario.

I believe the MatSize version was there for the old C-API (speculation). If you are still using it (you shouldn't be by now), then .size makes sense. During my lazy coding days, I tend to use it as well just for quick matrix size checkups.

I mostly use .size() because other functions adapted Size. For example, this default constructor takes Size instead of MSize.

Either one you choose to use, keep in mind of the returned format.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-09-11 10:22:41 -0600

Seen: 444 times

Last updated: Sep 11 '17