Wiimote Project » General Wiimote and Technology » Programmers Den » UpdateTrackingUtilization() !!! Help...
: [1]
: UpdateTrackingUtilization() !!! Help...  ( 4510 )
0 and 2 Guests are viewing this topic.
Karma: +0/-0
: 26
Offline Offline
« : January 06, 2010, 01:51:54 PM »

Hi guys,

I am new to wiimote and i would like to write an application like Johnny Whiteboard. I am looking at his source code BUT i am stuck at the UpdateTrackingUtilization() function. I have some questions about the code below:

        float UpdateTrackingUtilization()
            //area of ideal calibration coordinates (to match the screen)
            float idealArea = (1 - 2*calibrationMargin) * 1024 * (1 - 2*calibrationMargin) * 768;
            //area of quadrliatera
            float actualArea = 0.5f * Math.Abs((srcX[1] - srcX[2]) * (srcY[0] - srcY[3]) - (srcX[0] - srcX[3]) * (srcY[1] - srcY[2]));
            float util = (actualArea / idealArea)*100;
            BeginInvoke((MethodInvoker)delegate() { lblTrackingUtil.Text = util.ToString("f0"); });
            BeginInvoke((MethodInvoker)delegate() { pbTrackingUtil.Value = (int)util; });

            return util;


 Where did you get the formula for idealArea, actualArea and util???   Why do we need these variables? and What is BeginInvoke?

Thank you very much and sorry for these noob's questions.

Karma: +28/-0
: 929
Offline Offline
Smoothboard Developer
« #1 : January 06, 2010, 05:56:36 PM »

Hi wizi,

The calibrationMargin is the ratio of the screen to position the calibration points. Therefore, the idealArea calculated is  actually the area in pixels of the a rectangle between the 4 fixed calibration points.

In short, it is the width * height of the rectangle.

The actualArea is the area of the quadrilateral of the points received from the Wiimote (calibrated by the user's IR pen). This can be seen as the white area above.

For the area, you can take a look at this link: http://mathforum.org/library/drmath/view/60583.html

Finally, util is tracking utilization which is the percentage of the area calibrated in comparison with the idealArea (Wiimote's view). In the screenshot above, the value for the tracking utilization is the White Area/ Black Area.

The BeginInvoke is used because of the thread that the code is running on is different from the threads that the controls are working on. Thus, you will need to invoke the delegate asynchronously.

Boon Jin

Wii Whiteboard/Wiimote Whiteboard with annotation features and collaborate with multiple iPads and Android Tablets!

Smoothboard for Mac
Using a Mac? Now you can annotate on PowerPoint or Keynote slideshows!

Karma: +0/-0
: 26
Offline Offline
« #2 : January 06, 2010, 10:28:16 PM »

Oh i see. Thank you very much boonjin.
: [1]

Clicky Web Analytics