| 1937 | } |
| 1938 | |
| 1939 | void cv::perspectiveTransform( InputArray _src, OutputArray _dst, InputArray _mtx ) |
| 1940 | { |
| 1941 | Mat src = _src.getMat(), m = _mtx.getMat(); |
| 1942 | int depth = src.depth(), scn = src.channels(), dcn = m.rows-1; |
| 1943 | CV_Assert( scn + 1 == m.cols && (depth == CV_32F || depth == CV_64F)); |
| 1944 | |
| 1945 | _dst.create( src.size(), CV_MAKETYPE(depth, dcn) ); |
| 1946 | Mat dst = _dst.getMat(); |
| 1947 | |
| 1948 | const int mtype = CV_64F; |
| 1949 | AutoBuffer<double> _mbuf; |
| 1950 | double* mbuf = _mbuf; |
| 1951 | |
| 1952 | if( !m.isContinuous() || m.type() != mtype ) |
| 1953 | { |
| 1954 | _mbuf.allocate((dcn+1)*(scn+1)); |
| 1955 | Mat tmp(dcn+1, scn+1, mtype, (double*)_mbuf); |
| 1956 | m.convertTo(tmp, mtype); |
| 1957 | m = tmp; |
| 1958 | } |
| 1959 | else |
| 1960 | mbuf = (double*)m.data; |
| 1961 | |
| 1962 | TransformFunc func = depth == CV_32F ? |
| 1963 | (TransformFunc)perspectiveTransform_32f : |
| 1964 | (TransformFunc)perspectiveTransform_64f; |
| 1965 | CV_Assert( func != 0 ); |
| 1966 | |
| 1967 | const Mat* arrays[] = {&src, &dst, 0}; |
| 1968 | uchar* ptrs[2]; |
| 1969 | NAryMatIterator it(arrays, ptrs); |
| 1970 | size_t i, total = it.size; |
| 1971 | |
| 1972 | for( i = 0; i < it.nplanes; i++, ++it ) |
| 1973 | func( ptrs[0], ptrs[1], (uchar*)mbuf, (int)total, scn, dcn ); |
| 1974 | } |
| 1975 | |
| 1976 | /****************************************************************************************\ |
| 1977 | * ScaleAdd * |