[Interest] Understanding QImage::transformed()
Jérôme Godbout
godboutj at amotus.ca
Fri Dec 14 23:03:12 CET 2018
Are you trying to make a POSIT algorithm? You can take a look at the C# accord POSIT algo:
http://accord-framework.net/samples.html#
Maybe someone known a good C++ implementation for this.
You need to find the transform then make a reverse look up to the original pixel and make an interpolation between pixel to give the proper color. This will stretch some zone but will give a gradual transition at least.
If I understand well you might need a shape detection follow by a posit to bring the image into the plane properly.
-----Original Message-----
From: Interest <interest-bounces at qt-project.org> On Behalf Of Jason H
Sent: December 14, 2018 4:50 PM
To: interest at lists.qt-project.org
Subject: [Interest] Understanding QImage::transformed()
I have an image. I have identified 4 control points in in image (1920x1080).
I want to map the points to a square image, of 1080 on a side.
QPolygonF fromPoly(QVector<QPointF> { ... }); QPolygonF toPoly(QVector<QPointF> {QPoint(squareDimension/2, 0), QPoint(squareDimension, squareDimension/2), QPoint(squareDimension/2, squareDimension), QPoint(0, squareDimension/2)});
Where the toPoly maps to [(960,0), (1080,960), (960,1080), [0, 960)]
QTransform tx;
if (QTransform::quadToQuad(fromPoly, toPoly, tx)) {
out = image.transformed(QImage::trueMatrix(tx, image.width(), image.height()));
qDebug() << out.save("sdsd1.jpg");
out = out.copy ((out.width() - squareDimension)/2,(out.height() - squareDimension)/2, squareDimension, squareDimension);
qDebug() << out.save("sdsd2.jpg");
}
But out is (3270x2179);
The control points match up a square in that out image of 1600x1600, which is not right. No matter what I do, using trueMatrix() or not, when I crop the image to 1080x1080, it is too zoomed in.
What do I need to go to get all the control points to fit into an image of 1080x1080? Imagine an image (1920x1080) of a clock with some perspective skew. I identify 12,3, 6, and 9 hour positions. I want to create an image of the clock without perspective skew, that is to say, a face-on approximation of the clock.
Thanks.
_______________________________________________
Interest mailing list
Interest at qt-project.org
https://lists.qt-project.org/listinfo/interest
More information about the Interest
mailing list