Skip to content

API Reference

kexxu_eye_sdk

kexxu_eye_sdk.format.openeye_file_to_xy

openeye_file_to_xy(path)

Convert an OpenEye eye tracking recording datafile to x,y coordinates in pixels on the video, one per frame.

Parameters:

Name Type Description Default
path str

The file path to the OpenEye Datafile.

required

Returns:

Type Description
List[Tuple[int, int]]

List with [ (x,y), ... ] gaze locations, one for each video frame

Source code in src/kexxu_eye_sdk/format.py
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
def openeye_file_to_xy(path: str)-> List[Tuple[int,int]]:
  """Convert an OpenEye eye tracking recording datafile to x,y coordinates in pixels on the video, one per frame.

  Args:
    path: The file path to the OpenEye Datafile.

  Returns:
    List with [ (x,y), ... ] gaze locations, one for each video frame
  """

  eye_locs = []
  lines = read_lines(path)
  for line in lines:
    try:
      if not get_event_type(line) == "eyetracking":
          continue # not an eye tracking event, skip

      parts = get_event_parts(line)
      js = json.loads(parts[2])

      rx = js["pupil_rel_pos_x"]
      ry = js["pupil_rel_pos_y"]

      x, y = to_720p(rx, ry)
      eye_locs.append((x, y))
    except Exception as e:
        print("error processing event from line:")
        print(line)

  return eye_locs