BBTouch, code, multitouch, openSoundControl

TUIO support is Here!22 Jul

And it even seems to work!

It is gratifying as a developer and code architect (not to toot my own horn, but, tooting my own horn :^) to be able to effectively use a chunk of my own code to add a fairly complex feature in just a few hours. I started fresh on TUIO about 4 hours ago, and because the BBOSC stuff is really easy to deploy and BBTouch is designed to be easily extended, I was done with the main bit of code about 2 hours ago! (spent the next 2 hours fiddling with processing, taking screengrabs, and committing the code to the google repository, and now writing this, which is bringing em up to the 5 hours mark oh well..) (it helps that the TUIO spec is fairly straightforward, and that it closely parallels how the BBTouch internals are structured)

Anyhow, BBTouch now supports the generation of TUIO style events via OSC and UDP. w00t!

OK, here are the details:

First up, since BBOSC is all ObjC 2.0 i went ahead and updated the objects I was stuck into on the BBtouch side as well (mostly just @properties and that sort of thing) the upside is that I saved lots of time implementing, the downside is that it is all OSX 10.5 only. So if you are still on OSX 10.4, and you really really want to run this, it should be fine, but it will take you a bit of elbow grease to replace all the @properties and @synthesize with actual methods. If i am totally screwing you with this change, then let me know and I will try to find time to downgrade all the code. but really, if you are into this stuff, then you are a geek like me and you should be running the bleeding edge OS :-)
Also, i included all the BBOSC files in the BBTouch project, so you wont need to deal with downloading the BBOSC stuff separately. (you really only need to do that if you want to build your own app on top of BBOSC)

Second: I updated the UI in BBtouch to add a TUIO config panel. Now you can just add the hostname and port (defaults to localhost/127.0.0.1 and port 3333 which seems to be the 'default' TUIO stuff), and turn on the 'generate TUIO events' button and it will do just that. (as long as you are also detecting blobs)

Note: if you want to change the host and port, you need to shut off the TUIO event stream first.

Oh, and a quick note about BBTouch performance: I dont have any trouble running it on my macbookpro in full size (640x480) but of you find yourself lagging a bit, you can close the config window and that will save a bunch of processing (since it wont need to be drawing all the raw video and whatnot). this leave BBTouch basically just a menu bar, but you can always get the config window back from the View Menu -> Show Config Window. (i noticed about a %20 drop in processor usage when I closed that window, although most of it is the raw video, so you can just shut that off too) Another Note: now that i have had a look at the processor usage %75!! yikes.. i guess the next thing is to do another optimization pass through the code. that is wayyy too high for what it is doing.. next week maybe :-)

I used the Processing/TUIODemo sketch to test with. (found on the reactivision software page) I plan on testing with some of the others as well, but I don't have time today, and I know you guys are chompin at the bit to get this :-)

As always the code is available on google code: http://code.google.com/p/opentouch/ you will need XCode to compile it.
If you already have some older code checked out, you should be able to update your project and get all the changes automatically.

I will leave you with the above image, a lame finger-painting of mine during testing.. :-)

EDIT: here is a zipped binary of the app for anyone who doesn't want to compile it from the source
bbtouchapp.zip (Universal, but 10.5 only)

No TweetBacks yet. (Be the first to Tweet this post)

