Ask Your Question
0

How does OpenCV ensure that Mat::data is correctly aligned?

asked 2018-08-02 09:18:13 -0600

c-- gravatar image

Suppose I have a matrix whose elements are shorts, e.g. 16UC1. The actual data in a Mat is stored in a uchar array pointed to by Mat::data. Could anyone point me to the bit of code that ensures that the uchar* is actually correctly aligned for 16-bit elements? Thank you.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
4

answered 2018-08-02 10:26:17 -0600

matman gravatar image

Take a look here and here

edit flag offensive delete link more

Comments

Brilliant, thank you! Presumably if I use one of the Mat constructors that takes a void* argument, it is my own fault if it isn't aligned properly.

c-- gravatar imagec-- ( 2018-08-03 04:11:52 -0600 )edit

If you use Mat with void* your data alignment is unchanged. This is only a Mat wrapper around your data and does not copy any data.

matman gravatar imagematman ( 2018-08-03 12:41:49 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-08-02 09:18:13 -0600

Seen: 1,099 times

Last updated: Aug 02 '18