run the example on the website

Forum for C#/Windows development

run the example on the website

Postby c.li-1 » 02 May 2015, 18:58

Hello,

I have problem running the example "getting data" on the website (http://dev.theeyetribe.com/csharp/).

I add the example into the C# SDK in visual studio. The original property of the SDK is class library, and I got the error of "A project with an output type of class library cannot be started directly". if I change the property to console application, then I got the error of "does not contain a static 'Main' method suitable for an entry point".

Can anybody help me with this issue? I want to run the example of "getting data" on the website and get the coordinates of the gaze point. But I am really new to C#. Any help is much appreciated. Many Thanks.

Chandler
c.li-1
 
Posts: 3
Joined: 07 Apr 2015, 12:53

Re: run the example on the website

Postby Anders » 03 May 2015, 10:17

Anders
 
Posts: 124
Joined: 29 Oct 2013, 16:23

Re: run the example on the website

Postby c.li-1 » 03 May 2015, 15:46

Hi Anders,

Thanks for your reply. Unfortunately, it doesn't help.

I downloaded the examples several days ago. There are calibration, scroll and mouse control examples. But what I need is only the gaze data.

I created a new project in visual studio, included the SDK in references. I copied the "getting data" example on the website into a main( ) program. However, I still got an error that "} expected" at the first "{" in the main() program, though I did close the main().

Actually, I read every topic in the forum. Most of the topics are the same question as mine. But they were always answered with a link to your examples or a simple sentence. I do believe if you could please give more details about how to get the gaze data, it will help a lot of beginners like me. Thank you very much in advance.

Regards,
Chandler

The code I copied from your website is as follows. Please let me know if there is anything wrong.

using System;
using System.Linq;
using System.Runtime.InteropServices;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Diagnostics;
using System.ComponentModel;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Threading;
using System.Runtime.CompilerServices;
using TETCSharpClient;
using TETCSharpClient.Data;


namespace showgazedata
{
class Program
{
static void Main()
{
private TcpClient socket;
private Thread incomingThread;
private System.Timers.Timer timerHeartbeat;

public bool Connect(string host, int port)
{
try
{
socket = new TcpClient ("localhost", 6555);
}
catch (Exception ex)
{
Console.Out.WriteLine("Error connecting: " + ex.Message);
return false;
}

// Send the obligatory connect request message
string REQ_CONNECT = "{\"values\":{\"push\":true,\"version\":1},\"category\":\"tracker\",\"request\":\"set\"}";
Send(REQ_CONNECT);

// Lauch a seperate thread to parse incoming data
incomingThread = new Thread(ListenerLoop);
incomingThread.Start();

// Start a timer that sends a heartbeat every 250ms.
// The minimum interval required by the server can be read out
// in the response to the initial connect request.

string REQ_HEATBEAT = "{\"category\":\"heartbeat\",\"request\":null}";
timerHeartbeat = new System.Timers.Timer(250);
timerHeartbeat.Elapsed += delegate { Send(REQ_HEATBEAT); };
timerHeartbeat.Start();

return true;
}

private void Send(string message)
{
if (socket != null && socket.Connected)
{
StreamWriter writer = new StreamWriter(socket.GetStream());
writer.WriteLine(message);
writer.Flush();
}
}
public event EventHandler<ReceivedDataEventArgs> OnData;

private void ListenerLoop()
{
StreamReader reader = new StreamReader(socket.GetStream());
bool isRunning = true;

while (isRunning)
{
string response = string.Empty;

try
{
response = reader.ReadLine();

JObject jObject = JObject.Parse(response);

Packet p = new Packet();
//p.rawdata = json;

p.category = (string)jObject["category"];
p.request = (string)jObject["request"];
p.statuscode = (string)jObject["statuscode"];

JToken values = jObject.GetValue("values");

if (values != null)
{
/*
We can further parse the Key-Value pairs from the values here.
For example using a switch on the Category and/or Request
to create Gaze Data or CalibrationResult objects and pass these
via separate events.

To get the estimated gaze coordinate (on-screen pixels):
JObject gaze = JObject.Parse(jFrame.SelectToken("avg").ToString());
double gazeX = (double) gaze.Property("x").Value;
double gazeY = (double) gaze.Property("y").Value;*/

}

// Raise event with the data
if(OnData != null)
OnData(this, new ReceivedDataEventArgs(p));
}
catch (Exception ex)
{
Console.Out.WriteLine("Error while reading response: " + ex.Message);
}
}
}

public class Packet
{
public string time = DateTime.UtcNow.Ticks.ToString();
public string category = string.Empty;
public string request = string.Empty;
public string statuscode = string.Empty;
public string values = string.Empty;
public string rawData = string.Empty;

public Packet() { }
}

public class ReceivedDataEventArgs : EventArgs
{
private Packet packet;

public ReceivedDataEventArgs(Packet _packet)
{
this.packet = _packet;
}

public Packet Packet
{
get { return packet; }
}
}
}
}
}
c.li-1
 
Posts: 3
Joined: 07 Apr 2015, 12:53

Re: run the example on the website

Postby Anders » 04 May 2015, 08:17

Your problems seem to originate from general C# programming issues. The TET C# SDK is a library project. It cannot be 'run' but is designed to be referenced by C# projects and enables developers to quickly write programs that use our technology.

Looking at your code I strongly advise you to use the C# SDK instead of writing your own network layer. If you clone the C# samples and open that solution in VS you will see how usage of the C# SDK is intended in a WPF C# project. You should inspect the code examples to learn how to use the SDK library. If you use the example code setup as a basis for the project you are doing then you will save a lot of time.

Also, several users of this forum have shared their code. Maybe inspecting those projects could be an inspiration to you?

Best of luck!
Anders
 
Posts: 124
Joined: 29 Oct 2013, 16:23

Re: run the example on the website

Postby c.li-1 » 06 May 2015, 13:26

Thank you very much, Anders.

One more question, what is the frequency of the sample rate? I saw the sample time in the EYETRIBE UI. Is the unit of sample time milliseconds?

Regards,
Chandler
c.li-1
 
Posts: 3
Joined: 07 Apr 2015, 12:53

Re: run the example on the website

Postby Anders » 06 May 2015, 15:10

c.li-1@tudelft.nl wrote:One more question, what is the frequency of the sample rate? I saw the sample time in the EYETRIBE UI. Is the unit of sample time milliseconds?


You should insepct the TET Open API, the C# SDK Documentation or C# SDK Source Code if in doubt about a value.
Anders
 
Posts: 124
Joined: 29 Oct 2013, 16:23

Re: run the example on the website

Postby chithiravelus » 17 May 2015, 15:14

Hi Friends,

My name Chithirai, I am happy to join in The Eye Tribe Dev forum. I just purchased Eye Tribe Tracker and would like to get sample code/solution for click event and scroll event. I need it to apply one of my demo just to click ppt.

Thank you in advance.

Chithirai
chithiravelus
 
Posts: 4
Joined: 18 Feb 2015, 10:08

Re: run the example on the website

Postby Martin » 19 May 2015, 02:21

Chithirai,

Check the our GitHub open source archive. Scrolling in C# is done in this sample.

Click event you will have to decide upon yourself. It's very easy to get the X/Y screen coordinates using the API. The C# client is available with corresponding docs. Of course also API Clients for Java, C++, ObjectiveC and Unity (C#).


Click after 1 second dwell on button?

Have fun!
Martin
 
Posts: 567
Joined: 29 Oct 2013, 15:20

Re: run the example on the website

Postby chithiravelus » 26 Jun 2015, 16:10

Dear Martin,

Thank you so much for your guidance.. I am started doing it and let you know the progress shortly..

Hope you will guide me to make it successfully.... - CHithirai
chithiravelus
 
Posts: 4
Joined: 18 Feb 2015, 10:08

Re: run the example on the website

Postby chithiravelus » 03 Jul 2015, 22:40

Dear Martin,

I just executed and it is working fine - Thanks.
I need to use my page instead of existing page for scrolling. Also I need the sample for eye click event sample program.

Could you please guide me for above.
chithiravelus
 
Posts: 4
Joined: 18 Feb 2015, 10:08


Return to C#