• <i id='LLFAK'><tr id='LLFAK'><dt id='LLFAK'><q id='LLFAK'><span id='LLFAK'><b id='LLFAK'><form id='LLFAK'><ins id='LLFAK'></ins><ul id='LLFAK'></ul><sub id='LLFAK'></sub></form><legend id='LLFAK'></legend><bdo id='LLFAK'><pre id='LLFAK'><center id='LLFAK'></center></pre></bdo></b><th id='LLFAK'></th></span></q></dt></tr></i><div id='LLFAK'><tfoot id='LLFAK'></tfoot><dl id='LLFAK'><fieldset id='LLFAK'></fieldset></dl></div>
      <bdo id='LLFAK'></bdo><ul id='LLFAK'></ul>

    1. <legend id='LLFAK'><style id='LLFAK'><dir id='LLFAK'><q id='LLFAK'></q></dir></style></legend>

      <tfoot id='LLFAK'></tfoot>
      1. <small id='LLFAK'></small><noframes id='LLFAK'>

        OpenCV Python围绕特定点将图像旋转X度

        时间:2023-07-05
          <bdo id='ADzgO'></bdo><ul id='ADzgO'></ul>
              <tfoot id='ADzgO'></tfoot><legend id='ADzgO'><style id='ADzgO'><dir id='ADzgO'><q id='ADzgO'></q></dir></style></legend>

              1. <i id='ADzgO'><tr id='ADzgO'><dt id='ADzgO'><q id='ADzgO'><span id='ADzgO'><b id='ADzgO'><form id='ADzgO'><ins id='ADzgO'></ins><ul id='ADzgO'></ul><sub id='ADzgO'></sub></form><legend id='ADzgO'></legend><bdo id='ADzgO'><pre id='ADzgO'><center id='ADzgO'></center></pre></bdo></b><th id='ADzgO'></th></span></q></dt></tr></i><div id='ADzgO'><tfoot id='ADzgO'></tfoot><dl id='ADzgO'><fieldset id='ADzgO'></fieldset></dl></div>

                    <tbody id='ADzgO'></tbody>

                  <small id='ADzgO'></small><noframes id='ADzgO'>

                • 本文介绍了OpenCV Python围绕特定点将图像旋转X度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我很难找到使用 OpenCV 在 Python 中将图像围绕特定点旋转特定(通常非常小)角度的示例.

                  I'm having a hard time finding examples for rotating an image around a specific point by a specific (often very small) angle in Python using OpenCV.

                  这是我目前所拥有的,但它产生了一个非常奇怪的结果图像,但它有点旋转:

                  This is what I have so far, but it produces a very strange resulting image, but it is rotated somewhat:

                  def rotateImage( image, angle ):
                      if image != None:
                          dst_image = cv.CloneImage( image )
                  
                          rotate_around = (0,0)
                          transl = cv.CreateMat(2, 3, cv.CV_32FC1 )
                  
                          matrix = cv.GetRotationMatrix2D( rotate_around, angle, 1.0, transl )
                          cv.GetQuadrangleSubPix( image, dst_image, transl )
                          cv.GetRectSubPix( dst_image, image, rotate_around )
                  
                      return dst_image
                  

                  推荐答案

                  import numpy as np
                  import cv2
                  
                  def rotate_image(image, angle):
                    image_center = tuple(np.array(image.shape[1::-1]) / 2)
                    rot_mat = cv2.getRotationMatrix2D(image_center, angle, 1.0)
                    result = cv2.warpAffine(image, rot_mat, image.shape[1::-1], flags=cv2.INTER_LINEAR)
                    return result
                  

                  假设您使用的是 cv2 版本,该代码会找到您要旋转的图像的中心,计算变换矩阵并应用于图像.

                  Assuming you're using the cv2 version, that code finds the center of the image you want to rotate, calculates the transformation matrix and applies to the image.

                  这篇关于OpenCV Python围绕特定点将图像旋转X度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何从 wxpython ListBox 获取项目列表 下一篇:3D矢量的旋转?

                  相关文章

                    <bdo id='JrjwH'></bdo><ul id='JrjwH'></ul>

                    <tfoot id='JrjwH'></tfoot>

                      <small id='JrjwH'></small><noframes id='JrjwH'>

                      <i id='JrjwH'><tr id='JrjwH'><dt id='JrjwH'><q id='JrjwH'><span id='JrjwH'><b id='JrjwH'><form id='JrjwH'><ins id='JrjwH'></ins><ul id='JrjwH'></ul><sub id='JrjwH'></sub></form><legend id='JrjwH'></legend><bdo id='JrjwH'><pre id='JrjwH'><center id='JrjwH'></center></pre></bdo></b><th id='JrjwH'></th></span></q></dt></tr></i><div id='JrjwH'><tfoot id='JrjwH'></tfoot><dl id='JrjwH'><fieldset id='JrjwH'></fieldset></dl></div>
                    1. <legend id='JrjwH'><style id='JrjwH'><dir id='JrjwH'><q id='JrjwH'></q></dir></style></legend>