12 Responses to “TUIO support is Here!”

  1. sandor 23 July 2008 at 2:44 am #

    Hey Ben,

    having some problems to run the actual version. I cannot access the camera settings. I tryed here with my Ligitech and my XBox cam connected. Since the last time on this Mac i used a FireI i will check that also tomorrow (took the cam home over the weekend)… Anyhow the app crashes when i try to enter the camera setting. No raw image is displayed. I am running on 10.5.2

    Regarding your last post: i’m a bit confused about. I mean tehre is an OSC sender and OSC listener in QC. There is also a TUIO plugin for QC. Now you have BBTouch for blob detection and TUI processing – why would you now need a plugin with Blob-Detection for QC? I would see to build apps in QC and use BBTouch for blob tracking and passing the coordinates via TUIO to the QC composition… I think that is what the two particle examples in the opentouch/trunk a supposed to do… Anyhow i’m very new to this QC-stuff so i might bee completly wrong ;-)))

    Cheers!

  2. thescreamingdrills 23 July 2008 at 5:47 am #

    I’m also having the problem of it crashing as soon as I click the camera settings button, I think it’s calling for something I don’t have on my computer. I am running 10.5.4 with quicktime 7.4.5 and everything else up to date. Here’s the report:

    Process: BBTouch [46277]
    Path: /Users/cyberedit/Downloads/BBTouch.app/Contents/MacOS/BBTouch
    Identifier: com.BB.BBTouch
    Version: ??? (1.0)
    Code Type: X86 (Native)
    Parent Process: launchd [139]

    Date/Time: 2008-07-22 12:45:23.160 -0700
    OS Version: Mac OS X 10.5.4 (9E17)
    Report Version: 6

    Exception Type: EXC_ARITHMETIC (SIGFPE)
    Exception Codes: EXC_I386_DIV (divide by zero)
    Crashed Thread: 0

    Thread 0 Crashed:
    0 …ickTimeComponents.component 0×967e80cf DestroySettingsDialog + 273
    1 …ickTimeComponents.component 0×967eb3f9 _SGSettingsDialog + 260
    2 …ple.CoreServices.CarbonCore 0×917c65cb CallComponentFunctionCommon + 1403
    3 …ickTimeComponents.component 0×967deb9b _SGComponentDispatch + 123
    4 …ple.CoreServices.CarbonCore 0×917c5f31 CallComponentDispatch + 29
    5 com.apple.QuickTime 0×915eb366 SGSettingsDialog + 74
    6 com.BB.BBTouch 0×000035d3 -[CSGCamera showSettings] + 85
    7 com.BB.BBTouch 0×000047f0 -[BBInputController showCameraSettings:] + 30
    8 com.apple.AppKit 0×9296bc23 -[NSApplication sendAction:to:from:] + 112
    9 com.apple.AppKit 0×9296bb60 -[NSControl sendAction:to:] + 108
    10 com.apple.AppKit 0×9296b9e6 -[NSCell _sendActionFrom:] + 169
    11 com.apple.AppKit 0×9296b03f -[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 1827
    12 com.apple.AppKit 0×9296a892 -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 541
    13 com.apple.AppKit 0×9296a14c -[NSControl mouseDown:] + 888
    14 com.apple.AppKit 0×9296888b -[NSWindow sendEvent:] + 5381
    15 com.apple.AppKit 0×92935431 -[NSApplication sendEvent:] + 2941
    16 com.apple.AppKit 0×92892e27 -[NSApplication run] + 847
    17 com.apple.AppKit 0×92860030 NSApplicationMain + 574
    18 com.BB.BBTouch 0×00001ef2 start + 54

    Thread 0 crashed with X86 Thread State (32-bit):
    eax: 0×00000000 ebx: 0×967eb306 ecx: 0×00000000 edx: 0×00000000
    edi: 0×001d2420 esi: 0×00000000 ebp: 0xbfffefa8 esp: 0xbfffef20
    ss: 0×0000001f efl: 0×00010246 eip: 0×967e80cf cs: 0×00000017
    ds: 0×0000001f es: 0×0000001f fs: 0×00000000 gs: 0×00000037
    cr2: 0xa076f50a

    Admin Edit: i just snipped off the big chunk of ugly core dump stuff.. the above stuff is all i really need for now :-)

  3. thescreamingdrills 23 July 2008 at 5:50 am #

    whoops, sorry to bombard you with the one error I found in the program, otherwise this thing is beautiful! I’m going to continue playing with it and see how it goes. Great work, I was very pleasantly surprised when I saw it up this morning. Is there anything more I can do to help? I don’t really know much about programming, but I bet there’s something I could do if you’d like any help.

  4. Ben 23 July 2008 at 8:42 am #

    Hey guys!

    errors are good! (i mean, ther arent good, but finding them is good, so don’t feel bad about posting errors :-)

    There is definitely something a bit flakey about the way I am storing and retrieving the camera settings. I am trying to figure out the issue. One temporary solution that I have had is to find the BBtouch preferences file (com.bb.bbtouch.plist i think it is called) and trash it (while the app is not running) then re-open the app and see how that goes.

    I had some issues with the same kind of thing (not crashing, but strange errors with the sequence grabber showing either no video, or a strange squished and tiled version of the video) Especially across versions of BBTouch. So, trash your prefs and let me know how it goes, and I will get stuck into the byzantine sequence grabber code and see if i can sort out the source of the problem.

    But, to reference what I said earlier: bring on the bugs! I cant fix them if you guys dont tell me about them, so don’t be shy. Also, the crash reports (like screamingdrills posted above) are very helpful.

    Cheers!
    -b

  5. Ben 23 July 2008 at 8:45 am #

    Sandor,
    to answer your question about QC, you are absolutely correct, that with BBTouch sending TUIO events to the TUIO QC patch, there is no need for a Blob Detector QC Patch. I just think it would be neat is all :-)

    Cheers!
    -b

  6. sandor 23 July 2008 at 7:21 pm #

    Hey Ben,

    yepp – you are right with the preferences. deleting the pref file lets you access the camera settings… The Fire-I make a bit of trouble tough… There are very little video setting you can pass thru BBTouch. Uncompressed video does not working. 60fps also not. B/W not etc… I am getting also the stylish pop-art videos in some setting you mentioned in your post :-) I guess that is the video-grabber as you are saying. BUT (and a BIG BUT): the blob detection works NICELY! I could test that only with a remote control (our table is not finished yet), but i recognises the blobs well and you can pass the TUIO stuff nicely to the Flash demos ;-)

    About QC: sorry! Stuped me! I even did not realise that the QC-TUIO-Patch only allows fiducials. And you are right – it is a good option to have the blob recognition and tracking also in QC. I had some ideas, but i need some time to line them out… Will post the ideas sometimes later to you (you know allways the boring clients with they payed jobs – LOL). But i stubled over some efforts going that way. Take a look at http://kineme.net/ and do a search for TUIO and OSC – those guys are also working in feature recognition inside QC…

    Keep it up you Kung-Fu-Panda!! :-)

    Sandor

  7. Ben 23 July 2008 at 7:34 pm #

    Hey Sandor,

    I have the fire-i and the settings i use that work well are:
    Compression type: component video – ccir – 601 uyvy
    frames per second: best (which is about 30)

    I have also used uncompressed 8 bit as well, didnt seem to make much of a difference in the end. I dont even know what the compressor is even doing (if anything at all)

    and in the image adjustments i set the brightness and exposure to manual and then adjust those two plus gain to get a nice looking image.

    cheers!
    -b

  8. thescreamingdrills 24 July 2008 at 7:57 am #

    Ok, so now everything is working fine, no crashes so far. However, I am having a different problem which is that I can’t get any blobs detected. I suspect this is because of how I am configuring bbtouch and the cam. Here’s a link to what I see:
    http://www.flickr.com/photos/27013844@N08/2697073836/ – I’m using an MTMini.

    That means my blobs are coming out black, but yours are white, does that matter? I also have brightness set high and contrast set high, which gives me some nice dark blobs.

    However, they are not recognized as blobs consistently. I’m not sure how to adjust the blob detection settings because I’m not sure what it’s doing. If I can just get past this step I think I can really help out more, with more testing and documentation.

    I know there are a lot of developers working on mac solutions, but for my money bbtouch looks the most promising and I’d really like to help it along anyway I can.

  9. Ben 24 July 2008 at 8:55 am #

    Hey Screaming drills,

    I knew this would happen at some point :-) in fact your blobs do need to be white (at the moment). Invert is one of the reasons that I am adding CIImage support (although invert is super duper easy to do, right in the blob detector)

    I dont think you can invert your camera input :-) so i will need to change the code real quick so that you can invert the way the detector compares the values. (it is probably about a three line change)

    I am about a day or two away from the CIImage update as a transport between the camera and the blob detector (making things like inversion REALLY simple)

    if you don’t want to wait (i know I never do :-) you should be able to get it working with a quick code change: (after having a quick refresh on the code)

    two changes: both in BBBlobDetector.m

    line 314 ish, in the -(BOOL)validBlobPixel:(int)position method
    change this line:
    if ((srcBytes[position] – bgBytes[position]) > threshold)
    to read:
    if (abs(srcBytes[position] – bgBytes[position]) > threshold)

    line 225ish in the -(void)scanSrcDataWithROI method
    change this line:
    if ((srcBytes[loopXYDataPosition] – bgBytes[loopXYDataPosition]) <= threshold)
    to read:
    if (abs(srcBytes[loopXYDataPosition] – bgBytes[loopXYDataPosition]) <= threshold)

    I THINK that will work :-) I am not actually at the machine with all my code and tests and stuff, so i cant test it out. later today I will be able to et back into it, but if you are as impatient as I am when you are so close, this might just hold you over until i get a better (ie CIImage/CIFilter) solution in place :-)

    cheers!
    -b

  10. thescreamingdrills 24 July 2008 at 9:41 am #

    It didn’t work for me, but that could very likely be I didn’t change it right. I just checked out another copy of r85, opened up the xcode project, made the changes, saved, and hit build and go.

    But if you are fixing this anyway, I can wait. I need to get back to wiring my led’s so I’ll have plenty to do while I wait for the changes.

    Thanks for the help!

  11. Ben 24 July 2008 at 9:44 am #

    Damn! I was so happy with myself for figuring that out.. meh thats what i get for trying to write code, in wordpress, early in the morning, before my caffeine… :-)

    Anyhow, I should hopefully have the CIIMage stuff all worky by the end of the week. (maybe sooner if I am lucky)

    Cheers!
    -b

  12. [...] came up with a brilliant on the spot fix, only to find out it wasn’t so brilliant after [...]

Leave a Reply

You must be logged in to post a comment.

About

meMy full name is Ben Britten Smith.

I go by Ben Britten because Ben Smith is a bit too common and using my full name is a mouthful.

I live in Melbourne, Australia and service clients all over the globe.

Contact

Have some questions?

Feel free to contact me directly at support@benbritten.com with any questions you might have about any of the applications I support.

Thanks!

PHVsPjxsaT48c3Ryb25nPndvb19hYm91dDwvc3Ryb25nPiAtIGFib3V0LXdpZGdldDwvbGk+PGxpPjxzdHJvbmc+d29vX2FkX2JlbG93X2ltYWdlPC9zdHJvbmc+IC0gaHR0cDovL2JlbmJyaXR0ZW4uY29tL3dwLWNvbnRlbnQvdGhlbWVzL3ZpYnJhbnRjbXMvaW1hZ2VzL2FkNDY4LmpwZzwvbGk+PGxpPjxzdHJvbmc+d29vX2FkX2JlbG93X3VybDwvc3Ryb25nPiAtIGh0dHA6Ly93d3cud29vdGhlbWVzLmNvbTwvbGk+PGxpPjxzdHJvbmc+d29vX2FsdF9zdHlsZXNo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