Sunday, August 22, 2010

Experimenting with FaceAPI

0 Kommentare
How do I look??

Works good without Eye-Tracker
Works slightly worse with my eye tracker goggles on ;)

Howto: Hide the cursor in Windows

0 Kommentare
A problem I had during the development of my gaze-enhanced tab switching, was that the mouse cursor was diverting the user's gaze. That's why I decided to hide the cursor, while gaze control is active.

A major problem here was that the .net funktions Cursor.Hide() and WinApi ShowCursor(false) are only valid for the user control they are called from.
I searched for a way to hide the cursors globally in windows.

One possibility which came to my mind was to change the Windows cursor temporarily (as you can also do it via System Control->Mouse Settings) to an invisible dummy cursor, which is basically just a .cur file without any content. The information for the currently active cursors is stored in the Windows registry. Reading from and changing the registry is not that big of a problem for C#.

So here is what I had to do:
  1. Store the current cursor path
  2. Change the cursors "Arrow" and "Hand" to the invisible.cur file
  3. Force a reload of the registry
  4. Later: restore the original cursors again.
After the jump is the code, which does what I wanted to accomplish. It is called on pressing the hotkey combination for "enable gaze control", which I set to the same hotkey combo as "show tab previews" in firefox :)

Saturday, August 14, 2010

C#: HowTo directly change a setting in an "*.exe.config" file

0 Kommentare
I had been searching for more than half a day for a way to directly change the values in the appSettings section in the  *.exe.config of my application. The problem is that the settings are read-only. I found no way to write to the *.exe.config file. I neither found a class or a method online to do this.
So I created my own method which directly accesses the *.exe.config file by making use of its XML structure.
Thus, I am able to add and change nodes and ultimately save the XML file.

Here is the code:

Wednesday, August 11, 2010

Processing Global Hotkey Events

0 Kommentare
I want to trigger an Event, everytime the ESC Key is pressed.
As shown below, this is npt that hard, when the program is in focus. If it out of focus, the event is not triggered.
Thus, I need global hotkey processing.

I found a page, where this method is explained using a custom class, which utilized Hooks.

More here:
http://www.tutorial-board.de/index.php?page=Thread&threadID=382
http://www.codeproject.com/KB/cs/globalhook.aspx
http://dotnet-snippets.de/dns/globale-hotkeys-tastenkombinationen-SID356.aspx

Handling the ESC Key in C#

0 Kommentare
Found this here: http://channel9.msdn.com/forums/TechOff/224745-Escape-Key-Event-Bug-C/?CommentID=224767
Escape Key is a command key, so you should achieve this with another trick, for example:

using System;
using System.Windows.Forms;

namespace HandleEscapeKeyDemo
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
        }

        protected override Boolean ProcessCmdKey(ref Message msg, Keys keyData)
        {
            if (keyData == Keys.Escape)
            {
                OnPressEscapeKey();
            }
            return true;
        }

        private void OnPressEscapeKey()
        {
            MessageBox.Show("Escape Key Is Pressed");
        }
    }
}


Sheva

WORKS!

Thursday, August 5, 2010

Trying to understand the smoothing algorithm from EyeWriter

1 Kommentare
The algorithm looks very simple:
There is one parameter, which controlls the intensity of the smoothin effect.

The formula is structured like this

NewCursorPosition =
       SmoothingFactor * OldCursorPosition
      + (1-SmoothingFactor) * ActualGazePosition

Code from testApp.cpp Line 62
   eyeSmoothed.x = CM.smoothing * eyeSmoothed.x + (1-CM.smoothing) * screenPoint.x;

One example for this:

NewPos = 0,97 * 487 + (1-0,97) * 705
              = 472 + 21
              = 493


The difference between OldPos and New Pos is 493-487 = 5px. This means, that the cursos slowly adopts to the actual gaze position without large jumps..
Increasing the Smoothing Factor leads to a much slower moving of the cursor, decreasing it, results in an abrupt jumping of the cursor, which gives it less stability.

From a first impression, the GT algorithm does not work as good as this simple and lean EyeWriter algorithm, AND uses a much more complicated logic. Therefore, I probably could implement this very simple algorithm instead.

However, I need to understand the GT algorithm first in order to decide.