Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does python opencv rotate the picture

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the knowledge of "how to rotate pictures in python opencv". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Function usage

(h center,30,1.0 w) = img2.shape [: 2] center= (w) M=cv2.getRotationMatrix2D (center,30,1.0) img3=cv2.warpAffine (img2,M, (w) h)

Detailed explanation of parameters

The main contents are as follows: 1. Because two images need to be the same size when matching.

2. When rotating the image, we can't simply rotate it. We should find out the center point of the image, rotate around the center point and fill in the blank.

Find the center point

(img2.shape w) = img2.shape [: 2] center= (wqqqqq2mgle hripple 2)

Function cv2.getRotationMatrix2D ()

The first parameter: indicates which point to rotate, and this is the center point of the image.

The second parameter: represents the angle of rotation, which is positive 30 degrees, which means 30 degrees clockwise.

The third parameter: represents the size of the rotated image. Setting it to 1 here means that the size is the same as the original image.

Function cv2.warpAffine ()

The first parameter: set to the original image.

The second parameter is the rotation matrix M, which is the result of the previous function.

The third parameter: set the (width, height) tuple of the image here, and then display the rotated image.

This is the end of "how to rotate python opencv Pictures". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report