Debug assertion failed when using perspectiveTransform

I'm trying to use perspectiveTransform for correcting a point in the video stream from camera. To do so I wrote this code. It is running when tranformation matrix transform is already calculated using getPerspectiveTransform function.

if (isPointsSet) {
vector <Point2f> transformedPoints, srcPoints;
srcPoints.clear();
// getting all objects in frame
for (int i = 0; i < frame->ObjectCount(); i++)
{
cObject *obj = frame->Object(i);
srcPoints.push_back((Point2f)(obj->X(), obj->Y()));
}
// applying transformation matrix
perspectiveTransform(srcPoints, transformedPoints, transform);
for (auto i : transformedPoints) {
std::cout << '\n' << i.x << ' ' << i.y;
}
}


It runs fine for a first time, but after in the next run it causes Debug assertion failed!error. Where is the problem might be?

This is how I'm creating a transformation matrix:

Mat transform
/* some code here */
transform = getPerspectiveTransform(cameraAnchorPoints, anchorPoints);


cameraAnchorPoints and anchorPoints are vectors of four Point2f

edit retag close merge delete