| OpenCV 5.0.0alpha Open Source Computer Vision

Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
cv::MatShape Struct Reference
Core functionality » Basic structures

Represents shape of a matrix/tensor. Previously, MatShape was defined as an alias of std::vector<int>, but now we use a special structure that provides a few extra benefits: More...

`#include <opencv2/core/mat.hpp>`

Collaboration diagram for cv::MatShape:

## Public Types
enum | { MAX_DIMS =10 }

## Public Member Functions
| MatShape ()
template<class _It >
| MatShape (_It begin, _It end)
| MatShape (const int *begin, const int *end, DataLayout layout=DATA_LAYOUT_UNKNOWN, int C=0)
| MatShape (const MatShape &shape)
| MatShape (const std::vector< int > &shape, DataLayout layout=DATA_LAYOUT_UNKNOWN, int C=0)
| MatShape (int dims, int value, DataLayout layout=DATA_LAYOUT_UNKNOWN)
| MatShape (size_t dims, const int *sizes=nullptr, DataLayout layout=DATA_LAYOUT_UNKNOWN, int C=0)
| MatShape (size_t dims, int value, DataLayout layout=DATA_LAYOUT_UNKNOWN)
| MatShape (std::initializer_list< int > shape)
template<class _It >
void | assign (_It begin, _It end)
void | assign (const int *begin, const int *end)
void | assign (int newSize, int value)
void | assign (size_t newSize, int value)
void | assign_ (const int *begin, const int *end)
int & | back ()
const int & | back () const
int * | begin ()
const int * | begin () const
void | clear ()
int * | data ()
const int * | data () const
void | emplace_back (int value)
bool | empty () const
int * | end ()
const int * | end () const
void | erase (int *where)
MatShape | expand (const MatShape &another) const
MatShape | fromBlock (DataLayout newLayout) const
bool | hasSymbols () const
template<class _It >
void | insert (int *where, _It begin, _It end)
void | insert (int *where, const int *begin, const int *end)
void | insert (int *where, int count, int value)
void | insert (int *where, int value)
void | insert (int *where, size_t count, int value)
void | insert_ (int *where, const int *begin, const int *end)
bool | isScalar () const
MatShape & | operator= (const MatShape &shape)
int & | operator[] (size_t idx)
const int & | operator[] (size_t idx) const
void | push_back (int value)
void | reserve (size_t maxSize)
void | resize (size_t newSize, int value=0)
size_t | size () const
std::string | str () const
MatShape | toBlock (int C0) const
size_t | total () const

## Static Public Member Functions
static MatShape | scalar ()

## Public Attributes
int | C
int | dims
DataLayout | layout
int | p [MAX_DIMS]

## Detailed Description

Represents shape of a matrix/tensor. Previously, MatShape was defined as an alias of std::vector<int>, but now we use a special structure that provides a few extra benefits:

1. avoids any heap operations, since the shape is stored in a plain array. This reduces overhead of shape inference etc.
2. includes information about the layout, including the actual number of channels ('C') in the case of block layout.
3. distinguishes between empty shape (total() == 0) and 0-dimensional shape (dims == 0, but total() == 1).

## Member Enumeration Documentation

## ◆ anonymous enum

anonymous enum

Enumerator
MAX_DIMS |

## Constructor & Destructor Documentation

## ◆ MatShape() [1/9]

cv::MatShape::MatShape | ( |  | ) |

## ◆ MatShape() [2/9]

cv::MatShape::MatShape | ( | size_t | dims,
|  | const int * | sizes = nullptr,
|  | DataLayout | layout = DATA_LAYOUT_UNKNOWN,
|  | int | C = 0 )
| explicit

## ◆ MatShape() [3/9]

cv::MatShape::MatShape | ( | size_t | dims,
|  | int | value,
|  | DataLayout | layout = DATA_LAYOUT_UNKNOWN )
| explicit

## ◆ MatShape() [4/9]

cv::MatShape::MatShape | ( | int | dims,
|  | int | value,
|  | DataLayout | layout = DATA_LAYOUT_UNKNOWN )
| explicit

## ◆ MatShape() [5/9]

cv::MatShape::MatShape | ( | const std::vector< int > & | shape,
|  | DataLayout | layout = DATA_LAYOUT_UNKNOWN,
|  | int | C = 0 )
| explicit

## ◆ MatShape() [6/9]

cv::MatShape::MatShape | ( | const int * | begin,
|  | const int * | end,
|  | DataLayout | layout = DATA_LAYOUT_UNKNOWN,
|  | int | C = 0 )
| explicit

## ◆ MatShape() [7/9]

