1 | initial version |
here's a python example
2 | No.2 Revision |
here's a python example
and it's c++ counterpart:
Mat deskew(const Mat &src)
{
Moments m = moments(src);
if (abs(m.mu02) < 1e-2)
return src;
float skew = float(m.mu11 / m.mu02);
int SZ = src.rows; // assumes quadratic shape
Mat_<float> M(2,3);
M << 1, skew, (-0.5f * SZ * skew), 0, 1, 0;
Mat dst;
warpAffine(src, dst, M, src.size(), WARP_INVERSE_MAP | INTER_LINEAR);
return dst;
}