cv::completeSymm fixed to work with any OpenCV data type and multiple channels.

This commit is contained in:
Peter Andreas Entschev 2013-12-14 22:48:01 -02:00
parent 10849d1c7a
commit f44de302a0

View File

@ -2032,40 +2032,25 @@ void cv::transpose( InputArray _src, OutputArray _dst )
}
////////////////////////////////////// completeSymm /////////////////////////////////////////
void cv::completeSymm( InputOutputArray _m, bool LtoR )
{
Mat m = _m.getMat();
CV_Assert( m.dims <= 2 );
size_t step = m.step, esz = m.elemSize();
CV_Assert( m.dims <= 2 && m.rows == m.cols );
int i, j, nrows = m.rows, type = m.type();
int j0 = 0, j1 = nrows;
CV_Assert( m.rows == m.cols );
int rows = m.rows;
int j0 = 0, j1 = rows;
if( type == CV_32FC1 || type == CV_32SC1 )
{
int* data = (int*)m.data;
size_t step = m.step/sizeof(data[0]);
for( i = 0; i < nrows; i++ )
uchar* data = m.data;
for( int i = 0; i < rows; i++ )
{
if( !LtoR ) j1 = i; else j0 = i+1;
for( j = j0; j < j1; j++ )
data[i*step + j] = data[j*step + i];
for( int j = j0; j < j1; j++ )
memcpy(data + (i*step + j*esz), data + (j*step + i*esz), esz);
}
}
else if( type == CV_64FC1 )
{
double* data = (double*)m.data;
size_t step = m.step/sizeof(data[0]);
for( i = 0; i < nrows; i++ )
{
if( !LtoR ) j1 = i; else j0 = i+1;
for( j = j0; j < j1; j++ )
data[i*step + j] = data[j*step + i];
}
}
else
CV_Error( CV_StsUnsupportedFormat, "" );
}
cv::Mat cv::Mat::cross(InputArray _m) const