Getting any dynamic image positions in screen coordinates with keyboard and mouse events for eye tracker

Dear VTK users and developers,

I am working on image viewer which is going to be integrated with eye tracker device. Although I look at some open source project’s source code such as 3d slicer, mitk, smili, medInria, starview in C++ on github, I still could not figure out a solution yet . Sorry if I miss anything in advance.

I would like to ask a question as follows. I already got x,y coordinates of image pixel in vtkRenderWindow in vtkImageViewer2 using vtkRenderWindowInteractor in C++ using VtK 8.2 and Qt 12.5 in Qt Creator after opening 2d/3d nifti image or DICOM image on windows 10.

How to get exact location (x,y and size) of shown image in vtkImageViewer2 any time such as top left and bottom right corner in x,y pixels in current screen when i do zoom in/out , pan , left/right click or any keyboard events in VTK as shown on Figure?. Basically, I only need to get x,y and size in pixels of what i see in vtk not all image coordinates when i do not see all image in vtk.

I would really appreacite if you let me know some solutions about it in C++ using VTK or any guidance.
Thank you in advance

Best,
Ismail

I just know 3D Slicer, and it is easy to do it there:

  • Get the X and Y pixel coordinates in the widget from the screen coordinates using standard Qt coordinate mapping functions.
  • Get the XY (pixel coordinates in the viewer) to RAS (physical coordinates in patient coordinate system) transform from the slice node’s GetXYToRAS() method.
  • Multiply the [X, Y, 0, 1] vector by this transformation matrix to get the [R, A, S, 1] vector. RAS values are the physical coordinates (in right-anterior-superior anatomical coordinate system).

If you need any further help on how to do this in Slicer, you can ask on the Slicer forum

1 Like

Thank you @lassoan Andras. It was helpful. I will delve into code more. If i find a solution in VTK and C++, i will let you know.
Best,
Ismail