#39 regarding the webcam idea (openCV)


I noticed someone was talking about adding webcam support some time ago in aother rfe (see the sprites discussion), and I just wanted to say that these things are fairly simple to do using openCV. I don't know about Qt's degree of webcam support, but OpenCV can also be used to do headtracking and such things.

I imagine it would be relatively straightforward to capture a webcam image (photograph or video) and then copy it to an image buffer accessible from within kidbasic, so that kidbasic could be used for transforming such images. One could even use kidbasic to create funny faces using openCV (kai power goo).

Given the networking features that are now available basic256, it would then be a fairly simple task to even create a skype-like video chat program in kidbasic, i.e. just by supporting video/audio grabbing, saving in a memory buffer, transmitting over network.

I guess such a program could end up being pretty expressive, probably in under 50 lines of code.


  • I had some time yesterday to play with this, I used the two examples from the opencv wiki:

    I copied and pasted the code into Interpreter.cpp (adding a custom test operation) and this works rather well, and it would really bring a lot of potential to basic256, on the other hand openCV is a rather hefty dependency to be honest.

    It is however fairly easy to get working, and using the images it just a matter of converting to QImages so that they can be shown/manipulated using kidbasic instructions.

  • Jim Reneau
    Jim Reneau

    Thanks for the links showing how to do it. I added database and networking so that I could use the BASIC-256 language in a couple of my university classes (for non programmers to see how they work). I am trying to wrap my head around what this functionality would add to the language for the first time programmer.

    BASIC-256 includes functions to get and set points on the graphics output window but they are VERY slow. Manipulation of the captured still images would be possible (currently) but kludgy at best. Working with video or audio capture would push the little P-code engine, beyond. (IMHO)

    Before we rush into this support, what statements would you like to have added to make this functional and educational for the "First Time Programmer". I am afraid the "feature creature" is taking over (I know - part of it is me) the project. We need to keep the spirit of an educational language that will lead students to a more advanced language (like Python, Java, c) when they want to go further.


  • Hi, I was just looking into this because I always wanted to play around with openCV.

    The actual idea originated from another thread/RFE - I was just trying to provide pointers. I didn't plan to really try to do this myself, but it turned out not to be too complicated.

    I completely agree regarding feature creep ... that's a very valid concern. I was in fact thinking exactly that when I saw that BASIC-256 now even has SQLite support :-)

    FWIW, I don't really know if this idea should be pursued at all - but in the spirit of the original discussion, I agree that some more "modern" features are probably helpful to make BASIC 256 more interesting and frankly more relevant to new users, who often happen to be very familiar with new technologies like these.

    So I am really not looking for a specific use case or certain statements at all.
    I can just imagine that having access to more and more common hardware peripherals is a good thing, no matter if it is a webcam, a scanner, a microphone/sound card. It's a matter of exposing what's available I guess.
    And I agree, it's a fine line to walk ... it is far too easy to add arbitrary new things.

    There is certainly lots of potential with a dependency like OpenCV, the question is if it's worth it or not - I mean the additional overhead...especially for a beginners language

    I would suggest to actually try this with people who have little programming experience at all. To see how they resonate.

    But I suppose there is a fair share of people who will be able to relate to a "video chat" application (like skype), probably more so than to more conventional programming exercises (think towers of hanoi). But really, I don't know - I don't have kids myself, and I am also classically trained ... so I could only ask non-programmer friends about this.

    I really like the program, but I can't really estimate how valuable this addition would be in the long run. As a dependency I find openCV certainly far from trivial - and Qt already is a pretty huge beast in itself.

    Another thing to take into consideration is that this would be a hardware specific feature, i.e. it would require a webcam - so while this is nowadays a fairly common piece of equipment it surely isn't everywhere available. And from a project point of view, I could understand it if people wanted BASIC256 to work on all platforms, regardless of certain hardware being present or not ...

    Regarding audio processing, I also can't say what/if that would add to the language, I do remember having been exposed to a language that provided access to the MS SAPI (speech API) with support for speech synthesis and recognition - it was amusing at best, and wouldn't really work most of the time - especially the recognition part (not without prior speech recognitiion training).

    Bottom line being: I would also be careful about adding even more "cool features", certainly without having solid feedback from first time users in the first place ... it really is too easy to add all sorts of weird stuff to the language.

    Still, capturing still images at 10-20 hz, converting them to a memory buffer and sending them to another kidbasic program over network could probably be done in little more than 20-30 lines of code, and would probably illustrate quite well how these things are done in real life apps. I am still not saying that this is a good idea, though ;-)

    Maybe it would be better to use something like uservoice.com to have real polls among users, to ensure that not totally stupid/unpopular features get added?

    I don't know - like I said, I only played with this because I was already interested in OpenCV.