Libtouch and more …

Today I saw this excellent HOWTO at on how to make your very own multi-touch pad, which is the coolest thing i’ve ever seen during the last two decades … *cough, cough* …

I haven’t made one myself yet, but I downloaded touchlib and I found it quite annoying that it used my built-in cam from my toshiba sattelite laptop however I plugged in another external one.

So, I did a quick fix to be able to use /dev/video1 … oh yeah, I tried this under Linux, more specifically Ubuntu, because I was lazy to setup all the libs with headers and shits under Windows.

In the CvCaptureFilter.cpp right in the void CvCaptureFilter::setParamater( … ) I added two more lines, so my version looks like this:

void CvCaptureFilter::setParameter(const char *name, 
                                   const char *value)
      if(strcmp( name, "source" ) == 0)
        strcpy(source, value);
        if(strcmp( value, "cam" ) == 0)
          capture = cvCaptureFromCAM( CV_CAP_ANY );
        else if(strcmp( value, "cam1" ) == 0)
          capture = cvCaptureFromCAM( 1 );
          capture = cvCaptureFromAVI(value);

With this done, i can just change in the “config.xml” the “source” to “cam1” and make use of my other camera device on /dev/video1 🙂

That’s all I need 😀

A few other thoughts … you can give an index from 0..99 to the cvCaptureFromCam( … ) and then it will try to find the first available driver for that particular device, or if you give something >=100 then it will try to use that particular driver with the first available video device; CV_CAP_ANY = 100 .


About icebreaker

Senior Software Engineer, Open Source Evangelist.

One response to “Libtouch and more …

  1. cerupcat

    Hi, I’m glad you liked the video!

    This is very interesting.

    For people using dsvl, there’s a dsvl_config.xml file where you can change which camera is used. IF you think this is a better way, i’d love to talk and maybe we can commit something to the touchlib svn so it’s easier for people to switch between multiple cameras.

    Right now, I just made a tutorial for editing dsvl_config.xml that will be included in the newest download package (hopefully released later today). This edit requires using graphedit and getting the camera’s “friendly_name.”
    I’d welcome an easier way though.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: