1

Suppose you have a rectangular pyqtgraph roi instance with some data:

import pyqtgraph as pg
from pyqtgraph.Qt import QtCore, QtGui
import numpy as np

data = np.random.random(size=(50,50,50))
app = QtGui.QApplication([])
w = pg.ImageView()

roi = pg.RectROI([20, 20], [20, 20], pen=(0,9))
roi.addRotateHandle([1, 0], [0.5, 0.5])

w.setImage(data)
w.addItem(roi)
w.show()

How can I extract the 4 corner coordinates of the roi after scaling/rotating it? It think it is possible to calculate them trigonometrically after calling

pos_x, pos_y = roi.pos()
angle = roi.angle()
size_x, size_y = roi.size()

However, it is not that straight forward since the angle can take values >360° etc. I feel like I have missed some build-in solution.

a.smiet
  • 1,727
  • 3
  • 21
  • 36

1 Answers1

0

smiet

i am looking for something similar, but after looking into the documentation, source code and web, i think you are indeed left with your trigonometrical solution. nevertheless you could save two lines of code by calling

roi.getState()

which holds your wanted information in a dictionary. regarding your problem with angles over 360° - shouldn't the modulo operator do the trick?

angle = 365 % 360

..or did i get your problem wrong?