Skip to content

ts: ROI cases are not being covered by ArrayTest #26244

Open
@mshabunin

Description

ArrayTest class have two storages for arrays: vector<vector<void*>> test_array for old functions and vector<vector<Mat>> test_mat for new functions. The first one is being filled with data and the second one is copied from the first:

test_mat.resize(test_array.size());
for( i = 0; i < max_arr; i++ )
{
size_t sizei = test_array[i].size();
test_mat[i].resize(sizei);
for( j = 0; j < sizei; j++ )
{
CvArr* arr = test_array[i][j];
test_mat[i][j] = cv::cvarrToMat(arr);
if( !test_mat[i][j].empty() )
fill_array( test_case_idx, (int)i, (int)j, test_mat[i][j] );
}
}

However, the function cvarrToMat being used to convert old array to Mat clears the ROI indicator and creates plain object instead (data == datastart, dataend unset or at the end). Example for IplImage:

if(!img->roi)
{
CV_Assert(img->dataOrder == IPL_DATA_ORDER_PIXEL);
m.flags = Mat::MAGIC_VAL + CV_MAKETYPE(imgdepth, img->nChannels);
m.rows = img->height;
m.cols = img->width;
m.datastart = m.data = (uchar*)img->imageData;
esz = CV_ELEM_SIZE(m.flags);
}
else
{
CV_Assert(img->dataOrder == IPL_DATA_ORDER_PIXEL || img->roi->coi != 0);
bool selectedPlane = img->roi->coi && img->dataOrder == IPL_DATA_ORDER_PLANE;
m.flags = Mat::MAGIC_VAL + CV_MAKETYPE(imgdepth, selectedPlane ? 1 : img->nChannels);
m.rows = img->roi->height;
m.cols = img->roi->width;
esz = CV_ELEM_SIZE(m.flags);
m.datastart = m.data = (uchar*)img->imageData +
(selectedPlane ? (img->roi->coi - 1)*m.step*img->height : 0) +
img->roi->yOffset*m.step[0] + img->roi->xOffset*esz;
}

Thus all ArrayTest-based tests using test_mat and new functions will effectively miss ROI case. For example Core_MulSpectrums.accuracy. Here neither of src1, src2 or dst will be ROI Mat in any case:

cv::mulSpectrums( *src1, *src2, dst, flags, (flags & CV_DXT_MUL_CONJ) != 0 );

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions