03-25-2014 03:08 PM
I'm trying to use a XY graph as an input device (virtual joystick) that controls a crosshair nad also provides coordinates inside a live video feedback from a webcam in labview 2012 64bit , but I can't get the VI to work properly. I've made the VI for the "virtual joystick" and for the video feedback . I can't figure out how to make the VI for the crosshair.
03-26-2014 07:58 PM
Nikio17,
Please take a look at these two forums. I think this will help you.
How do I add a cross hair to a xy chart - Discussion Forums
http://forums.ni.com/t5/LabVIEW/How-do-I-add-a-cross-hair-to-a-xy-chart/td-p/627088
XY Graph Cursor - Discussion Forums
http://forums.ni.com/t5/LabVIEW/XY-Graph-Cursor/m-p/110625?query.id=8335#M66922
William Fernandez
Applications Engineer
National Instruments
03-27-2014 12:19 AM
To use a cursor of an XY graph as a 2D control, the graph does not need to be a control, it can as well be an indicator.
It seems using an xy graph is overkill adds a bit too much overhead, because you only use 5% of the xy-graph functionality. You could easily use e.g. a picture indicator. If you would use a picture indicator, you could even draw some stylized background looking like a joystick as a function of mouse position, for example. You would need to keep the "mouse down" state in a shift register, and only react to mouse positions while the button is held down.
If you want to use a cursor of an xy graph, you should do a few things. For example you should disable "cursors scroll graphs", else the axes will scroll when the cursor is moved past the boundary. Your code also spins the while loop like crazy. All you need is spin the loop when the cursor changes. Use an event structure. Attached is a very simple rewrite of your code. (You still should ensure that the cursors remain coerced to the plot area, not shown).
03-27-2014 12:55 AM
As I said, a 2D picture is probably an better way to do this. Here is a very simple example.