Retrieving and using blob size from CCV with AS3
8 years ago
One thing I have been wanting to do for a quite a while now with my touch screen is use touch size data to determine the size of lines drawn on the screen. The other day I finally got around to researching experimenting with CCV. It turns out that CCV can send the width and height of blobs along with coordinates and other data but its not turned on by default and there is no option in the GUI to turn it on.
Here’s a quick demo using a paint brush:
After digging around in CCV’s config XML file, here is how I got touch size to work in Flash.
1. Find the app_settings.xml for CCV (for CCV 1.5 it is in the following location C:\Program Files (x86)\NUI Group\Community Core Vision\data\xml)
2. In it you will find the following node in the <BOOLEAN> node: <HEIGHTWIDTH>0</HEIGHTWIDTH>
3. Change the value to 1 and save. Now CCV will send height and width data.
4. To get the data in Flash I used the old TouchLib TUIO AS3 library – mainly because its the only TUIO library I’ve really used and it just works. I had to make some small modifications to make the size data accessible.
5. First I opened the TUIOObject.as file and and changed the internal vars width and height to public (this could also be done via getters).
6. I also had to change every instance of ‘TouchEvent’ to ‘TouchEventTUIO’ to avoid conflicts with the built in TouchEvent class.
7. Now these properties can be accessed. Connect as usual and as a touch event listener
TUIO.init( this, ‘127.0.0.1’, 3000, ”, true );
8. Then, on in the handler the data can be accessed via the TUIO class
var to:TUIOObject = TUIO.getObjectById(e.ID);
trace(“blob width: “+to.width + ” , blob height: ” + to.height);
[/code]Author: Ben Foster Date: March 16, 2012