64,678
社区成员
发帖
与我相关
我的任务
分享
//……接上帖
1721:
1722: //! converts header to CvMat; no data is copied
1723: operator CvMat() const;
1724: //! converts header to CvMatND; no data is copied
1725: operator CvMatND() const;
1726: //! converts header to IplImage; no data is copied
1727: operator IplImage() const;
1728:
1729: template<typename _Tp> operator vector<_Tp>() const;
1730: template<typename _Tp, int n> operator Vec<_Tp, n>() const;
1731: template<typename _Tp, int m, int n> operator Matx<_Tp, m, n>() const;
1732:
1733: //! returns true iff the matrix data is continuous
1734: // (i.e. when there are no gaps between successive rows).
1735: // similar to CV_IS_MAT_CONT(cvmat->type)
1736: bool isContinuous() const;
1737:
1738: //! returns true if the matrix is a submatrix of another matrix
1739: bool isSubmatrix() const;
1740:
1741: //! returns element size in bytes,
1742: // similar to CV_ELEM_SIZE(cvmat->type)
1743: size_t elemSize() const;
1744: //! returns the size of element channel in bytes.
1745: size_t elemSize1() const;
1746: //! returns element type, similar to CV_MAT_TYPE(cvmat->type)
1747: int type() const;
1748: //! returns element type, similar to CV_MAT_DEPTH(cvmat->type)
1749: int depth() const;
1750: //! returns element type, similar to CV_MAT_CN(cvmat->type)
1751: int channels() const;
1752: //! returns step/elemSize1()
1753: size_t step1(int i=0) const;
1754: //! returns true if matrix data is NULL
1755: bool empty() const;
1756: //! returns the total number of matrix elements
1757: size_t total() const;
1758:
1759: //! returns N if the matrix is 1-channel (N x ptdim) or ptdim-channel (1 x N) or (N x 1); negative number otherwise
1760: int checkVector(int elemChannels, int depth=-1, bool requireContinuous=true) const;
1761:
1762: //! returns pointer to i0-th submatrix along the dimension #0
1763: uchar* ptr(int i0=0);
1764: const uchar* ptr(int i0=0) const;
1765:
1766: //! returns pointer to (i0,i1) submatrix along the dimensions #0 and #1
1767: uchar* ptr(int i0, int i1);
1768: const uchar* ptr(int i0, int i1) const;
1769:
1770: //! returns pointer to (i0,i1,i3) submatrix along the dimensions #0, #1, #2
1771: uchar* ptr(int i0, int i1, int i2);
1772: const uchar* ptr(int i0, int i1, int i2) const;
1773:
1774: //! returns pointer to the matrix element
1775: uchar* ptr(const int* idx);
1776: //! returns read-only pointer to the matrix element
1777: const uchar* ptr(const int* idx) const;
1778:
1779: template<int n> uchar* ptr(const Vec<int, n>& idx);
1780: template<int n> const uchar* ptr(const Vec<int, n>& idx) const;
1781:
1782: //! template version of the above method
1783: template<typename _Tp> _Tp* ptr(int i0=0);
1784: template<typename _Tp> const _Tp* ptr(int i0=0) const;
1785:
1786: template<typename _Tp> _Tp* ptr(int i0, int i1);
1787: template<typename _Tp> const _Tp* ptr(int i0, int i1) const;
1788:
1789: template<typename _Tp> _Tp* ptr(int i0, int i1, int i2);
1790: template<typename _Tp> const _Tp* ptr(int i0, int i1, int i2) const;
1791:
1792: template<typename _Tp> _Tp* ptr(const int* idx);
1793: template<typename _Tp> const _Tp* ptr(const int* idx) const;
1794:
1795: template<typename _Tp, int n> _Tp* ptr(const Vec<int, n>& idx);
1796: template<typename _Tp, int n> const _Tp* ptr(const Vec<int, n>& idx) const;
1797:
1798: //! the same as above, with the pointer dereferencing
1799: template<typename _Tp> _Tp& at(int i0=0);
1800: template<typename _Tp> const _Tp& at(int i0=0) const;
1801:
1802: template<typename _Tp> _Tp& at(int i0, int i1);
1803: template<typename _Tp> const _Tp& at(int i0, int i1) const;
1804:
1805: template<typename _Tp> _Tp& at(int i0, int i1, int i2);
1806: template<typename _Tp> const _Tp& at(int i0, int i1, int i2) const;
1807:
1808: template<typename _Tp> _Tp& at(const int* idx);
1809: template<typename _Tp> const _Tp& at(const int* idx) const;
1810:
1811: template<typename _Tp, int n> _Tp& at(const Vec<int, n>& idx);
1812: template<typename _Tp, int n> const _Tp& at(const Vec<int, n>& idx) const;
1813:
1814: //! special versions for 2D arrays (especially convenient for referencing image pixels)
1815: template<typename _Tp> _Tp& at(Point pt);
1816: template<typename _Tp> const _Tp& at(Point pt) const;
1817:
1818: //! template methods for iteration over matrix elements.
1819: // the iterators take care of skipping gaps in the end of rows (if any)
1820: template<typename _Tp> MatIterator_<_Tp> begin();
1821: template<typename _Tp> MatIterator_<_Tp> end();
1822: template<typename _Tp> MatConstIterator_<_Tp> begin() const;
1823: template<typename _Tp> MatConstIterator_<_Tp> end() const;
1824:
1825: enum { MAGIC_VAL=0x42FF0000, AUTO_STEP=0, CONTINUOUS_FLAG=CV_MAT_CONT_FLAG, SUBMATRIX_FLAG=CV_SUBMAT_FLAG };
1826:
1827: /*! includes several bit-fields:
1828: - the magic signature
1829: - continuity flag
1830: - depth
1831: - number of channels
1832: */
1833: int flags;
1834: //! the matrix dimensionality, >= 2
1835: int dims;
1836: //! the number of rows and columns or (-1, -1) when the matrix has more than 2 dimensions
1837: int rows, cols;
1838: //! pointer to the data
1839: uchar* data;
1840:
1841: //! pointer to the reference counter;
1842: // when matrix points to user-allocated data, the pointer is NULL
1843: int* refcount;
1844:
1845: //! helper fields used in locateROI and adjustROI
1846: uchar* datastart;
1847: uchar* dataend;
1848: uchar* datalimit;
1849:
1850: //! custom allocator
1851: MatAllocator* allocator;
1852:
1853: struct CV_EXPORTS MSize
1854: {
1855: MSize(int* _p);
1856: Size operator()() const;
1857: const int& operator[](int i) const;
1858: int& operator[](int i);
1859: operator const int*() const;
1860: bool operator == (const MSize& sz) const;
1861: bool operator != (const MSize& sz) const;
1862:
1863: int* p;
1864: };
1865:
1866: struct CV_EXPORTS MStep
1867: {
1868: MStep();
1869: MStep(size_t s);
1870: const size_t& operator[](int i) const;
1871: size_t& operator[](int i);
1872: operator size_t() const;
1873: MStep& operator = (size_t s);
1874:
1875: size_t* p;
1876: size_t buf[2];
1877: protected:
1878: MStep& operator = (const MStep&);
1879: };
1880:
1881: MSize size;
1882: MStep step;
1883: };
崩溃的时候在弹出的对话框按相应按钮进入调试,按Alt+7键查看Call Stack即“调用堆栈”里面从上到下列出的对应从里层到外层的函数调用历史。双击某一行可将光标定位到此次调用的源代码或汇编指令处,看不懂时双击下一行,直到能看懂为止。
1565: class CV_EXPORTS Mat
1566: {
1567: public:
1568: //! default constructor
1569: Mat();
1570: //! constructs 2D matrix of the specified size and type
1571: // (_type is CV_8UC1, CV_64FC3, CV_32SC(12) etc.)
1572: Mat(int _rows, int _cols, int _type);
1573: Mat(Size _size, int _type);
1574: //! constucts 2D matrix and fills it with the specified value _s.
1575: Mat(int _rows, int _cols, int _type, const Scalar& _s);
1576: Mat(Size _size, int _type, const Scalar& _s);
1577:
1578: //! constructs n-dimensional matrix
1579: Mat(int _ndims, const int* _sizes, int _type);
1580: Mat(int _ndims, const int* _sizes, int _type, const Scalar& _s);
1581:
1582: //! copy constructor
1583: Mat(const Mat& m);
1584: //! constructor for matrix headers pointing to user-allocated data
1585: Mat(int _rows, int _cols, int _type, void* _data, size_t _step=AUTO_STEP);
1586: Mat(Size _size, int _type, void* _data, size_t _step=AUTO_STEP);
1587: Mat(int _ndims, const int* _sizes, int _type, void* _data, const size_t* _steps=0);
1588:
1589: //! creates a matrix header for a part of the bigger matrix
1590: Mat(const Mat& m, const Range& rowRange, const Range& colRange=Range::all());
1591: Mat(const Mat& m, const Rect& roi);
1592: Mat(const Mat& m, const Range* ranges);
1593: //! converts old-style CvMat to the new matrix; the data is not copied by default
1594: Mat(const CvMat* m, bool copyData=false);
1595: //! converts old-style CvMatND to the new matrix; the data is not copied by default
1596: Mat(const CvMatND* m, bool copyData=false);
1597: //! converts old-style IplImage to the new matrix; the data is not copied by default
1598: Mat(const IplImage* img, bool copyData=false);
1599: //! builds matrix from std::vector with or without copying the data
1600: template<typename _Tp> explicit Mat(const vector<_Tp>& vec, bool copyData=false);
1601: //! builds matrix from cv::Vec; the data is copied by default
1602: template<typename _Tp, int n> explicit Mat(const Vec<_Tp, n>& vec,
1603: bool copyData=true);
1604: //! builds matrix from cv::Matx; the data is copied by default
1605: template<typename _Tp, int m, int n> explicit Mat(const Matx<_Tp, m, n>& mtx,
1606: bool copyData=true);
1607: //! builds matrix from a 2D point
1608: template<typename _Tp> explicit Mat(const Point_<_Tp>& pt, bool copyData=true);
1609: //! builds matrix from a 3D point
1610: template<typename _Tp> explicit Mat(const Point3_<_Tp>& pt, bool copyData=true);
1611: //! builds matrix from comma initializer
1612: template<typename _Tp> explicit Mat(const MatCommaInitializer_<_Tp>& commaInitializer);
1613: //! destructor - calls release()
1614: ~Mat();
1615: //! assignment operators
1616: Mat& operator = (const Mat& m);
1617: Mat& operator = (const MatExpr& expr);
1618:
1619: //! returns a new matrix header for the specified row
1620: Mat row(int y) const;
1621: //! returns a new matrix header for the specified column
1622: Mat col(int x) const;
1623: //! ... for the specified row span
1624: Mat rowRange(int startrow, int endrow) const;
1625: Mat rowRange(const Range& r) const;
1626: //! ... for the specified column span
1627: Mat colRange(int startcol, int endcol) const;
1628: Mat colRange(const Range& r) const;
1629: //! ... for the specified diagonal
1630: // (d=0 - the main diagonal,
1631: // >0 - a diagonal from the lower half,
1632: // <0 - a diagonal from the upper half)
1633: Mat diag(int d=0) const;
1634: //! constructs a square diagonal matrix which main diagonal is vector "d"
1635: static Mat diag(const Mat& d);
1636:
1637: //! returns deep copy of the matrix, i.e. the data is copied
1638: Mat clone() const;
1639: //! copies the matrix content to "m".
1640: // It calls m.create(this->size(), this->type()).
1641: void copyTo( OutputArray m ) const;
1642: //! copies those matrix elements to "m" that are marked with non-zero mask elements.
1643: void copyTo( OutputArray m, InputArray mask ) const;
1644: //! converts matrix to another datatype with optional scalng. See cvConvertScale.
1645: void convertTo( OutputArray m, int rtype, double alpha=1, double beta=0 ) const;
1646:
1647: void assignTo( Mat& m, int type=-1 ) const;
1648:
1649: //! sets every matrix element to s
1650: Mat& operator = (const Scalar& s);
1651: //! sets some of the matrix elements to s, according to the mask
1652: Mat& setTo(InputArray value, InputArray mask=noArray());
1653: //! creates alternative matrix header for the same data, with different
1654: // number of channels and/or different number of rows. see cvReshape.
1655: Mat reshape(int _cn, int _rows=0) const;
1656: Mat reshape(int _cn, int _newndims, const int* _newsz) const;
1657:
1658: //! matrix transposition by means of matrix expressions
1659: MatExpr t() const;
1660: //! matrix inversion by means of matrix expressions
1661: MatExpr inv(int method=DECOMP_LU) const;
1662: //! per-element matrix multiplication by means of matrix expressions
1663: MatExpr mul(InputArray m, double scale=1) const;
1664:
1665: //! computes cross-product of 2 3D vectors
1666: Mat cross(InputArray m) const;
1667: //! computes dot-product
1668: double dot(InputArray m) const;
1669:
1670: //! Matlab-style matrix initialization
1671: static MatExpr zeros(int rows, int cols, int type);
1672: static MatExpr zeros(Size size, int type);
1673: static MatExpr zeros(int ndims, const int* sz, int type);
1674: static MatExpr ones(int rows, int cols, int type);
1675: static MatExpr ones(Size size, int type);
1676: static MatExpr ones(int ndims, const int* sz, int type);
1677: static MatExpr eye(int rows, int cols, int type);
1678: static MatExpr eye(Size size, int type);
1679:
1680: //! allocates new matrix data unless the matrix already has specified size and type.
1681: // previous data is unreferenced if needed.
1682: void create(int _rows, int _cols, int _type);
1683: void create(Size _size, int _type);
1684: void create(int _ndims, const int* _sizes, int _type);
1685:
1686: //! increases the reference counter; use with care to avoid memleaks
1687: void addref();
1688: //! decreases reference counter;
1689: // deallocates the data when reference counter reaches 0.
1690: void release();
1691:
1692: //! deallocates the matrix data
1693: void deallocate();
1694: //! internal use function; properly re-allocates _size, _step arrays
1695: void copySize(const Mat& m);
1696:
1697: //! reserves enough space to fit sz hyper-planes
1698: void reserve(size_t sz);
1699: //! resizes matrix to the specified number of hyper-planes
1700: void resize(size_t sz);
1701: //! resizes matrix to the specified number of hyper-planes; initializes the newly added elements
1702: void resize(size_t sz, const Scalar& s);
1703: //! internal function
1704: void push_back_(const void* elem);
1705: //! adds element to the end of 1d matrix (or possibly multiple elements when _Tp=Mat)
1706: template<typename _Tp> void push_back(const _Tp& elem);
1707: template<typename _Tp> void push_back(const Mat_<_Tp>& elem);
1708: void push_back(const Mat& m);
1709: //! removes several hyper-planes from bottom of the matrix
1710: void pop_back(size_t nelems=1);
1711:
1712: //! locates matrix header within a parent matrix. See below
1713: void locateROI( Size& wholeSize, Point& ofs ) const;
1714: //! moves/resizes the current matrix ROI inside the parent matrix.
1715: Mat& adjustROI( int dtop, int dbottom, int dleft, int dright );
1716: //! extracts a rectangular sub-matrix
1717: // (this is a generalized form of row, rowRange etc.)
1718: Mat operator()( Range rowRange, Range colRange ) const;
1719: Mat operator()( const Rect& roi ) const;
1720: Mat operator()( const Range* ranges ) const;
//未完待续……