I am trying the cornerstone js library. In which I am trying to use some cornerstone-tools
All I am doing using common JS.
Below is my code:
HTML
<div class="cornerstone-element-wrapper">
<div class="cornerstone-element" data-index="0" oncontextmenu="return false"></div>
</div>
JS
// Setup image loader
cornerstoneWebImageLoader.external.cornerstone = cornerstone;
cornerstone.registerImageLoader('http', cornerstoneWebImageLoader.loadImage)
cornerstone.registerImageLoader('https', cornerstoneWebImageLoader.loadImage)
// Setup tools
csTools = cornerstoneTools.init();
// Enable Element
const element = document.querySelector('.cornerstone-element');
cornerstone.enable(element);
// Display an image
const imageId = 'https://cdn.pixabay.com/photo/2015/04/23/22/00/tree-736885_960_720.jpg';
cornerstone.loadImage(imageId).then(function (image) {
cornerstone.displayImage(element, image);
});
// Freehand ROI
// Add our tool, and set it's mode
const FreehandRoiTool = cornerstoneTools.FreehandRoiTool;
csTools.addTool(FreehandRoiTool)
csTools.setToolActive('FreehandRoi', { mouseButtonMask: 1 })
as far as I could understand docs, I don't see any error in the above code. but still, the following error is displayed in the console.
Uncaught TypeError: apiTool is not a constructor
Following is the JS fiddle of the above code:
As I have done some research, I found out that the
FreehandRoiToolfunction is not present in the cornerstoneTools. So I solved my probelm using the functionFreehandMouseTool, and it seems to be working fine now.Here is the following code I changed.