Vision Distance Question

This is the first year we’ve really tried vision, so if I seem lost, it’s because all of vision is pretty much new to me, but I successfully integrated the 2017 vision example code into our vision code for this year. The camera display in vision shows the camera, and is filtering to show only our reflective tape correctly, however, the distance reading comes back as infinite(inf). Any ideas?

We your vision finds the target is the box red or green? You can change the threshold value to lower the level and it should turn green. You may also have to look a the code to see what you are not getting. When I went through the code the first time I noticed that it needed four points to calculate the distance. I made my own that only requires the line to get the distance. It seems to work really well. If you can not figure it out let me know and I will send you our distance code.

Try this:

It finds it as red currently. I appreciate the replies and links, I’ll try changing the threshold later today and update on the results, if that doesn’t work I’ll give those pdf links a go. Thanks for the replies!

Red means it doesn’t have a valid targst. Try changing the score cutoff.

His problem is probably that the line along which it searches for edges is vertical, thus not crossing any stripes. This causes the distance calculation to fail, regardless of score cutoff. The line also needs to extend a few pixels past the overall bounding rectangle on either end.

Now I’m getting errors. I changed nothing coming into today but as soon as I connect my driver station started pumping out errors like there was no tomorrow. This was the error: ERROR 1043 Register For Events in Calibration>Vision>Robot Main.viLabVIEW: The property or method is not supported in this version of LabVIEW. ERROR -1074395152 IMAQ Vision: (Hex 0xBFF607F0) Font file not found. ERROR -1074395152 IMAQ Vision: (Hex 0xBFF607F0) Font file not found. ERROR 1043 Register For Events in Calibration>Vision>Robot Main.viLabVIEW: The property or method is not supported in this version of LabVIEW.

Any ideas?

Font file not found is okay, it means the font for the scoring numbers that are overlayed on the displayed images in the front panel of vision isn’t on the RoboRIO.
For the other error, you will need to remove the calibration code (or disable it). When targeting the peg, calibration does pretty much nothing.
Make sure that when you want to save changes to values entered in the front panel, right click -> data operations -> make current value default, then save the VI. Otherwise, it will reset the value on you when you close the VI or try to build the project.

The errors about the event not being supported are caused by putting desktop code on the roboRIO. There is a call to the calibration helper that passes the reference to the picture control. This lets you click and draw a line on the colored region and it calculates the HSL range settings based on your statistic settings.

But this can’t work in a headless RT environment. In that situation, you remove the cal from the roboRIO, and if you still want it, you put it into your dashboard and share the results to the robot.

Greg McKaskle

I resolved the errors, thank you for the help on that, but now I’m back to the first problem. I tried lowering the score cutoff and using a horizontal line, but both still come back red with an infinite reading. Any ideas?

Increase your line border values, they need to be greater than, say, 2 or 3, and by default they are 6 and 1.

Alright, I’m getting readings perfectly now if I put the reflective tape horizontal, rather than vertical, because with the code that I have now, I can’t do the mouse drag to calibrate it, and I can’t figure out how to make the calibration line horizontal instead of vertical. I tried switching the control for that in the distance calculation subVI, but it had no effect. Where do is the option for it to track horizontally rather than vertically as it does by default?

The line isn’t a calibration line, it’s the distance calculation line. That line is drawn in Rectangle, near the top of the block diagram. You can’t draw that line, the program has to draw the line based on the position of the particles.

Even after all of this it still is reading infinite. It appears to still be using a vertical line instead of a horizontal. I’m clueless as to what I’m doing wrong at this point.

I think the problem is the number of qualified particles I’m getting. I can’t get more than 2 or 3 of them. Any ideas as to why or how to fix it?

Nevermind, it just wasn’t picking up the reflective tape brightly enough, I just had to play around with the exposure settings, so I think I have it working now, however, I never could get the line to search horizontally, so I ended up turning the camera on its side, but it’s reading distance with it like that so I’m pretty sure it works.

You only need 2 qualified particles, so that’s highly unlikely to be a problem.

Look closely at the way I wired my scoring code in the upper right. Very closely. That’s how you get the line to be horizontal.

If even that fails, post your code here.

Got it to work, thank you so much for all the help! One more question, is it okay that the score is averaging around 38? It may just be the lighting of the room I’m in, I’m not sure, but is that okay?

Yeah, that’s okay. As I said, it’s far from perfect, and no it’s not the lighting in the room, it’s the halfhearted scoring algorithm.

Sent from my iPod touch using Tapatalk

Gotcha, thank you again for all the help!