OpenCV Q&A Forum - RSS feedhttp://answers.opencv.org/questions/OpenCV answersenCopyright <a href="http://www.opencv.org">OpenCV foundation</a>, 2012-2018.Wed, 13 May 2020 06:26:10 -0500How could I achieve similar function such as the piecewise affine transform?http://answers.opencv.org/question/230128/how-could-i-achieve-similar-function-such-as-the-piecewise-affine-transform/ Hi,
There is a method in scikit-image called `piecewise affine transform` which is very useful. Is there any function in opencv which does the same this? Or how could I do it with opencv?
What the `piecewise affine transform` does is showed in this [link](https://scikit-image.org/docs/dev/auto_examples/transform/plot_piecewise_affine.html).coincheungWed, 13 May 2020 06:26:10 -0500http://answers.opencv.org/question/230128/Strange streching effects in photo due to transformation by matrixhttp://answers.opencv.org/question/229362/strange-streching-effects-in-photo-due-to-transformation-by-matrix/ I am working on stitching algorithm and and sometime there is strange streching of photo. It is cause by low number of keypoints BUT I am interested what cause it in this matrix:
![matrix](/upfiles/15876576686657783.png)
and the effect of this matrix is this: https://imgur.com/a/dwzm9Af (sorry can not upload image here, it seems too big)
can you suggest how to reduce this effect or what cause it?
RockStar1337Thu, 23 Apr 2020 11:06:48 -0500http://answers.opencv.org/question/229362/Determining types of 3D transformation between two sets of cloud pointshttp://answers.opencv.org/question/226378/determining-types-of-3d-transformation-between-two-sets-of-cloud-points/ Hi. I am new in the forum and I have a little question.
I have two cloud of points in 3D and I know that the second cloud is obtained applying a transformation matrix.
I think, if I am not mistaken, that I need to use the [estimateAffine3D](https://docs.opencv.org/2.4/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html?highlight=estimate#cv2.estimateAffine3D) function.
But, in this case, I would like to know how much of each transformation has been applied. For example, I would like to know if the second set of clouds has been scaled 2 times, rotated 25ยบ and sheared 5 units in the X axis.
The second set of points can have any kind of transformations.
thanks a lot for your time!
IbaiSun, 16 Feb 2020 18:03:37 -0600http://answers.opencv.org/question/226378/Co-ordinate system followed in cv2.warpAffine()http://answers.opencv.org/question/217897/co-ordinate-system-followed-in-cv2warpaffine/ I was trying to implement a naive version of the warpAffine function to understand how it works. This is my implementation
def custom_warpaffine(image, matrix, shape):
'''
clone of cv2.warpAffine()
Follows nearest-neighbour interpolation
@Params:
image - numpy array - 1 channel, source image
matrix - numpy array of size (2, 3), affine transform matrix
shape - int tuple, shape of source image
@returns:
output - numpy array - 1 channel, image after affine transform
'''
output = np.zeros_like(image, dtype=np.float32)
for x in range(shape[0]):
for y in range(shape[1]):
transformed_x = int(matrix[0,0]*x + matrix[0,1]*y + matrix[0,2])
transformed_y = int(matrix[1,0]*x + matrix[1,1]*y + matrix[1,2])
if transformed_x >=shape[0] or transformed_y >=shape[1]:
pass
else:
output[x, y] = image[transformed_x, transformed_y]
return output
I followed the mapping given in the [documentation](https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html?highlight=warpaffine#void%20warpAffine(InputArray%20src,%20OutputArray%20dst,%20InputArray%20M,%20Size%20dsize,%20int%20flags,%20int%20borderMode,%20const%20Scalar&%20borderValue), but my [output](https://imgur.com/a/CgTvLos) is different from that of the inbuilt function.
my affine transform matrix is [[1, 0, 100], [0, 1, 50]],
i.e dst[x, y] = scr[x+100, y+50]
but the [output](https://imgur.com/a/CgTvLos) was different.
The output matched the inbuilt cv2.warpAffine(.., flags=cv2.WARP_INVERSE_MAP,..) function output only when the mapping was changed from
`output[x, y] = image[transformed_x, transformed_y]`
to
`output[y, x] = image[transformed_y, transformed_x]`
I am confused as to why this is the case. Thanks for any help!blockchainmenWed, 04 Sep 2019 04:51:25 -0500http://answers.opencv.org/question/217897/