How to Retrieve Coordinates of a Rectangle Drawn Using Rectangle Scissor Tool in OHIF Viewer?

Hello Community,

I am currently working with the OHIF Viewer and am using the Rectangle Scissor Tool to annotate regions. While the tool works perfectly for drawing rectangles on the image, I need to extract the coordinates of the rectangle (e.g., the top-left and bottom-right points) programmatically.

Has anyone worked with this tool and successfully retrieved the coordinates? Specifically, I am looking for:

  1. The API or method within OHIF Viewer that provides the rectangle’s coordinates after it’s drawn.
  2. Any configuration or event listeners I need to enable to capture this data.

Thank you in advance for your help!

Best regards,
Amritha

1 Like

RectangleROI you mean? our scissors (segmentation) does not keep coordinates, but you can grab RectangleROI tool coords using cornerstoneTools.annotation.state

Thank you! That works for me.

Does this still work?
as I am getting an empty array when doing cornerstoneTools.annotation.state.getAllAnnotations()

import * as cornerstoneTools from '@cornerstonejs/tools';

const logSeg = async () => {
    console.log({ "cornerstoneTools.annotation.state": cornerstoneTools.annotation.state });
    console.log({ "cornerstoneTools.annotation.state.getAllAnnotations()": cornerstoneTools.annotation.state.getAllAnnotations() });
}

would really appreciate if @Amritha-7 or @alireza could guide me for this.