08-12-2021 07:37 AM
Dear All
I am trying to incorporate a piece of code into my vi that will allow me to draw a box on an image. The box however, must be able to be created based off of the image pixels from a camera. I am currently using a piece of code that allows me to click and drag a box.
What I'm saying, is that if i have an image from the camera that is 500x500 pixels (for example) and a beam is at the position (250,250), i would like to draw a box around this of a user determined size. If I wanted a box that was 100 image pixels wide, I could draw/create a box that has points at (150,350), (350,150), (350,350), (150,150). The beam is at the centre of the box.
I have tried to use the IMAQ draw on image VI but this seems to change the pixel values, I don't want it to do this as these images are then manipulated (centroid calculation etc).
does anyone have any idea how I might do this or any advice?
The VI i am using currently is attached below, I did not write this particular vi. I believe it was written by Ben64.
Best Wishes
Andrew
Solved! Go to Solution.
08-13-2021 05:17 AM
HI,
If you do not want to alter the image, you can use a separate front panel object and place it on top of the graph.
08-13-2021 07:43 AM
Have you considered creating a rectangular ROI? This is non destructive and can be moved on the UI.
08-13-2021 07:50 AM
Hi both
thank you so much for the replies.
I will try this solution and see how it goes.
can I then take the image output of that image then display it onto an intensity graph with the box drawn on it.
Best Wishes
Andrew
08-13-2021 08:03 AM
@AndrewIons01 wrote:
can I then take the image output of that image then display it onto an intensity graph with the box drawn on it.
Using an intensity graph seems a bit convoluted when you are already using IMAQ. Is there a reason for this?
08-13-2021 08:08 AM
Hi
we are using intensity graphs as it was what we decided to use early on in the project. Another reason is because it will show me exactly how far a beam has travelled.
Best Wishes
Andrew
08-13-2021 08:41 AM
Then how about using 2 cursors? This will show lines across the whole length and width but it is non-destructive.
08-13-2021 09:14 AM
Hi
Ramon
This sounds great, is it possible to define the gap between the cursors by a set amount i.e. can i use a numeric indicator to pre-define a width and height?
Best wishes
Andrew
08-13-2021 09:48 AM
Yes, you can programmatically set cursors.
08-13-2021 10:07 AM
Brilliant thank you so much, this works a treat.