Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Opencv 2.4.3 estimateRigidTransform in python

This is really a mess for me and I have a hard time trying to solve this. I want to use the method cv2.estimateRigitTransform in Python with numpy arrays but I can't find anywhere an example or something else that explains the format of the src and dst numpy arrays needed.

Could somebody send me a little example of these 2 arrays that will work with this method? I have all the data (in 2D of course) but can't find how to shape it in a numpy array.

Please help me. Thank you!

like image 769
Jeep87c Avatar asked Oct 05 '22 12:10

Jeep87c


1 Answers

Here's a basic example that tries to align two random sets of 10 points

import numpy as np
import cv2
shape = (1, 10, 2) # Needs to be a 3D array
source = np.random.randint(0, 100, shape).astype(np.int)
target = source + np.array([1, 0]).astype(np.int)
transformation = cv2.estimateRigidTransform(source, target, False)

Documentation is here.

like image 98
Geoff Avatar answered Oct 13 '22 11:10

Geoff