04-20-2021 06:31 PM
Hi,
I'm not experienced with Labview, and need help to figure out the following:
1. How to save single/multiple ROIs (of any shape) drawn on an image?
2. Once saved, how to load ROIs back on the image to the same location?
I searched on nimax forum and found the following reference, but I do not know how to use open, write file functionality as described on this link below: https://forums.ni.com/t5/Machine-Vision/Saving-ROI-of-an-image-in-a-file/m-p/26868
Thank you for your help!
Best,
Swati
Solved! Go to Solution.
04-20-2021 07:41 PM
Hi Swati,
You can write the ROI data (from a property node) to a binary file, then read it from the binary file when you want it.
The "clear ROI" and wait of 1sec is just so you can see the ROI disappearing and being restored.
04-21-2021 01:36 PM
Hi Gregory, This is awesome!! Thank you so much for a quick and detailed reply with the block diagram and explanation!! That's super helpful, I'm going to try it out right away! I really appreciate your time and help!!
Best Wishes
Swati
04-21-2021 04:20 PM
Hi Gregory,
I have been trying to recreate this block diagram to understand the steps and I have the following follow-up questions:
1. How to get 'Clear ROI' module? I tried using property node to get that, but haven't been successful.
2. What is the purpose of "ROI.bin" input given to the Build Path VI? What does "ROI.bin" signify? Is this the binary file which will have the saved ROI's? And why is the output of 'Build Path VI' connected to both 'Write' and 'Read' VI's ( if the aim is to read ROI from the written binary file)?
What is the motive of adding 'Get System directory' ? Is it because this will allow user to specify the path to which user wants to save the ROI binary file? Could you please explain the sequence in words?
3. How to get a grey square around timer?
I'm sorry for these naïve questions as I'm still learning. Thank you for your great help!
Thanks
Best,
Swati
04-21-2021 04:48 PM
@Swati.Bh wrote:
Hi Gregory,
I have been trying to recreate this block diagram to understand the steps and I have the following follow-up questions:
1. How to get 'Clear ROI' module? I tried using property node to get that, but haven't been successful.
2. What is the purpose of "ROI.bin" input given to the Build Path VI? What does "ROI.bin" signify? Is this the binary file which will have the saved ROI's? And why is the output of 'Build Path VI' connected to both 'Write' and 'Read' VI's ( if the aim is to read ROI from the written binary file)?
What is the motive of adding 'Get System directory' ? Is it because this will allow user to specify the path to which user wants to save the ROI binary file? Could you please explain the sequence in words?
3. How to get a grey square around timer?
I'm sorry for these naïve questions as I'm still learning. Thank you for your great help!
Thanks
Best,
Swati
Hi Swati, no problem at all, I am glad you are trying to create it yourself.
1. That is an invoke node. A lot of times if you think you want to "set" something, it's a property, and if you want to "do" something, it's a method done through an invoke node. This isn't always the case, sometimes you just have to explore.
2. Yes, ROI.bin is just the filename, and I used that desktop folder so it will go on your desktop. But you should put it wherever you need it. "Application directory" is useful for getting a path relative to your project or executable. The path that is built is the file where the data is first saved, and then read from. If you want to save different ROIs, you can use a different filename for each one.
3. That is a flat sequence structure. This is a rare case of where this structure is needed and useful to ensure the wait time occurs right after clearing the ROI. Again, the wait time is just for demonstration purposes, and usually you would not want it.
04-21-2021 06:14 PM
Hi Gregory,
That's super helpful! I learnt so many things today. Thanks to you for your great explanation and patience!!!
Kudos to you!
Thank you so much!!!
Best Wishes
Swati
04-27-2021 09:41 PM - edited 04-27-2021 09:45 PM
Hi Gregory,
I followed the steps you mentioned and that's very helpful!! Although I'm close to what I wanted to achieve, but I'm facing one problem. I'm using the live video (using webcam) and making several ROI's on that live video images. And those are the ROI's I wanted to save and re-load later when needed.
The problem is that the ROI's I make on the live image, do not get recognized until I "re-run" the program: So initially the saved/written ROI file is empty! The work around is that once I run the program, then I draw ROI's, and then I re-run the VI. This time, since ROI's are already present on the live image, it saves those ROI's. I tried adding some time delay, but that didn't work. Any leads on how to solve this problem?
Below are the snapshots of my current file. First half shows how I'm capturing the live video. Then below there is a case structure. Depending on user input, it will either Write the binary ROI file or Read the selected ROI file.
Also, attached is the VI file.
As a solution to my problem: I was thinking to separate the code into separate VI's (say videocapture VI, WriteROI VI, and ReadROI VI) and, then possibly add a button to the videocapture VI, which when pressed will call WriteROI VI, so write is done only when it is called. But, I still want the videocapture VI to be continuously running. I'm not sure what will happen after the WriteROI VI is called...
I wanted to know if there is another better way to make it work? or am I thinking in the right direction? For now, I've started checking online resources about event handling in labview, and will move forward from there.
Thanks so much, any leads will be greatly helpful.
Best regards
Swati
04-28-2021 12:41 PM
04-28-2021 01:06 PM
Hi Gregory,
Thanks a lot for sharing your insight on how this should be done and the link. That's indeed very helpful information for me to move forward in the right direction, super thanks!!
Kind Regards
Swati