Skip to main content

Posts

Showing posts with the label Mat

OpenCV : Create Mat Object

What is Mat Class  The basic Image Container, an n-dimensional dense numerical single-channel or multi-channel array. 1. Costructor  You can create Mat object by different ways. Mat mat ( 3 , 3 , CV_32F ); Mat mat2 ( 10 , 2 , CV_64FC2 ); // 2x10 64 bit float 2 channel Mat img ( Size ( 5 , 3 ), CV_32FC3 ); // 5x3 32bit float 3 channel Mat mat3 ( 2 , 3 , CV_8U , Scalar(255) ); // 3x2 8bit unsign_int, all elements set 255 Warining When you create mat object by using Size or Point class, yout have to reverse rows and columns. 2. Set Elements When you create Mat object without data, the elements is set to '0' by defaults. If you want to change elements, you can use setTo , Mat:: ones , Mat:: zeros , Mat:: eye method. Mat mat ( 3 , 3 , CV_32F ); mat .setTo( 10 ); // all elements set to 10 Mat mat7 = Mat :: ones( 3 , 5 , CV_32F ); // all elements set to '1' Mat mat8 = Mat :: zeros( 2 , 3 , CV_32F ); // all elements set to '0' Mat mat9 = Mat :: e...