See: http://nuigroup.com/wiki/Basic_Touchlib_Application/
// main.cpp
#pragma once
#pragma comment( lib, "user32" )
#define WIN32_LEAN_AND_MEAN
#define _WIN32_WINNT 0x0500
#include <windows.h>
#include <cv.h>
#include <cxcore.h>
#include <highgui.h>
#include <map>
#include <tchar.h>
#include "TouchScreenDevice.h"
#include "TouchData.h"
#include <stdio.h>
#include <cvcam.h>
using namespace touchlib;
bool show_window=true;
ITouchScreen *screen;
class HelloFinger : public ITouchListener
{
public:
HelloFinger()
{
}
~HelloFinger()
{
}
virtual void fingerDown(TouchData data)
{
printf("TOUCH_DOWN: %f, %f\n",data.X, data.Y);
}
virtual void fingerUpdate(TouchData data)
{
printf("TOUCH_MOVE: %f, %f\n",data.X, data.Y);
}
virtual void fingerUp(TouchData data)
{
printf("TOUCH_UP: %f, %f\n", data.X, data.Y);
}
private:
//
};
HelloFinger app;
int _tmain(int argc, char * argv[])
{
screen = TouchScreenDevice::getTouchScreen();
cvNamedWindow( "Hello Finger", CV_WINDOW_AUTOSIZE );
//! SET CONFIG MODE (Boolean)
screen->setDebugMode(false);
std::string recLabel,bgLabel;
if(!screen->loadConfig("config.xml"))
{
std::string capLabel = screen->pushFilter("dsvlcapture");
screen->pushFilter("mono");
screen->pushFilter("smooth");
bgLabel = screen->pushFilter("backgroundremove");
std::string bcLabel = screen->pushFilter("brightnesscontrast");
recLabel = screen->pushFilter("rectify");
screen->setParameter(recLabel, "level", "25");
screen->setParameter(capLabel, "source", "cam");
screen->setParameter(bcLabel, "brightness", "0.1");
screen->setParameter(bcLabel, "contrast", "0.4");
screen->saveConfig("config.xml");
}else{
recLabel = screen->findFirstFilter("rectify");
bgLabel = screen->findFirstFilter("backgroundremove");
}
screen->registerListener((ITouchListener *)&app);
screen->beginProcessing();
SLEEP(1000);
screen->setParameter(bgLabel, "mask", (char*)screen->getCameraPoints());
screen->setParameter(bgLabel, "capture", "");
screen->beginTracking();
do
{
// main loop.. do any graphics or sound updates here
screen->getEvents();
SLEEP(16);
} while( show_window );
cvDestroyWindow( "Hello Finger" );
//screen->saveConfig("config.xml");
TouchScreenDevice::destroy();
return 0;
}
