random - how to generateRandomTransform with OpenCV -


i tried generate random homography matrix used transform planar object image. seems opencv has class "patchgenerator". can't find detailed information of class. , people said work affine transformation. there method generated random homography matrix? or can use opencv function directly? many thx!

you can build homography matrix multiplying random scaling, translation , rotation matrices together:

h = t . s . r 

the rotation matrix can generated using e.g. euler angles (three parameter rotation).

the translation matrix identity matrix last column entries corresponding point translation in each dimension.

finally, scale matrix has scaling entries each dimension on diagonal.

the final homography matrix h can normalized dividing last entry (bottom right corner). can check whether entry not small (if need 2d homography , project transformed points in same plane).

the advantage of approach better control on parameters (e.g. translation corresponds typical translation amounts used) , generated homographies guaranteed invertible long 3 simple matrices invertible well.

of course, can generate well-behaving homographies unit square, example, , scale matrix fit actual problem (e.g. image size in pixels).


Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -