report.tex 60 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111
  1. \documentclass[twoside,openright]{uva-bachelor-thesis}
  2. \usepackage[english]{babel}
  3. \usepackage[utf8]{inputenc}
  4. \usepackage{hyperref,graphicx,tikz,subfigure,float}
  5. % Link colors
  6. \hypersetup{colorlinks=true,linkcolor=black,urlcolor=blue,citecolor=DarkGreen}
  7. % Title Page
  8. \title{A generic architecture for gesture-based interaction}
  9. \author{Taddeüs Kroes}
  10. \supervisors{Dr. Robert G. Belleman (UvA)}
  11. \signedby{Dr. Robert G. Belleman (UvA)}
  12. \begin{document}
  13. % Title page
  14. \maketitle
  15. \begin{abstract}
  16. Applications that use complex gesture-based interaction need to translate
  17. primitive messages from low-level device drivers to complex, high-level
  18. gestures, and map these gestures to elements in an application. This report
  19. presents a generic architecture for the detection of complex gestures in an
  20. application. The architecture translates device driver messages to a common
  21. set of ``events''. The events are then delegated to a tree of ``event
  22. areas'', which are used to separate groups of events and assign these
  23. groups to an element in the application. Gesture detection is performed on
  24. a group of events assigned to an event area, using detection units called
  25. ``gesture tackers''. An implementation of the architecture as a daemon
  26. process would be capable of serving gestures to multiple applications at
  27. the same time. A reference implementation and two test case applications
  28. have been created to test the effectiveness of the architecture design.
  29. % TODO: conclusions
  30. \end{abstract}
  31. % Set paragraph indentation
  32. \parindent 0pt
  33. \parskip 1.5ex plus 0.5ex minus 0.2ex
  34. % Table of content on separate page
  35. \tableofcontents
  36. \chapter{Introduction}
  37. \label{chapter:introduction}
  38. Surface-touch devices have evolved from pen-based tablets to single-touch
  39. trackpads, to multi-touch devices like smartphones and tablets. Multi-touch
  40. devices enable a user to interact with software using hand gestures, making the
  41. interaction more expressive and intuitive. These gestures are more complex than
  42. primitive ``click'' or ``tap'' events that are used by single-touch devices.
  43. Some examples of more complex gestures are ``pinch''\footnote{A ``pinch''
  44. gesture is formed by performing a pinching movement with multiple fingers on a
  45. multi-touch surface. Pinch gestures are often used to zoom in or out on an
  46. object.} and ``flick''\footnote{A ``flick'' gesture is the act of grabbing an
  47. object and throwing it in a direction on a touch surface, giving it momentum to
  48. move for some time after the hand releases the surface.} gestures.
  49. The complexity of gestures is not limited to navigation in smartphones. Some
  50. multi-touch devices are already capable of recognizing objects touching the
  51. screen \cite[Microsoft Surface]{mssurface}. In the near future, touch screens
  52. will possibly be extended or even replaced with in-air interaction (Microsoft's
  53. Kinect \cite{kinect} and the Leap \cite{leap}).
  54. The interaction devices mentioned above generate primitive events. In the case
  55. of surface-touch devices, these are \emph{down}, \emph{move} and \emph{up}
  56. events. Application programmers who want to incorporate complex, intuitive
  57. gestures in their application face the challenge of interpreting these
  58. primitive events as gestures. With the increasing complexity of gestures, the
  59. complexity of the logic required to detect these gestures increases as well.
  60. This challenge limits, or even deters the application developer to use complex
  61. gestures in an application.
  62. The main question in this research project is whether a generic architecture
  63. for the detection of complex interaction gestures can be designed, with the
  64. capability of managing the complexity of gesture detection logic. The ultimate
  65. goal would be to create an implementation of this architecture that can be
  66. extended to support a wide range of complex gestures. With the existence of
  67. such an implementation, application developers do not need to reinvent gesture
  68. detection for every new gesture-based application.
  69. \section{Contents of this document}
  70. The scope of this thesis is limited to the detection of gestures on
  71. multi-touch surface devices. It presents a design for a generic gesture
  72. detection architecture for use in multi-touch based applications. A
  73. reference implementation of this design is used in some test case
  74. applications, whose purpose is to test the effectiveness of the design and
  75. detect its shortcomings.
  76. Chapter \ref{chapter:related} describes related work that inspired the
  77. design of the architecture. The design is described in chapter
  78. \ref{chapter:design}. Chapter \ref{chapter:implementation} presents a
  79. reference implementation of the architecture. Two test case applications
  80. show the practical use of the architecture components in chapter
  81. \ref{chapter:test-applications}. Chapter \ref{chapter:conclusions}
  82. formulates some conclusions about the architecture design and its
  83. practicality. Finally, some suggestions for future research on the subject
  84. are given in chapter \ref{chapter:futurework}.
  85. \chapter{Related work}
  86. \label{chapter:related}
  87. Applications that use gesture-based interaction need a graphical user
  88. interface (GUI) on which gestures can be performed. The creation of a GUI
  89. is a platform-specific task. For instance, Windows and Linux support
  90. different window managers. To create a window in a platform-independent
  91. application, the application would need to include separate functionalities
  92. for supported platforms. For this reason, GUI-based applications are often
  93. built on top of an application framework that abstracts platform-specific
  94. tasks. Frameworks often include a set of tools and events that help the
  95. developer to easily build advanced GUI widgets.
  96. % Existing frameworks (and why they're not good enough)
  97. Some frameworks, such as Nokia's Qt \cite{qt}, provide support for basic
  98. multi-touch gestures like tapping, rotation or pinching. However, the
  99. detection of gestures is embedded in the framework code in an inseparable
  100. way. Consequently, an application developer who wants to use multi-touch
  101. interaction in an application, is forced to use an application framework
  102. that includes support for those multi-touch gestures that are required by
  103. the application. Kivy \cite{kivy} is a GUI framework for Python
  104. applications, with support for multi-touch gestures. It uses a basic
  105. gesture detection algorithm that allows developers to define custom
  106. gestures to some degree \cite{kivygesture} using a set of touch point
  107. coordinates. However, these frameworks do not provide support for extension
  108. with custom complex gestures.
  109. Many frameworks are also device-specific, meaning that they are developed
  110. for use on either a tablet, smartphone, PC or other device. OpenNI
  111. \cite{OpenNI2010}, for example, provides API's for only natural interaction
  112. (NI) devices such as webcams and microphones. The concept of complex
  113. gesture-based interaction, however, is applicable to a much wider set of
  114. devices. VRPN \cite{VRPN} provides a software library that abstracts the
  115. output of devices, which enables it to support a wide set of devices used
  116. in Virtual Reality (VR) interaction. The framework makes the low-level
  117. events of these devices accessible in a client application using network
  118. communication. Gesture detection is not included in VRPN.
  119. % Methods of gesture detection
  120. The detection of high-level gestures from low-level events can be
  121. approached in several ways. GART \cite{GART} is a toolkit for the
  122. development of gesture-based applications, which states that the best way
  123. to classify gestures is to use machine learning. The programmer trains an
  124. application to recognize gestures using a machine learning library from the
  125. toolkit. Though multi-touch input is not directly supported by the toolkit,
  126. the level of abstraction does allow for it to be implemented in the form of
  127. a ``touch'' sensor. The reason to use machine learning is that gesture
  128. detection ``is likely to become increasingly complex and unmanageable''
  129. when using a predefined set of rules to detect whether some sensor input
  130. can be classified as a specific gesture.
  131. The alternative to machine learning is to define a predefined set of rules
  132. for each gesture. Manoj Kumar \cite{win7touch} presents a Windows 7
  133. application, written in Microsofts .NET, which detects a set of basic
  134. directional gestures based on the movement of a stylus. The complexity of
  135. the code is managed by the separation of different gesture types in
  136. different detection units called ``gesture trackers''. The application
  137. shows that predefined gesture detection rules do not necessarily produce
  138. unmanageable code.
  139. \section{Analysis of related work}
  140. Implementations for the support of complex gesture based interaction do
  141. already exist. However, gesture detection in these implementations is
  142. device-specific (Nokia Qt and OpenNI) or limited to use within an
  143. application framework (Kivy).
  144. An abstraction of device output allows VRPN and GART to support multiple
  145. devices. However, VRPN does not incorporate gesture detection. GART does,
  146. but only in the form of machine learning algorithms. Many applications for
  147. mobile phones and tablets only use simple gestures such as taps. For this
  148. category of applications, machine learning is an excessively complex method
  149. of gesture detection. Manoj Kumar shows that when managed well, a
  150. predefined set of gesture detection rules is sufficient to detect simple
  151. gestures.
  152. This thesis explores the possibility to create an architecture that
  153. combines support for multiple input devices with different methods of
  154. gesture detection.
  155. \chapter{Design}
  156. \label{chapter:design}
  157. % Diagrams are defined in a separate file
  158. \input{data/diagrams}
  159. \section{Introduction}
  160. Application frameworks are a necessity when it comes to fast,
  161. cross-platform development. A generic architecture design should aim to be
  162. compatible with existing frameworks, and provide a way to detect and extend
  163. gestures independent of the framework. Since an application framework is
  164. written in a specific programming language, the architecture should be
  165. accessible for applications using a language-independent method of
  166. communication. This intention leads towards the concept of a dedicated
  167. gesture detection application that serves gestures to multiple applications
  168. at the same time.
  169. This chapter describes a design for such an architecture. The architecture
  170. components are shown by figure \ref{fig:fulldiagram}. Sections
  171. \ref{sec:multipledrivers} to \ref{sec:daemon} explain the use of all
  172. components in detail.
  173. \fulldiagram
  174. \newpage
  175. \section{Supporting multiple drivers}
  176. \label{sec:multipledrivers}
  177. The TUIO protocol \cite{TUIO} is an example of a driver that can be used by
  178. multi-touch devices. TUIO uses ALIVE- and SET-messages to communicate
  179. low-level touch events (section\ref{sec:tuio} describes these in more
  180. detail). These messages are specific to the API of the TUIO protocol.
  181. Other drivers may use different messages types. To support more than one
  182. driver in the architecture, there must be some translation from
  183. device-specific messages to a common format for primitive touch events.
  184. After all, the gesture detection logic in a ``generic'' architecture should
  185. not be implemented based on device-specific messages. The event types in
  186. this format should be chosen so that multiple drivers can trigger the same
  187. events. If each supported driver would add its own set of event types to
  188. the common format, the purpose of it being ``common'' would be defeated.
  189. A minimal expectation for a touch device driver is that it detects simple
  190. touch points, with a ``point'' being an object at an $(x, y)$ position on
  191. the touch surface. This yields a basic set of events: $\{point\_down,
  192. point\_move, point\_up\}$.
  193. The TUIO protocol supports fiducials\footnote{A fiducial is a pattern used
  194. by some touch devices to identify objects.}, which also have a rotational
  195. property. This results in a more extended set: $\{point\_down, point\_move,
  196. point\_up, object\_down, object\_move, object\_up,\\ object\_rotate\}$.
  197. Due to their generic nature, the use of these events is not limited to the
  198. TUIO protocol. Another driver that can keep apart rotated objects from
  199. simple touch points could also trigger them.
  200. The component that translates device-specific messages to common events, is
  201. called the \emph{event driver}. The event driver runs in a loop, receiving
  202. and analyzing driver messages. When a sequence of messages is analyzed as
  203. an event, the event driver delegates the event to other components in the
  204. architecture for translation to gestures.
  205. Support for a touch driver can be added by adding an event driver
  206. implementation. The choice of event driver implementation that is used in an
  207. application is dependent on the driver support of the touch device being
  208. used.
  209. Because event driver implementations have a common output format in the
  210. form of events, multiple event drivers can be used at the same time (see
  211. figure \ref{fig:multipledrivers}). This design feature allows low-level
  212. events from multiple devices to be aggregated into high-level gestures.
  213. \multipledriversdiagram
  214. \section{Event areas: connecting gesture events to widgets}
  215. \label{sec:areas}
  216. Touch input devices are unaware of the graphical input
  217. widgets\footnote{``Widget'' is a name commonly used to identify an element
  218. of a graphical user interface (GUI).} rendered by an application, and
  219. therefore generate events that simply identify the screen location at which
  220. an event takes place. User interfaces of applications that do not run in
  221. full screen modus are contained in a window. Events which occur outside the
  222. application window should not be handled by the application in most cases.
  223. What's more, a widget within the application window itself should be able
  224. to respond to different gestures. E.g. a button widget may respond to a
  225. ``tap'' gesture to be activated, whereas the application window responds to
  226. a ``pinch'' gesture to be resized. In order to restrict the occurence of a
  227. gesture to a particular widget in an application, the events used for the
  228. gesture must be restricted to the area of the screen covered by that
  229. widget. An important question is if the architecture should offer a
  230. solution to this problem, or leave the task of assigning gestures to
  231. application widgets to the application developer.
  232. If the architecture does not provide a solution, the ``gesture detection''
  233. component in figure \ref{fig:fulldiagram} receives all events that occur on
  234. the screen surface. The gesture detection logic thus uses all events as
  235. input to detect a gesture. This leaves no possibility for a gesture to
  236. occur at multiple screen positions at the same time. The problem is
  237. illustrated in figure \ref{fig:ex1}, where two widgets on the screen can be
  238. rotated independently. The rotation detection component that detects
  239. rotation gestures receives all four fingers as input. If the two groups of
  240. finger events are not separated by clustering them based on the area in
  241. which they are placed, only one rotation event will occur.
  242. \examplefigureone
  243. A gesture detection component could perform a heuristic way of clustering
  244. based on the distance between events. However, this method cannot guarantee
  245. that a cluster of events corresponds with a particular application widget.
  246. In short, a gesture detection component is difficult to implement without
  247. awareness of the location of application widgets. Secondly, the
  248. application developer still needs to direct gestures to a particular widget
  249. manually. This requires geometric calculations in the application logic,
  250. which is a tedious and error-prone task for the developer.
  251. The architecture described here groups events that occur inside the area
  252. covered by a widget, before passing them on to a gesture detection
  253. component. Different gesture detection components can then detect gestures
  254. simultaneously, based on different sets of input events. An area of the
  255. screen surface is represented by an \emph{event area}. An event area
  256. filters input events based on their location, and then delegates events to
  257. gesture detection components that are assigned to the event area. Events
  258. which are located outside the event area are not delegated to its gesture
  259. detection components.
  260. In the example of figure \ref{fig:ex1}, the two rotatable widgets can be
  261. represented by two event areas, each having a different rotation detection
  262. component. Each event area can consist of four corner locations of the
  263. square it represents. To detect whether an event is located inside a
  264. square, the event areas use a point-in-polygon (PIP) test \cite{PIP}. It is
  265. the task of the client application to update the corner locations of the
  266. event area with those of the widget.
  267. \subsection{Callback mechanism}
  268. When a gesture is detected by a gesture detection component, it must be
  269. handled by the client application. A common way to handle events in an
  270. application is a ``callback'' mechanism: the application developer binds a
  271. function to an event, that is called when the event occurs. Because of the
  272. familiarity of this concept with developers, the architecture uses a
  273. callback mechanism to handle gestures in an application. Callback handlers
  274. are bound to event areas, since event areas control the grouping of events
  275. and thus the occurrence of gestures in an area of the screen.
  276. \subsection{Area tree}
  277. \label{sec:tree}
  278. A basic data structure of event areas in the architecture would be a list
  279. of event areas. When the event driver delegates an event, it is accepted by
  280. each event area that contains the event coordinates.
  281. If the architecture were to be used in combination with an application
  282. framework, each widget that responds to gestures should have a mirroring
  283. event area that synchronizes its location with that of the widget. Consider
  284. a panel with five buttons that all listen to a ``tap'' event. If the
  285. location of the panel changes as a result of movement of the application
  286. window, the positions of all buttons have to be updated too.
  287. This process is simplified by the arrangement of event areas in a tree
  288. structure. A root event area represents the panel, containing five other
  289. event areas which are positioned relative to the root area. The relative
  290. positions do not need to be updated when the panel area changes its
  291. position. GUI frameworks use this kind of tree structure to manage
  292. graphical widgets.
  293. If the GUI toolkit provides an API for requesting the position and size of
  294. a widget, a recommended first step when developing an application is to
  295. create a subclass of the area that automatically synchronizes with the
  296. position of a widget from the GUI framework. For example, the test
  297. application described in section \ref{sec:testapp} extends the GTK
  298. \cite{GTK} application window widget with the functionality of a
  299. rectangular event area, to direct touch events to an application window.
  300. \subsection{Event propagation}
  301. \label{sec:eventpropagation}
  302. Another problem occurs when event areas overlap, as shown by figure
  303. \ref{fig:eventpropagation}. When the white square is dragged, the gray
  304. square should stay at its current position. This means that events that are
  305. used for dragging of the white square, should not be used for dragging of
  306. the gray square. The use of event areas alone does not provide a solution
  307. here, since both the gray and the white event area accept an event that
  308. occurs within the white square.
  309. The problem described above is a common problem in GUI applications, and
  310. there is a common solution (used by GTK \cite{gtkeventpropagation}, among
  311. others). An event is passed to an ``event handler''. If the handler returns
  312. \texttt{true}, the event is considered ``handled'' and is not
  313. ``propagated'' to other widgets. Applied to the example of the draggable
  314. squares, the rotation detection component of the white square should stop
  315. the propagation of events to the event area of the gray square.
  316. In the example, rotation of the white square has priority over rotation of
  317. the gray square because the white area is the widget actually being touched
  318. at the screen surface. In general, events should be delegated to event
  319. areas according to the order in which the event areas are positioned over
  320. each other. The tree structure in which event areas are arranged, is an
  321. ideal tool to determine the order in which an event is delegated. An
  322. object touching the screen is essentially touching the deepest event area
  323. in the tree that contains the triggered event, which must be the first to
  324. receive the event. When the gesture trackers of the event area are
  325. finished with the event, it is propagated to the siblings and parent in the
  326. event area tree. Optionally, a gesture tracker can stop the propagation of
  327. the event by its corresponding event area. Figure
  328. \ref{fig:eventpropagation} demonstrates event propagation in the example of
  329. the draggable squares.
  330. \eventpropagationfigure
  331. An additional type of event propagation is ``immediate propagation'', which
  332. indicates propagation of an event from one gesture detection component to
  333. another. This is applicable when an event area uses more than one gesture
  334. detection component. When regular propagation is stopped, the event is
  335. propagated to other gesture detection components first, before actually
  336. being stopped. One of the components can also stop the immediate
  337. propagation of an event, so that the event is not passed to the next
  338. gesture detection component, nor to the ancestors of the event area.
  339. The concept of an event area is based on the assumption that the set of
  340. originating events that form a particular gesture, can be determined
  341. exclusively based on the location of the events. This is a reasonable
  342. assumption for simple touch objects whose only parameter is a position,
  343. such as a pen or a human finger. However, more complex touch objects can
  344. have additional parameters, such as rotational orientation or color. An
  345. even more generic concept is the \emph{event filter}, which detects whether
  346. an event should be assigned to a particular gesture detection component
  347. based on all available parameters. This level of abstraction provides
  348. additional methods of interaction. For example, a camera-based multi-touch
  349. surface could make a distinction between gestures performed with a blue
  350. gloved hand, and gestures performed with a green gloved hand.
  351. As mentioned in the introduction chapter [\ref{chapter:introduction}], the
  352. scope of this thesis is limited to multi-touch surface based devices, for
  353. which the \emph{event area} concept suffices. Section \ref{sec:eventfilter}
  354. explores the possibility of event areas to be replaced with event filters.
  355. \section{Detecting gestures from low-level events}
  356. \label{sec:gesture-detection}
  357. The low-level events that are grouped by an event area must be translated
  358. to high-level gestures in some way. Simple gestures, such as a tap or the
  359. dragging of an element using one finger, are easy to detect by comparing
  360. the positions of sequential $point\_down$ and $point\_move$ events. More
  361. complex gestures, like the writing of a character from the alphabet,
  362. require more advanced detection algorithms.
  363. Sequences of events that are triggered by a multi-touch based surfaces are
  364. often of a manageable complexity. An imperative programming style is
  365. sufficient to detect many common gestures, like rotation and dragging. The
  366. imperative programming style is also familiar and understandable for a wide
  367. range of application developers. Therefore, the architecture should support
  368. this style of gesture detection. A problem with an imperative programming
  369. style is that the explicit detection of different gestures requires
  370. different gesture detection components. If these components are not managed
  371. well, the detection logic is prone to become chaotic and over-complex.
  372. A way to detect more complex gestures based on a sequence of input events,
  373. is with the use of machine learning methods, such as the Hidden Markov
  374. Models (HMM)\footnote{A Hidden Markov Model (HMM) is a statistical model
  375. without a memory, it can be used to detect gestures based on the current
  376. input state alone.} used for sign language detection by Gerhard Rigoll et
  377. al. \cite{conf/gw/RigollKE97}. A sequence of input states can be mapped to
  378. a feature vector that is recognized as a particular gesture with a certain
  379. probability. An advantage of using machine learning with respect to an
  380. imperative programming style, is that complex gestures are described
  381. without the use of explicit detection logic, thus reducing code complexity.
  382. For example, the detection of the character `A' being written on the screen
  383. is difficult to implement using explicit detection code, whereas a trained
  384. machine learning system can produce a match with relative ease.
  385. To manage complexity and support multiple styles of gesture detection
  386. logic, the architecture has adopted the tracker-based design as described
  387. by Manoj Kumar \cite{win7touch}. Different detection components are wrapped
  388. in separate gesture tracking units called \emph{gesture trackers}. The
  389. input of a gesture tracker is provided by an event area in the form of
  390. events. Each gesture detection component is wrapped in a gesture tracker
  391. with a fixed type of input and output. Internally, the gesture tracker can
  392. adopt any programming style. A character recognition component can use an
  393. HMM, whereas a tap detection component defines a simple function that
  394. compares event coordinates.
  395. When a gesture tracker detects a gesture, this gesture is triggered in the
  396. corresponding event area. The event area then calls the callbacks which are
  397. bound to the gesture type by the application.
  398. The use of gesture trackers as small detection units allows extendability
  399. of the architecture. A developer can write a custom gesture tracker and
  400. register it in the architecture. The tracker can use any type of detection
  401. logic internally, as long as it translates low-level events to high-level
  402. gestures.
  403. An example of a possible gesture tracker implementation is a
  404. ``transformation tracker'' that detects rotation, scaling and translation
  405. gestures.
  406. \section{Serving multiple applications}
  407. \label{sec:daemon}
  408. The design of the architecture is essentially complete with the components
  409. specified in this chapter. However, one specification has not yet been
  410. discussed: the ability to address the architecture using a method of
  411. communication independent of the application's programming language.
  412. If the architecture and a gesture-based application are written in the same
  413. language, the main loop of the architecture can run in a separate thread of
  414. the application. If the application is written in a different language, the
  415. architecture has to run in a separate process. Since the application needs
  416. to respond to gestures that are triggered by the architecture, there must
  417. be a communication layer between the separate processes.
  418. A common and efficient way of communication between two separate processes
  419. is through the use of a network protocol. In this particular case, the
  420. architecture can run as a daemon\footnote{``daemon'' is a name Unix uses to
  421. indicate that a process runs as a background process.} process, listening
  422. to driver messages and triggering gestures in registered applications.
  423. \vspace{-0.3em}
  424. \daemondiagram
  425. An advantage of a daemon setup is that it can serve multiple applications
  426. at the same time. Alternatively, each application that uses gesture
  427. interaction would start its own instance of the architecture in a separate
  428. process, which would be less efficient. The network communication layer
  429. also allows the architecture and a client application to run on separate
  430. machines, thus distributing computational load. The other machine may even
  431. use a different operating system.
  432. %\section{Example usage}
  433. %\label{sec:example}
  434. %
  435. %This section describes an extended example to illustrate the data flow of
  436. %the architecture. The example application listens to tap events on a button
  437. %within an application window. The window also contains a draggable circle.
  438. %The application window can be resized using \emph{pinch} gestures. Figure
  439. %\ref{fig:examplediagram} shows the architecture created by the pseudo code
  440. %below.
  441. %
  442. %\begin{verbatim}
  443. %initialize GUI framework, creating a window and nessecary GUI widgets
  444. %
  445. %create a root event area that synchronizes position and size with the application window
  446. %define 'rotation' gesture handler and bind it to the root event area
  447. %
  448. %create an event area with the position and radius of the circle
  449. %define 'drag' gesture handler and bind it to the circle event area
  450. %
  451. %create an event area with the position and size of the button
  452. %define 'tap' gesture handler and bind it to the button event area
  453. %
  454. %create a new event server and assign the created root event area to it
  455. %
  456. %start the event server in a new thread
  457. %start the GUI main loop in the current thread
  458. %\end{verbatim}
  459. %
  460. %\examplediagram
  461. \chapter{Reference implementation}
  462. \label{chapter:implementation}
  463. A reference implementation of the design has been written in Python and is
  464. available at \cite{gitrepos}. The implementation does not include a network
  465. protocol to support the daemon setup as described in section \ref{sec:daemon}.
  466. Therefore, it is only usable in Python programs. The two test applications
  467. described in chapter \ref{chapter:test-applications} are also written in
  468. Python.
  469. To test multi-touch interaction properly, a multi-touch device is required. The
  470. University of Amsterdam (UvA) has provided access to a multi-touch table from
  471. PQlabs. The table uses the TUIO protocol \cite{TUIO} to communicate touch
  472. events.
  473. The following component implementations are included in the implementation:
  474. \textbf{Event areas}
  475. \begin{itemize}
  476. \item Circular area
  477. \item Rectangular area
  478. \item Polygon area
  479. \item Full screen area
  480. \end{itemize}
  481. \textbf{Gesture trackers}
  482. \begin{itemize}
  483. \item Basic tracker, supports $point\_down,~point\_move,~point\_up$ gestures.
  484. \item Tap tracker, supports $tap,~single\_tap,~double\_tap$ gestures.
  485. \item Transformation tracker, supports $rotate,~pinch,~drag,~flick$ gestures.
  486. \end{itemize}
  487. \textbf{Event drivers}
  488. \begin{itemize}
  489. \item TUIO driver, using only the support for simple touch points with an
  490. $(x, y)$ position.
  491. \end{itemize}
  492. The reference implementation also contains some geometric functions that are
  493. used by several event area implementations. The event area implementations are
  494. trivial by name and are therefore not discussed in this report.
  495. All gesture trackers have been implemented using an imperative programming
  496. style. Section \ref{sec:tracker-registration} shows how gesture trackers can be
  497. added to the architecture. Sections \ref{sec:basictracker} to
  498. \ref{sec:transformationtracker} describe the gesture tracker implementations in
  499. detail. The implementation of the TUIO event driver is described in section
  500. \ref{sec:tuio}.
  501. \section{Gesture tracker registration}
  502. \label{sec:tracker-registration}
  503. When a gesture handler is added to an event area by an application, the event
  504. area must create a gesture tracker that detects the corresponding gesture. To
  505. do this, the architecture must be aware of the existing gesture trackers and
  506. the gestures they support. The architecture provides a registration system for
  507. gesture trackers. A gesture tracker implementation contains a list of supported
  508. gesture types. These gesture types are mapped to the gesture tracker class by
  509. the registration system. When an event area needs to create a gesture tracker
  510. for a gesture type that is not yet being detected, the class of the new created
  511. gesture tracker is loaded from this map. Registration of a gesture tracker is
  512. very straight-forward, as shown by the following Python code:
  513. \begin{verbatim}
  514. # Create a gesture tracker implementation
  515. class TapTracker(GestureTracker):
  516. supported_gestures = ["tap", "single_tap", "double_tap"]
  517. # Methods for gesture detection go here
  518. # Register the gesture tracker with the architecture
  519. register_tracker(TapTracker)
  520. \end{verbatim}
  521. \section{Basic tracker}
  522. \label{sec:basictracker}
  523. The ``basic tracker'' implementation exists only to provide access to low-level
  524. events in an application. Low-level events are only handled by gesture
  525. trackers, not by the application itself. Therefore, the basic tracker maps
  526. \emph{point\_\{down,move,up\}} events to equally named gestures that can be
  527. handled by the application.
  528. \section{Tap tracker}
  529. \label{sec:taptracker}
  530. The ``tap tracker'' detects three types of tap gestures:
  531. \begin{enumerate}
  532. \item The basic \emph{tap} gesture is triggered when a touch point releases
  533. the touch surface within a certain time and distance of its initial
  534. position. When a \emph{point\_down} event is received, its location is
  535. saved along with the current timestamp. On the next \emph{point\_up}
  536. event of the touch point, the difference in time and position with its
  537. saved values are compared with predefined thresholds to determine
  538. whether a \emph{tap} gesture should be triggered.
  539. \item A \emph{double tap} gesture consists of two sequential \emph{tap}
  540. gestures that are located within a certain distance of each other, and
  541. occur within a certain time window. When a \emph{tap} gesture is
  542. triggered, the tracker saves it as the ``last tap'' along with the
  543. current timestamp. When another \emph{tap} gesture is triggered, its
  544. location and the current timestamp are compared with those of the
  545. ``last tap'' gesture to determine whether a \emph{double tap} gesture
  546. should be triggered. If so, the gesture is triggered at the location of
  547. the ``last tap'', because the second tap may be less accurate.
  548. \item A separate thread handles detection of \emph{single tap} gestures at
  549. a rate of thirty times per second. When the time since the ``last tap''
  550. exceeds the maximum time between two taps of a \emph{double tap}
  551. gesture, a \emph{single tap} gesture is triggered.
  552. \end{enumerate}
  553. The \emph{single tap} gesture exists to be able to make a distinction between
  554. single and double tap gestures. This distinction is not possible with the
  555. regular \emph{tap} gesture, since the first \emph{tap} gesture has already been
  556. handled by the application when the second \emph{tap} of a \emph{double tap}
  557. gesture is triggered.
  558. \section{Transformation tracker}
  559. \label{sec:transformationtracker}
  560. The transformation tracker triggers \emph{rotate}, \emph{pinch}, \emph{drag}
  561. and \emph{flick} gestures. These gestures use the centroid of all touch points.
  562. A \emph{rotate} gesture uses the difference in angle relative to the centroid
  563. of all touch points, and \emph{pinch} uses the difference in distance. Both
  564. values are normalized using division by the number of touch points $N$. A
  565. \emph{pinch} gesture contains a scale factor, and therefore uses a division of
  566. the current by the previous average distance to the centroid. Any movement of
  567. the centroid is used for \emph{drag} gestures. When a dragged touch point is
  568. released, a \emph{flick} gesture is triggered in the direction of the
  569. \emph{drag} gesture.
  570. Figure \ref{fig:transformationtracker} shows an example situation in which a
  571. touch point is moved, triggering a \emph{pinch} gesture, a \emph{rotate}
  572. gesture and a \emph{drag} gesture.
  573. \transformationtracker
  574. The \emph{pinch} gesture in figure \ref{fig:pinchrotate} uses the ratio
  575. $d_2:d_1$ to calculate its $scale$ parameter. Note that the difference in
  576. distance $d_2 - d_1$ and the difference in angle $\alpha$ both relate to a
  577. single touch point. The \emph{pinch} and \emph{rotate} gestures that are
  578. triggered relate to all touch points, using the average of distances and
  579. angles. Since all except one of the touch points have not moved, their
  580. differences in distance and angle are zero. Thus, the averages can be
  581. calculated by dividing the differences in distance and angle of the moved touch
  582. point by the number of touch points $N$. The $scale$ parameter represents the
  583. scale relative to the previous situation, which results in the following
  584. formula:
  585. $$pinch.scale = \frac{d_1 + \frac{d_2 - d_1}{N}}{d_1}$$
  586. The angle used for the \emph{rotate} gesture is only divided by the number of
  587. touch points to obtain an average rotation of all touch points:
  588. $$rotate.angle = \frac{\alpha}{N}$$
  589. \section{The TUIO event driver}
  590. \label{sec:tuio}
  591. The TUIO protocol \cite{TUIO} defines a way to geometrically describe tangible
  592. objects, such as fingers or objects on a multi-touch table. Object information
  593. is sent to the TUIO UDP port (3333 by default). For efficiency reasons, the
  594. TUIO protocol is encoded using the Open Sound Control \cite[OSC]{OSC} format.
  595. An OSC server/client implementation is available for Python: pyOSC
  596. \cite{pyOSC}.
  597. A Python implementation of the TUIO protocol also exists: pyTUIO \cite{pyTUIO}.
  598. However, a bug causes the execution of an example script to yield an error in
  599. Python's built-in \texttt{socket} library. Therefore, the TUIO event driver
  600. receives TUIO messages at a lower level, using the pyOSC package to receive
  601. TUIO messages.
  602. The two most important message types of the protocol are ALIVE and SET
  603. messages. An ALIVE message contains the list of ``session'' id's that are
  604. currently ``active'', which in the case of multi-touch a table means that they
  605. are touching the touch surface. A SET message provides geometric information of
  606. a session, such as position, velocity and acceleration. Each session represents
  607. an object touching the touch surface. The only type of objects on the
  608. multi-touch table are what the TUIO protocol calls ``2DCur'', which is a (x, y)
  609. position on the touch surface.
  610. ALIVE messages can be used to determine when an object touches and releases the
  611. screen. E.g. if a session id was in the previous message but not in the
  612. current, the object it represents has been lifted from the screen. SET messages
  613. provide information about movement. In the case of simple (x, y) positions,
  614. only the movement vector of the position itself can be calculated. For more
  615. complex objects such as fiducials, arguments like rotational position and
  616. acceleration are also included. ALIVE and SET messages are combined to create
  617. \emph{point\_down}, \emph{point\_move} and \emph{point\_up} events by the TUIO
  618. event driver.
  619. TUIO coordinates range from $0.0$ to $1.0$, with $(0.0, 0.0)$ being the left
  620. top corner of the touch surface and $(1.0, 1.0)$ the right bottom corner. The
  621. TUIO event driver scales these to pixel coordinates so that event area
  622. implementations can use pixel coordinates to determine whether an event is
  623. located within them. This transformation is also mentioned by the online
  624. TUIO specification \cite{TUIO_specification}:
  625. \begin{quote}
  626. In order to compute the X and Y coordinates for the 2D profiles a TUIO
  627. tracker implementation needs to divide these values by the actual sensor
  628. dimension, while a TUIO client implementation consequently can scale these
  629. values back to the actual screen dimension.
  630. \end{quote}
  631. \chapter{Test applications}
  632. \label{chapter:test-applications}
  633. Two test case applications have been created to test if the design ``works'' in
  634. a practical application, and to detect its flaws. One application is mainly
  635. used to test the gesture tracker implementations. The second application uses
  636. multiple event areas in a tree structure, demonstrating event delegation and
  637. propagation. The second application also defines a custom gesture tracker.
  638. \section{Full screen Pygame application}
  639. %The goal of this application was to experiment with the TUIO
  640. %protocol, and to discover requirements for the architecture that was to be
  641. %designed. When the architecture design was completed, the application was rewritten
  642. %using the new architecture components. The original variant is still available
  643. %in the ``experimental'' folder of the Git repository \cite{gitrepos}.
  644. An implementation of the detection of some simple multi-touch gestures (single
  645. tap, double tap, rotation, pinch and drag) using Processing\footnote{Processing
  646. is a Java-based programming environment with an export possibility for Android.
  647. See also \cite{processing}.} can be found in a forum on the Processing website
  648. \cite{processingMT}. The application has been ported to Python and adapted to
  649. receive input from the TUIO protocol. The implementation is fairly simple, but
  650. it yields some appealing results (see figure \ref{fig:draw}). In the original
  651. application, the detection logic of all gestures is combined in a single class
  652. file. As predicted by the GART article \cite{GART}, this leads to over-complex
  653. code that is difficult to read and debug.
  654. The original application code consists of two main classes. The ``multi-touch
  655. server'' starts a ``TUIO server'' that translates TUIO events to ``point
  656. \{down,move,up\}'' events. Detection of ``tap'' and ``double tap'' gestures is
  657. performed immediately after an event is received. Other gesture detection runs
  658. in a separate thread, using the following loop:
  659. \begin{verbatim}
  660. 60 times per second do:
  661. detect `single tap' based on the time since the latest `tap' gesture
  662. if points have been moved, added or removed since last iteration do:
  663. calculate the centroid of all points
  664. detect `drag' using centroid movement
  665. detect `rotation' using average orientation of all points to centroid
  666. detect `pinch' using average distance of all points to centroid
  667. \end{verbatim}
  668. There are two problems with the implementation described above. In the first
  669. place, low-level events are not grouped before gesture detection. The gesture
  670. detection uses all events for a single gesture. Therefore, only one element at
  671. a time can be rotated/resized etc. (see also section \ref{sec:areas}).
  672. Secondly, all detection code is located in the same class file. To extend the
  673. application with new gestures, a programmer must extend the code in this class
  674. file and therefore understand its structure. Since the main loop calls specific
  675. gesture detection components explicitly in a certain order, the programmer must
  676. alter the main loop to call custom gesture detection code. This is a problem
  677. because this way of extending code is not scalable over time. The class file
  678. would become more and more complex when extended with new gestures. The two
  679. problems have been solved using event areas and gesture trackers from the
  680. reference implementation. The gesture detection code has been separated into
  681. two different gesture trackers, which are the ``tap'' and ``transformation''
  682. trackers mentioned in chapter \ref{chapter:implementation}.
  683. The positions of all touch objects and their centroid are drawn using the
  684. Pygame library. Since the Pygame library does not provide support to find the
  685. location of the display window, the root event area captures events in the
  686. entire screen surface. The application can be run either full screen or in
  687. windowed mode. If windowed, screen-wide gesture coordinates are mapped to the
  688. size of the Pyame window. In other words, the Pygame window always represents
  689. the entire touch surface. The output of the application can be seen in figure
  690. \ref{fig:draw}.
  691. \begin{figure}[h!]
  692. \center
  693. \includegraphics[scale=0.4]{data/pygame_draw.png}
  694. \caption{
  695. Output of the experimental drawing program. It draws all touch points
  696. and their centroid on the screen (the centroid is used for rotation and
  697. pinch detection). It also draws a green rectangle which responds to
  698. rotation and pinch events.
  699. }
  700. \label{fig:draw}
  701. \end{figure}
  702. \section{GTK+/Cairo application}
  703. \label{sec:testapp}
  704. The second test application uses the GIMP toolkit (GTK+) \cite{GTK} to create
  705. its user interface. The PyGTK library \cite{PyGTK} is used to address GTK+
  706. functions in the Python application. Since GTK+ defines a main event loop that
  707. is started in order to use the interface, the architecture implementation runs
  708. in a separate thread.
  709. The application creates a main window, whose size and position are synchronized
  710. with the root event area of the architecture. The synchronization is handled
  711. automatically by a \texttt{GtkEventWindow} object, which is a subclass of
  712. \texttt{gtk.Window}. This object serves as a layer that connects the event area
  713. functionality of the architecture to GTK+ windows. The following Python code
  714. captures the essence of the synchronization layer:
  715. \begin{verbatim}
  716. class GtkEventWindow(Window):
  717. def __init__(self, width, height):
  718. Window.__init__(self)
  719. # Create an event area to represent the GTK window in the gesture
  720. # detection architecture
  721. self.area = RectangularArea(0, 0, width, height)
  722. # The "configure-event" signal is triggered by GTK when the position or
  723. # size of the window are updated
  724. self.connect("configure-event", self.sync_area)
  725. def sync_area(self, win, event):
  726. # Synchronize the position and size of the event area with that of the
  727. # GTK window
  728. self.area.width = event.width
  729. self.area.height = event.height
  730. self.area.set_position(*event.get_coords())
  731. \end{verbatim}
  732. The application window contains a number of polygons which can be dragged,
  733. resized and rotated. Each polygon is represented by a separate event area to
  734. allow simultaneous interaction with different polygons. The main window also
  735. responds to transformation, by transforming all polygons. Additionally, double
  736. tapping on a polygon changes its color.
  737. An ``overlay'' event area is used to detect all fingers currently touching the
  738. screen. The application defines a custom gesture tracker, called the ``hand
  739. tracker'', which is used by the overlay. The hand tracker uses distances
  740. between detected fingers to detect which fingers belong to the same hand (see
  741. section \ref{sec:handtracker} for details). The application draws a line from
  742. each finger to the hand it belongs to, as visible in figure \ref{fig:testapp}.
  743. \begin{figure}[h!]
  744. \center
  745. \includegraphics[scale=0.35]{data/testapp.png}
  746. \caption{
  747. Screenshot of the second test application. Two polygons can be dragged,
  748. rotated and scaled. Separate groups of fingers are recognized as hands,
  749. each hand is drawn as a centroid with a line to each finger.
  750. }
  751. \label{fig:testapp}
  752. \end{figure}
  753. To manage the propagation of events used for transformations and tapping, the
  754. applications arranges its event areas in a tree structure as described in
  755. section \ref{sec:tree}. Each transformable event area has its own
  756. ``transformation tracker'', which stops the propagation of events used for
  757. transformation gestures. Because the propagation of these events is stopped,
  758. overlapping polygons do not cause a problem. Figure \ref{fig:testappdiagram}
  759. shows the tree structure used by the application.
  760. Note that the overlay event area, though covering the entire screen surface, is
  761. not used as the root of the event area tree. Instead, the overlay is placed on
  762. top of the application window (being a rightmost sibling of the application
  763. window event area in the tree). This is necessary, because the transformation
  764. trackers in the application window stop the propagation of events. The hand
  765. tracker needs to capture all events to be able to give an accurate
  766. representations of all fingers touching the screen Therefore, the overlay
  767. should delegate events to the hand tracker before they are stopped by a
  768. transformation tracker. Placing the overlay over the application window forces
  769. the screen event area to delegate events to the overlay event area first. The
  770. event area implementation delegates events to its children in right-to left
  771. order, because area's that are added to the tree later are assumed to be
  772. positioned over their previously added siblings.
  773. \testappdiagram
  774. \subsection{Hand tracker}
  775. \label{sec:handtracker}
  776. The hand tracker sees each touch point as a finger. Based on a predefined
  777. distance threshold, each finger is assigned to a hand. Each hand consists of a
  778. list of finger locations, and the centroid of those locations.
  779. When a new finger is detected on the touch surface (a \emph{point\_down} event),
  780. the distance from that finger to all hand centroids is calculated. The hand to
  781. which the distance is the shortest can be the hand that the finger belongs to.
  782. If the distance is larger than the predefined distance threshold, the finger is
  783. assumed to be a new hand and \emph{hand\_down} gesture is triggered. Otherwise,
  784. the finger is assigned to the closest hand. In both cases, a
  785. \emph{finger\_down} gesture is triggered.
  786. Each touch point is assigned an ID by the reference implementation. When the
  787. hand tracker assigns a finger to a hand after a \emph{point\_down} event, its
  788. touch point ID is saved in a hash map\footnote{In computer science, a hash
  789. table or hash map is a data structure that uses a hash function to map
  790. identifying values, known as keys (e.g., a person's name), to their associated
  791. values (e.g., their telephone number). Source: Wikipedia \cite{wikihashmap}.}
  792. with the \texttt{Hand} object. When a finger moves (a \emph{point\_move} event)
  793. or releases the touch surface (\emph{point\_up}), The corresponding hand is
  794. loaded from the hash map and triggers a \emph{finger\_move} or
  795. \emph{finger\_up} gesture. If a released finger is the last of a hand, that
  796. hand is removed with a \emph{hand\_up} gesture.
  797. \section{Results}
  798. \label{sec:results}
  799. The Pygame application is based on existing program code, which has been be
  800. broken up into the components of the architecture. The application incorporates
  801. the most common multi-touch gestures, such as tapping and transformation
  802. gestures. All features from the original application are still supported in the
  803. revised application, so the component-based architecture design does not
  804. propose a limiting factor. Rather than that, the program code has become more
  805. maintainable and extendable due to the modular setup. The gesture tracker-based
  806. design has even allowed the detection of tap and transformation gestures to be
  807. moved to the reference implementation of the architecture, whereas it was
  808. originally part of the test application.
  809. The GTK+ application uses a more extended tree structure to arrange its event
  810. areas, so that it can use the powerful concept of event propagation. The
  811. application does show that the construction of such a tree is not always
  812. straight-forward: the ``overlay'' event area covers the entire touch surface,
  813. but is not the root of the tree. Designing the tree structure requires an
  814. understanding of event propagation by the application developer.
  815. Some work goes into the synchronization of application widgets with their event
  816. areas. The GTK+ application defines a class that acts as a synchronization
  817. layer between the application window and its event area in the architecture.
  818. This synchronization layer could be used in other applications that use GTK+.
  819. The ``hand tracker'' used by the GTK+ application is not incorporated within
  820. the architecture. The use of gesture trackers by the architecture allows he
  821. application to add new gestures in a single line of code (see section
  822. \ref{sec:tracker-registration}).
  823. Apart from the synchronization of event areas with application widgets, both
  824. applications have not trouble using the architecture implementation in
  825. combination with their application framework. Thus, the architecture can be
  826. used alongside existing application frameworks.
  827. \chapter{Conclusions}
  828. \label{chapter:conclusions}
  829. To support different devices, there must be an abstraction of device drivers so
  830. that gesture detection can be performed on a common set of low-level events.
  831. This abstraction is provided by the event driver.
  832. % Door input van meerdere drivers door dezelfde event driver heen te laten gaan
  833. % is er ondersteuning voor meerdere apparaten tegelijkertijd.
  834. Gestures must be able to occur within a certain area of a touch surface that is
  835. covered by an application widget. Therefore, low-level events must be divided
  836. into separate groups before any gesture detection is performed. Event areas
  837. provide a way to accomplish this. Overlapping event areas are ordered in a tree
  838. structure that can be synchronized with the widget tree of the application.
  839. Some applications require the ability to handle an event exclusively for an
  840. event area. An event propagation mechanism provides a solution for this: the
  841. propagation of an event in the tree structure can be stopped after gesture
  842. detection in an event area. Section \ref{sec:testapp} shows that the structure
  843. of the event area tree is not necessarily equal to that of the application
  844. widget tree. The design of the event area tree structure in complex situations
  845. requires an understanding of event propagation by the application programmer.
  846. The detection of complex gestures can be approached in several ways. If
  847. explicit detection code for different gesture is not managed well, program code
  848. can become needlessly complex. A tracker-based design, in which the detection
  849. of different types of gesture is separated into different gesture trackers,
  850. reduces complexity and provides a way to extend a set of detection algorithms.
  851. The use of gesture trackers is flexible, e.g. complex detection algorithms such
  852. as machine learning can be used simultaneously with other gesture trackers that
  853. use explicit detection. Also, the modularity of this design allows extension of
  854. the set of supported gestures. Section \ref{sec:testapp} demonstrates this
  855. extendability.
  856. A true generic architecture should provide a communication interface that
  857. provides support for multiple programming languages. A daemon implementation as
  858. described by section \ref{sec:daemon} is an example of such in interface. With
  859. this feature, the architecture can be used in combination with a wide range of
  860. application frameworks.
  861. \chapter{Suggestions for future work}
  862. \label{chapter:futurework}
  863. \section{A generic method for grouping events}
  864. \label{sec:eventfilter}
  865. As mentioned in section \ref{sec:areas}, the concept of an event area is based
  866. on the assumption that the set of originating events that form a particular
  867. gesture, can be determined based exclusively on the location of the events.
  868. Since this thesis focuses on multi-touch surface based devices, and every
  869. object on a multi-touch surface has a position, this assumption is valid.
  870. However, the design of the architecture is meant to be more generic; to provide
  871. a structured design for managing gesture detection.
  872. An in-air gesture detection device, such as the Microsoft Kinect \cite{kinect},
  873. provides 3D positions. Some multi-touch tables work with a camera that can also
  874. determine the shape and rotational orientation of objects touching the surface.
  875. For these devices, events delegated by the event driver have more parameters
  876. than a 2D position alone. The term ``area'' is not suitable to describe a group
  877. of events that consist of these parameters.
  878. A more generic term for a component that groups similar events is the
  879. \emph{event filter}. The concept of an event filter is based on the same
  880. principle as event areas, which is the assumption that gestures are formed from
  881. a subset of all events. However, an event filter takes all parameters of an
  882. event into account. An application on the camera-based multi-touch table could
  883. be to group all objects that are triangular into one filter, and all
  884. rectangular objects into another. Or, to separate small finger tips from large
  885. ones to be able to recognize whether a child or an adult touches the table.
  886. \section{Using a state machine for gesture detection}
  887. All gesture trackers in the reference implementation are based on the explicit
  888. analysis of events. Gesture detection is a widely researched subject, and the
  889. separation of detection logic into different trackers allows for multiple types
  890. of gesture detection in the same architecture. An interesting question is
  891. whether multi-touch gestures can be described in a formal way so that explicit
  892. detection code can be avoided.
  893. \cite{GART} and \cite{conf/gw/RigollKE97} propose the use of machine learning
  894. to recognize gestures. To use machine learning, a set of input events forming a
  895. particular gesture must be represented as a feature vector. A learning set
  896. containing a set of feature vectors that represent some gesture ``teaches'' the
  897. machine what the feature of the gesture looks like.
  898. An advantage of using explicit gesture detection code is the fact that it
  899. provides a flexible way to specify the characteristics of a gesture, whereas
  900. the performance of feature vector-based machine learning is dependent on the
  901. quality of the learning set.
  902. A better method to describe a gesture might be to specify its features as a
  903. ``signature''. The parameters of such a signature must be be based on input
  904. events. When a set of input events matches the signature of some gesture, the
  905. gesture is be triggered. A gesture signature should be a complete description
  906. of all requirements the set of events must meet to form the gesture.
  907. A way to describe signatures on a multi-touch surface can be by the use of a
  908. state machine of its touch objects. The states of a simple touch point could be
  909. ${down, move, hold, up}$ to indicate respectively that a point is put down, is
  910. being moved, is held on a position for some time, and is released. In this
  911. case, a ``drag'' gesture can be described by the sequence $down - move - up$
  912. and a ``select'' gesture by the sequence $down - hold$. If the set of states is
  913. not sufficient to describe a desired gesture, a developer can add additional
  914. states. For example, to be able to make a distinction between an element being
  915. ``dragged'' or ``thrown'' in some direction on the screen, two additional
  916. states can be added: ${start, stop}$ to indicate that a point starts and stops
  917. moving. The resulting state transitions are sequences $down - start - move -
  918. stop - up$ and $down - start - move - up$ (the latter does not include a $stop$
  919. to indicate that the element must keep moving after the gesture had been
  920. performed). The two sequences distinguish a ``drag'' gesture from a ``flick''
  921. gesture respectively.
  922. An additional way to describe even more complex gestures is to use other
  923. gestures in a signature. An example is to combine $select - drag$ to specify
  924. that an element must be selected before it can be dragged.
  925. The application of a state machine to describe multi-touch gestures is a
  926. subject well worth exploring in the future.
  927. \section{Daemon implementation}
  928. Section \ref{sec:daemon} proposes the use of a network protocol to communicate
  929. between an architecture implementation and (multiple) gesture-based
  930. applications, as illustrated in figure \ref{fig:daemon}. The reference
  931. implementation does not support network communication. If the architecture
  932. design is to become successful in the future, the implementation of network
  933. communication is a must. ZeroMQ (or $\emptyset$MQ) \cite{ZeroMQ} is a
  934. high-performance software library with support for a wide range of programming
  935. languages. A good basis for a future implementation could use this library as
  936. the basis for its communication layer.
  937. If an implementation of the architecture will be released, a good idea would be
  938. to do so within a community of application developers. A community can
  939. contribute to a central database of gesture trackers, making the interaction
  940. from their applications available for use in other applications.
  941. Ideally, a user can install a daemon process containing the architecture so
  942. that it is usable for any gesture-based application on the device. Applications
  943. that use the architecture can specify it as being a software dependency, or
  944. include it in a software distribution.
  945. \bibliographystyle{plain}
  946. \bibliography{report}{}
  947. \end{document}