Find image coordinates under cursor

Hi all,

I feel like I have asked this before but can’t find the thread anymore:
Is there an example snippet that shows how to look up the cursor position on the image in real time?
I woudl like to look up custom metadata based on the pixel coordinate the cursor is hovering over.
I believe this can only be done in Mu and was wondering if there are similar tools that I could look at for reference.


1 Like

Hello frank,

I’m not sure, if this is what you are looking for, but you could bind a pointer–move event to your mode. It works fine for me in python.

Here is a quick test, I did:

 def pointerEvent(self, event):
        # commands.showConsole()
        pointer = event.pointer()
        sourceName = commands.sourceAtPixel(pointer)[0]['name']
        sourceGroup = commands.inputAtPixel(pointer)
        imgPointer = commands.eventToImageSpace(sourceName, pointer)

pointer is a tuple with the x and y coordinates of the entire view
sourceAtPixel returns a list with a dictionary element (most likely just one)
inputAtPixel returns the RvSourceGroup Node

the eventToImageSpace function returns a tuple, where the lower left corner of the image is (0,0), the height of the image is 1 and the width seems to be calculated according to the image aspect.



Ohh, that would be fabulous if this could be done in python. Thanks!