# Estimate affine transform with constraints

**URL:** <https://forum.opencv.org/t/estimate-affine-transform-with-constraints/17503>\
**Category:** C++\
**Tags:** imgproc\
**Created:** [May 2, 2024, 9:09am UTC](https://forum.opencv.org/t/estimate-affine-transform-with-constraints/17503 "2024-05-02T09:09:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nji9](https://avatars.discourse-cdn.com/v4/letter/n/f08c70/32.png) [@nji9](https://forum.opencv.org/u/nji9)\
**Post date:** [May 2, 2024, 9:09am UTC](https://forum.opencv.org/t/estimate-affine-transform-with-constraints/17503/1 "2024-05-02T09:09:22Z")

</div>

I’m at 2D and need to derive the affine transform between two sets of points.

For the general case there is `cv::estimateAffineTransform2D`.  
If there is no shearing there is `cv::estimateAffineTransformPartial2D`,  
which has 4 degrees of freedom: tX, tY, scale and rotation.

In my case I sometimes know the value of one or more of these four.  
Using `cv::estimateAffineTransformPartial2D` often generates  
good approximations of them, but sometimes it does not. The alg seems to be sensible.

So my question (you will have guessed already):  
Is there a way in OpenCV to provide beforehand values for one or more of  
tX, tY, scale and rotation, so the calculation will be done with fixed value for it?  
Or do I have to use external statistic optimization algs for that?
