/// <summary>
            /// Constructor for a Windows Form that performs an eye tracker calibration routine with
            /// either 5, 9, or 16 points.  Each target is displayed for a settable duration.
            /// </summary>
            /// <seealso cref="T:QuickLink2DotNetHelper.QLHelper.CalibrationForm"/>
            /// <param name="deviceId">
            /// The ID of the device to be calibrated.  This is the value found in the
            /// <see cref="QLHelper.DeviceId"/> field.
            /// </param>
            /// <param name="calibrationType">
            /// The type of calibration to perform (5, 9, or 16-point).  Any member of
            /// <see cref="QuickLink2DotNet.QLCalibrationType"/> is accepted.
            /// </param>
            /// <param name="targetDuration">
            /// The duration, in milliseconds, to show each target on the screen during the calibration
            /// sequence.
            /// </param>
            public CalibrationForm(int deviceId, QLCalibrationType calibrationType, int targetDuration)
            {
                this._deviceId        = deviceId;
                this._calibrationType = calibrationType;
                this._targetDuration  = targetDuration;

                this._calibrationId = 0;

                QLHelper.CalibrationTypeToNumberOfPoints(this._calibrationType, out this._numberOfTargets);

                this._leftScores  = new QLCalibrationScore[this._numberOfTargets];
                this._rightScores = new QLCalibrationScore[this._numberOfTargets];
                this._targets     = new QLCalibrationTarget[this._numberOfTargets];

                this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
                this.Width           = Screen.PrimaryScreen.WorkingArea.Width;
                this.Height          = Screen.PrimaryScreen.WorkingArea.Height;
                this.TopMost         = false;
                this.WindowState     = System.Windows.Forms.FormWindowState.Minimized;
                this.Hide();

                this._calibrationPictureBox            = new System.Windows.Forms.PictureBox();
                this._calibrationPictureBox.BackColor  = System.Drawing.SystemColors.ButtonShadow;
                this._calibrationPictureBox.Dock       = System.Windows.Forms.DockStyle.Fill;
                this._calibrationPictureBox.ClientSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
                this.Controls.Add(this._calibrationPictureBox);

                this._calibrationPictureBox.Paint += new PaintEventHandler(CalibrationPictureBoxPaint);
            }
Example #2
0
            private void FrameReader()
            {
                while (true)
                {
                    QLError error = QuickLink2API.QLDevice_GetFrame(this._helper.DeviceId, 2000, ref this._frameData);
                    if (error != QLError.QL_ERROR_OK)
                    {
                        Console.WriteLine("QLDevice_GetFrame() returned {0}.", error.ToString());
                        continue;
                    }

                    this._latestImage = QLHelper.BitmapFromQLImageData(ref this._frameData.ImageData);

                    this._videoPictureBox.Invalidate();

                    lock (this._frameData_Lock)
                    {
                        Monitor.Wait(this._frameData_Lock);
                    }
                }
            }
Example #3
0
            /// <summary>
            /// Constructor for a Windows Form that displays a live video stream from the eye tracker.
            /// This constructor allows for the specification of an initial display size.
            /// </summary>
            /// <seealso cref="T:QuickLink2DotNetHelper.QLHelper.VideoForm"/>
            /// <seealso cref="VideoForm(QLHelper)"/>
            /// <param name="helper">
            /// The <see cref="T:QuickLink2DotNetHelper.QLHelper" /> object of the device from which live video will be displayed.
            /// This object can be obtained by calling <see cref="QLHelper.ChooseDevice"/> or
            /// <see cref="QLHelper.FromDeviceId"/>.
            /// </param>
            /// <param name="sizeDivisor">
            /// Specifies the initial size of the display.  A value of 1 causes the full size to be used,
            /// 2 is half size, and 4 is quarter size.  Passing other values cause the default of '1' to
            /// be used.
            /// </param>
            public VideoForm(QLHelper helper, int sizeDivisor)
            {
                this._helper = helper;

                switch (sizeDivisor)
                {
                case 1:
                    this._videoScale = 1f;
                    break;

                case 2:
                    this._videoScale = 0.5f;
                    break;

                case 4:
                    this._videoScale = 0.25f;
                    break;
                }

                this._frameData   = new QLFrameData();
                this._latestImage = null;
                this._nextSize    = false;

                this.ClientSize      = new Size((int)(helper._deviceInfo.sensorWidth * this._videoScale), (int)(helper._deviceInfo.sensorHeight * this._videoScale));
                this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
                this.MaximizeBox     = false;

                this._videoPictureBox        = new System.Windows.Forms.PictureBox();
                this._videoPictureBox.Dock   = System.Windows.Forms.DockStyle.Fill;
                this._videoPictureBox.Paint += new PaintEventHandler(VideoForm_VideoPictureBox_Paint);
                this.Controls.Add(this._videoPictureBox);

                this.FormClosing += new FormClosingEventHandler(VideoForm_FormClosing);
                this.KeyUp       += new KeyEventHandler(VideoForm_KeyUp);
                this.Shown       += new EventHandler(VideoForm_Shown);

                this._frameReader_Thread = new Thread(FrameReader);
            }
Example #4
0
 /// <summary>
 /// Constructor for a Windows Form that displays a live video stream from the eye tracker
 /// device in quarter-size, half-size, or full size.  Press the space bar with the form in
 /// focus to cycle through sizes.  This constructor always makes a video form with an
 /// initially full-sized display.
 /// </summary>
 /// <seealso cref="VideoForm(QLHelper, int)"/>
 /// <param name="helper">
 /// The <see cref="T:QuickLink2DotNetHelper.QLHelper" /> object of the device from which live video will be displayed.
 /// This object can be obtained by calling <see cref="QLHelper.ChooseDevice"/> or
 /// <see cref="QLHelper.FromDeviceId"/>.
 /// </param>
 public VideoForm(QLHelper helper)
     : this(helper, 1)
 {
 }