loading
 
programatically moving line profile
steve from United States  [3 posts]
7 years
Newbie question (I have read the tutorials and docs). I'm not fully grasping how to do things with the VBscript plugin or the API and could use some help.

I'd like to open an image file and draw a line profile line, with the red box and the green box starting at some particular x and y.

Then, I'd like to decrement the y, walking the horizontal line down until the max value on the line profile histogram exceeds k. Then I'd like to read the coordinates of the line.

How do I do it in VBscript? Do I use execute command? Do I wrap the instruction in XML? And more importantly, how do I even know where to begin.....help.

Thanks

Baghdad_boy from New Zealand  [11 posts] 7 years
Hey Steve,

Can you explain your situation a bit more clearly. What do you mean by drawing a profile line with a red box and a green box? What is your image of?

I you want to draw a line you can use the Display Line module. You can also set from within that module where you want it to read the line coordinates from, for example using the Point Location filter you can set it to the highest point or lowest point etc.

In the end all you need the VBscript to read is the point which will come out of one of the variables. You can even just use Watch Variable

At the end, I'm a bit confused as to what exactly you want to do. So if you can attach a sample image or explain what sort of application you are using it in, maybe I can help a bit more.

Cheers
Baghdad_boy
steve from United States  [3 posts] 7 years
Sorry I wasn't clear. Are you familiar with using the rr menu to draw a line profile with the mouse? Well, I simply want to do the same programmatically.
I imagine, in pseudocode (or VB script) i would look something like this:

**********************************************************
linevar = line_profile.new

//position the left fixed point of the line
linevar.left_x = 100;
linevar.left_y = 300 ;

//position the right fixed point of the line
linevar.right_x = 250;
linevar.right_y = 300 ;

//now there is a line profile from left to right, spanning 150 pixels
//The background of the image is all white. There is a random shaped black //object somewhere below the line. I want to move the line downwards,
//pixel by pixel until I detect the black object

//but first, since the line profile is drawn against a white surface, all of the
//values returned from the line profile histogram are 255. I'll detect the
//black object the instant one of the values drops below, say 230

while linvar.histogram_max >= 230
       linevar.right_x --;
       linevar.left_x --;
  Loop

//now we have detected the distance of the object
Msgbox("distance from top is " + str(linevar.right_x);

***********************************************

Now, I know enough from reading the docs that there are not public member functions as I have described above in pseudocode, I'll somehow have to do wrap the commands in XML or something. That's what I need help with- how do I do the above task in code?

Thanks!

Steve



      








Anonymous 7 years
Hi Steve,

I made a video for you on Youtube. I hope I've understood your question correctly. If not, please let me know and I'll give it another try. Thanks for asking the quesiton. This is helping learn to use Roborealm, practice makes perfect :)

http://www.youtube.com/watch?v=_JUwxvpMaw8

The way I did it is different to your method but I found it to be easier.

The source file is attached. From here you can open the Robo file in a text editor if you want to manipulate the variable any further or customise it. Otherwise you can use VBScript like I did in the video.

I had to cut the video short because of time constraints so the source file has some extra things that will let you measure the distance of the highest point from the top of the image.

I hope you find the video useful.
program.robo
steve from United States  [3 posts] 7 years
Thank you!

This is VERY helpful, I am genuinely appreciative. I continue to be impressed with this product an the support from fellow users. I hope I can return the favor.

The help, the code, and the video were over the top! That's awesome.

Steve

This forum thread has been closed due to inactivity (more than 4 months) or number of replies (more than 50 messages). Please start a New Post and enter a new forum thread with the appropriate title.

 New Post   Forum Index