Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaCV or OpenCV Image Rotation

My objective is to rotate an image by a certain angle (e.g. 30 degrees). One possible way of rotating by 90 degrees in OpenCV is given by tenta4 but unfortunately, it only performs 90-degree flips.

Another possible way is a method "SkewGrayImage" given in JavaCV samples where it performs "small angle rotations" that appear to work for rotations of up to approximately 45 - 50 degrees but not for any other higher values.

So - my issues is, is there a proper way/method in OpenCV or JavaCV to actually perform an angular rotation of images or objects?

like image 865
Psi-Ed Avatar asked Oct 21 '25 22:10

Psi-Ed


1 Answers

Meta has explained how to compute a rotation matrix with respect to the center of the image and then to perform a rotation as follows:

    Mat rotated_image;
    warpAffine(src, rotated_image, rot_mat, src.size());
like image 130
Ross Pudney Avatar answered Oct 24 '25 14:10

Ross Pudney



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!