cv::MatShape::MatShape | ( | std::initializer_list< int > | shape | ) |
| explicit

## ◆ MatShape() [8/9]

cv::MatShape::MatShape | ( | const MatShape & | shape | ) |

## ◆ MatShape() [9/9]

template<class _It >

cv::MatShape::MatShape | ( | _It | begin,
|  | _It | end )

## Member Function Documentation

## ◆ assign() [1/4]

template<class _It >

void cv::MatShape::assign | ( | _It | begin,
|  | _It | end )

## ◆ assign() [2/4]

void cv::MatShape::assign | ( | const int * | begin,
|  | const int * | end )

## ◆ assign() [3/4]

void cv::MatShape::assign | ( | int | newSize,
|  | int | value )

## ◆ assign() [4/4]

void cv::MatShape::assign | ( | size_t | newSize,
|  | int | value )

## ◆ assign_()

void cv::MatShape::assign_ | ( | const int * | begin,
|  | const int * | end )

## ◆ back() [1/2]

int & cv::MatShape::back | ( |  | ) |

## ◆ back() [2/2]

const int & cv::MatShape::back | ( |  | ) | const

## ◆ begin() [1/2]

int * cv::MatShape::begin | ( |  | ) |

## ◆ begin() [2/2]

const int * cv::MatShape::begin | ( |  | ) | const

## ◆ clear()

void cv::MatShape::clear | ( |  | ) |

## ◆ data() [1/2]

int * cv::MatShape::data | ( |  | ) |

## ◆ data() [2/2]

const int * cv::MatShape::data | ( |  | ) | const

## ◆ emplace_back()

void cv::MatShape::emplace_back | ( | int | value | ) |

## ◆ empty()

bool cv::MatShape::empty | ( |  | ) | const

## ◆ end() [1/2]

int * cv::MatShape::end | ( |  | ) |

## ◆ end() [2/2]

const int * cv::MatShape::end | ( |  | ) | const

## ◆ erase()

void cv::MatShape::erase | ( | int * | where | ) |

## ◆ expand()

MatShape cv::MatShape::expand | ( | const MatShape & | another | ) | const

## ◆ fromBlock()

MatShape cv::MatShape::fromBlock | ( | DataLayout | newLayout | ) | const

## ◆ hasSymbols()

bool cv::MatShape::hasSymbols | ( |  | ) | const

## ◆ insert() [1/5]

template<class _It >

void cv::MatShape::insert | ( | int * | where,
|  | _It | begin,
|  | _It | end )

## ◆ insert() [2/5]

void cv::MatShape::insert | ( | int * | where,
|  | const int * | begin,
|  | const int * | end )

## ◆ insert() [3/5]

void cv::MatShape::insert | ( | int * | where,
|  | int | count,
|  | int | value )

## ◆ insert() [4/5]

void cv::MatShape::insert | ( | int * | where,
|  | int | value )

## ◆ insert() [5/5]

void cv::MatShape::insert | ( | int * | where,
|  | size_t | count,
|  | int | value )

## ◆ insert_()

void cv::MatShape::insert_ | ( | int * | where,
|  | const int * | begin,
|  | const int * | end )

## ◆ isScalar()

bool cv::MatShape::isScalar | ( |  | ) | const

## ◆ operator=()

MatShape & cv::MatShape::operator= | ( | const MatShape & | shape | ) |

## ◆ operator[]() [1/2]

int & cv::MatShape::operator[] | ( | size_t | idx | ) |

## ◆ operator[]() [2/2]

const int & cv::MatShape::operator[] | ( | size_t | idx | ) | const

## ◆ push_back()

void cv::MatShape::push_back | ( | int | value | ) |

## ◆ reserve()

void cv::MatShape::reserve | ( | size_t | maxSize | ) |

## ◆ resize()

void cv::MatShape::resize | ( | size_t | newSize,
|  | int | value = 0 )

## ◆ scalar()

static MatShape cv::MatShape::scalar | ( |  | ) |
| static

## ◆ size()

size_t cv::MatShape::size | ( |  | ) | const

## ◆ str()

std::string cv::MatShape::str | ( |  | ) | const

## ◆ toBlock()

MatShape cv::MatShape::toBlock | ( | int | C0 | ) | const

## ◆ total()

size_t cv::MatShape::total | ( |  | ) | const

## Member Data Documentation

## ◆ C

int cv::MatShape::C

## ◆ dims

int cv::MatShape::dims

## ◆ layout

DataLayout cv::MatShape::layout

## ◆ p

int cv::MatShape::p[MAX_DIMS]

The documentation for this struct was generated from the following file:

- opencv2/core/mat.hpp