I have two threads in my application - the main UI thread and another thread triggered by the wm_WiiMoteChanged event handler (background thread). In the main thread, I do some video processing. I have a function called processFramebelow. I use this code to measure the processing time of each frame and therefore the frame rate per second.
If I comment on the line wm.WiiMoteChanged ...(see below), the frame rate is about 15-20 frames per second and looks at the video, it seems correct (there is a slight lag).
But when I uncomment the line, that is, add an event handler (which itself generates the stream), fps reaches 40-50, but this is definitely wrong - the video is actually more lag.
Can someone explain to me why this is happening? Thank.
private void Main_Load(object sender, EventArgs e)
{
try
{
wm.Connect();
wm.SetReportType(InputReport.IRAccel, true);
wm.SetLEDs(false, false, false, true);
}
catch (Exception x)
{
MessageBox.Show("Exception: " + x.Message);
this.Close();
}
}
More code:
private void processFrame(object sender, EventArgs e)
{
DateTime curr = DateTime.Now;
performOperation();
TimeSpan currTime = DateTime.Now - curr;
lblFPS.Text = (1000 / currTime.Milliseconds).ToString() + " fps";
}
EDIT
An interesting find, only when this line is present in wm_WiimoteChanged does this happen.
ibxOutput.Image = new Image<Bgr, Byte>(_irViewAreaBitmap);
Sidenote: this line also causes a higher lag - processing done before it is installed is quick!