public void Test_0440_QLDeviceGroup_RemoveDevice() { // Note: This only uses the initially chosen device. int deviceGroupId; QLError error = QuickLink2API.QLDeviceGroup_Create(out deviceGroupId); Assert.AreEqual(QLError.QL_ERROR_OK, error); Assert.Greater(deviceGroupId, 0); error = QuickLink2API.QLDeviceGroup_AddDevice(deviceGroupId, Test_SetUp.Helper.DeviceId); Assert.AreEqual(QLError.QL_ERROR_OK, error); int numDevices = 1; int[] deviceIds = new int[numDevices]; error = QuickLink2API.QLDeviceGroup_Enumerate(deviceGroupId, ref numDevices, deviceIds); Assert.AreEqual(QLError.QL_ERROR_OK, error); Assert.AreEqual(1, numDevices); Assert.AreEqual(Test_SetUp.Helper.DeviceId, deviceIds[0]); QLFrameData frameData = new QLFrameData(); error = QuickLink2API.QLDevice_GetFrame(Test_SetUp.Helper.DeviceId, 2000, ref frameData); Assert.AreEqual(QLError.QL_ERROR_OK, error); error = QuickLink2API.QLDeviceGroup_RemoveDevice(deviceGroupId, Test_SetUp.Helper.DeviceId); Assert.AreEqual(QLError.QL_ERROR_OK, error); error = QuickLink2API.QLDeviceGroup_Enumerate(deviceGroupId, ref numDevices, deviceIds); Assert.AreEqual(QLError.QL_ERROR_OK, error); Assert.AreEqual(0, numDevices); }
public void Test_0470_QLDeviceGroup_GetFrame() { // Note: This only uses the initially chosen device. // Note: This could be much more robust (i.e., by checking the data // in the received frame for correctness). int deviceGroupId; QLError error = QuickLink2API.QLDeviceGroup_Create(out deviceGroupId); Assert.AreEqual(QLError.QL_ERROR_OK, error); Assert.Greater(deviceGroupId, 0); error = QuickLink2API.QLDeviceGroup_AddDevice(deviceGroupId, Test_SetUp.Helper.DeviceId); Assert.AreEqual(QLError.QL_ERROR_OK, error); error = QuickLink2API.QLDevice_Start(deviceGroupId); Assert.AreEqual(QLError.QL_ERROR_OK, error); int numFrames = 1; QLFrameData[] frameDataArray = new QLFrameData[numFrames]; frameDataArray[0] = new QLFrameData(); error = QuickLink2API.QLDeviceGroup_GetFrame(deviceGroupId, 2000, ref numFrames, frameDataArray); Assert.AreEqual(QLError.QL_ERROR_OK, error); Assert.AreEqual(1, numFrames); Assert.AreEqual(Test_SetUp.Helper.DeviceId, frameDataArray[0].DeviceId); error = QuickLink2API.QLDevice_Stop(deviceGroupId); Assert.AreEqual(QLError.QL_ERROR_OK, error); }
static void Main(string[] args) { int deviceId = Initialize.QL2Initialize(filename_Password); QLError error = QuickLink2API.QLDevice_Start(deviceId); if (error != QLError.QL_ERROR_OK) { System.Console.WriteLine("Device not started successfully!"); System.Console.ReadLine(); return; } System.Console.WriteLine("Press any key to begin calibration."); Console.ReadKey(true); //Calibrate the device int calibrationId = 0; if (Calibrate.AutoCalibrate(deviceId, QLCalibrationType.QL_CALIBRATION_TYPE_16, ref calibrationId)) { System.Console.WriteLine("\n\nPress \'q\' to quit. \n"); // If the calibration was successful then apply the calibration to the device. QuickLink2API.QLDevice_ApplyCalibration(deviceId, calibrationId); // Display the gaze information until the user quits. QLFrameData frameData = new QLFrameData(); while ((!Console.KeyAvailable) || (Console.ReadKey(true).Key != ConsoleKey.Q)) { QuickLink2API.QLDevice_GetFrame(deviceId, 10000, ref frameData); if (frameData.WeightedGazePoint.Valid) { System.Console.Write("\rX:{0:F} Y:{1:F}", frameData.WeightedGazePoint.x, frameData.WeightedGazePoint.y); } } } else { System.Console.WriteLine("The calibration did not finish successfully!"); System.Console.Read(); QuickLink2API.QLDevice_Stop(deviceId); return; } // Stop the device. QuickLink2API.QLDevice_Stop(deviceId); return; }
public void Test_0130_QLDevice_GetFrame() { // Note: This could be much more robust (i.e., by checking the data // in the received frame for correctness). QLError error = QuickLink2API.QLDevice_Start(Test_SetUp.Helper.DeviceId); Assert.AreEqual(QLError.QL_ERROR_OK, error); QLFrameData frameData = new QLFrameData(); error = QuickLink2API.QLDevice_GetFrame(Test_SetUp.Helper.DeviceId, 2000, ref frameData); Assert.AreEqual(QLError.QL_ERROR_OK, error); Assert.AreEqual(Test_SetUp.Helper.DeviceId, frameData.DeviceId); error = QuickLink2API.QLDevice_Stop(Test_SetUp.Helper.DeviceId); Assert.AreEqual(QLError.QL_ERROR_OK, error); }
/// <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); }