Skip to content

Perspective correction wrong #160

@darkdragon-001

Description

@darkdragon-001

There seem to be several issues with the code:

  • It picks the minimum instead of the maximum
  • It shrinks both dimensions by a factor of sqrt(2)
  • For large distortion angles, this looks very wrong

float w1 = sqrt( pow(x4 - x3 , 2) + pow(x4 - x3, 2));
float w2 = sqrt( pow(x2 - x1 , 2) + pow(x2-x1, 2));
float h1 = sqrt( pow(y2 - y4 , 2) + pow(y2 - y4, 2));
float h2 = sqrt( pow(y1 - y3 , 2) + pow(y1-y3, 2));
float maxWidth = (w1 < w2) ? w1 : w2;
float maxHeight = (h1 < h2) ? h1 : h2;
Mat dst = Mat::zeros(maxHeight, maxWidth, CV_8UC3);

Any ideas how to improve this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions