slow reaction time

Dec 12, 2009 at 9:43 PM

Hi, im new to touchless, and im starting with using touchless demo's codes to understand how it works. The problem is, that in touchlessdemo video reacts in an instant, and in my project it does not ;). Dont get me wrong, im not writing bout fps. Fps is same in my project, and in project demo. The thing is, that in my case, when i move in front of camera, picture on my screen (from webcam) 'reacts' after 0,5 - 1 second... any ideas?

 


private void initTouchlessCam(TouchlessMgr manager)

{

Camera choosenCam = null;

foreach (Camera cam in manager.Cameras)

{

CamerasComboBox.Items.Add(cam);

}

if (CamerasComboBox.Items.Count > 0)

{

CamerasComboBox.SelectedIndex = 0;

choosenCam = (Camera)CamerasComboBox.SelectedItem;

}

else

{

MessageBox.Show("no usable camera found");

}

}

 

private void comboBoxCameras_SelectedIndexChanged(object sender, EventArgs e)

{

if (cm.CurrentCamera == (Camera)CamerasComboBox.SelectedItem)

return;

 

if (cm.CurrentCamera != null)

{

cm.CurrentCamera.OnImageCaptured -= new EventHandler<CameraEventArgs>(OnImageCaptured);

cm.CurrentCamera.Dispose();

cm.CurrentCamera = null;

CamerasComboBox.Text = "Select A Camera";

pictureBoxDisplay.Paint -= new PaintEventHandler(drawLatestImage);

}

 

if (CamerasComboBox.SelectedIndex < 0)

{

pictureBoxDisplay.Paint -= new PaintEventHandler(drawLatestImage);

CamerasComboBox.Text = "Select A Camera";

return;

}

 

try

{

Camera c = (Camera)CamerasComboBox.SelectedItem;

c.OnImageCaptured += new EventHandler<CameraEventArgs>(OnImageCaptured);

cm.CurrentCamera = c;

 

pictureBoxDisplay.Paint += new PaintEventHandler(drawLatestImage);

}

catch (Exception ex)

{

CamerasComboBox.Text = "Select A Camera";

MessageBox.Show(ex.Message);

}

}

 

private static Image _latestFrame;


private void OnImageCaptured(object sender, CameraEventArgs e)

{

_latestFrame = e.Image;

pictureBoxDisplay.Invalidate();

}

 

private void drawLatestImage(object sender, PaintEventArgs e)

{

if (_latestFrame != null)

{

e.Graphics.DrawImage(_latestFrame, 0, 0, pictureBoxDisplay.Width, pictureBoxDisplay.Height);

}

}

 

any ideas?