Skip to main content

Quick Start (Flutter)

Supported Platform

  • Android
  • iOS

Supported Environment

  • Flutter 3.13.1

  • Dart 3.1.0

  • Minimum supported Android API level is 23.

  • Target Android API level is 30.

  • Minimum supported iOS Version is 11.0.

  • Camera permission, Network permission and Network connected environment are required.

  • Build target to REAL DEVICE during the development process.

info

SeeSo SDK uses the front camera of the device

Sample Project

Please go to the sample project page for the purpose of using it rather than implementing it.

Environment Set-ups

  • Check the Development key.

  • Create the new flutter project from terminal.

    flutter create --platforms android,ios sample_app
  • Added seeso_flutter to sample_app's pubspec.yaml file.

    dependencies:
    flutter:
    sdk: flutter
    seeso_flutter:^1.0.3
  • Install pub packge from terminal.

    flutter pub get

Environment Set-ups (Android)

  • Add the maven repository URL 'https://seeso.jfrog.io/artifactory/visualcamp-seeso-android-gradle-release/' to the build.gradle file where seeso is located.

    allprojects {
    repositories {
    ...
    maven {
    url "https://seeso.jfrog.io/artifactory/visualcamp-seeso-android-gradle-release/"
    }
    }
    }
  • Add the following dependencies to the app/build.gradle file.

    dependencies {
    ...
    implementation "camp.visual:seeso-gazetracker:latest.release"
    implementation "camp.visual:seeso-libgaze:latest.release"
    }

Environment Set-ups (iOS)

  • Add permission to your Info.plist file.

      <key>NSCameraUsageDescription</key>
    <string></string>
  • Add PERMISSION_CAMERA=1 to your Podfile.

    target.build_configurations.each do |config|
    config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
    '$(inherited)',
    ...
    'PERMISSION_CAMERA=1'
    ]
    end
  • Pod install from terminal.

    pod install

Sample App Implementation

  1. Add code to check if you have camera permission.

    Future<void> checkCameraPermission() async {
    _hasCameraPermission = await _seesoPlugin.checkCameraPermission();
    }
  2. Add a function to request camera permission.

    Future<void> checkCameraPermission() async {
    _hasCameraPermission = await _seesoPlugin.checkCameraPermission();
    ///If you do not have camera permission, call the requesting function.
    if (!_hasCameraPermission) {
    _hasCameraPermission = await _seesoPlugin.requestCameraPermission();
    }
    }
  3. When camera permission is obtained through the user, authentication begins by calling the initGazeTracker function.

      Future<void> initSeeSo() async {
    await checkCameraPermission();
    String requestInitGazeTracker = "failed Request";
    if (_hasCameraPermission) {
    try {
    InitializedResult? initializedResult =
    await _seesoPlugin.initGazeTracker(licenseKey: _licenseKey);
    } on PlatformException catch (e) {
    print( "Occur PlatformException (${e.message})");
    }
    }
    }
  4. When authentication is successful, eye tracking begins.

     if (initializedResult!.result) {
    try {
    _seesoPlugin.startTracking();
    } on PlatformException catch (e) {
    print("Occur PlatformException (${e.message})");
    }
    }
  5. Set a listener to receive GazeInfo.

      _seesoPlugin.getGazeEvent().listen((event) {
    GazeInfo info = GazeInfo(event);
    if (info.trackingState == TrackingState.SUCCESS) {
    print("gaze info ${gazeInfo.x}, ${gazeInfo.y}");
    } else {
    print("gaze not found");
    }
    }
    );
  6. Here is the full code.

    import 'dart:async';
    import 'package:flutter/material.dart';
    import 'package:flutter/services.dart';

    import 'package:seeso_flutter/seeso.dart';
    import 'package:seeso_flutter/seeso_initialized_result.dart';
    import 'package:seeso_flutter/event/gaze_info.dart';
    import 'package:seeso_flutter/seeso_plugin_constants.dart';

    class MyApp extends StatefulWidget {
    MyApp({Key? key}) : super(key: key);

    @override
    State<MyApp> createState() => _MyAppState();
    }

    class _MyAppState extends State<MyApp> {
    final _seesoPlugin = SeeSo();
    static const String _licenseKey = "Input your licenseKey"; // todo: input your license key
    double _x = 0.0, _y = 0.0;
    bool _hasCameraPermission = false;
    MaterialColor _gazeColor = Colors.red;

    @override
    void initState() {
    super.initState();
    initSeeSo();
    }

    Future<void> checkCameraPermission() async {
    _hasCameraPermission = await _seesoPlugin.checkCameraPermission();
    if (!_hasCameraPermission) {
    _hasCameraPermission = await _seesoPlugin.requestCameraPermission();
    }
    if (!mounted) {
    return;
    }
    }

    Future<void> initSeeSo() async {
    await checkCameraPermission();
    if (_hasCameraPermission) {
    try {
    InitializedResult? initializedResult =
    await _seesoPlugin.initGazeTracker(licenseKey: _licenseKey);
    if (initializedResult!.result) {
    listenEvents();
    try {
    _seesoPlugin.startTracking();
    } on PlatformException catch (e) {
    print("Occur PlatformException (${e.message})");
    }
    }
    } on PlatformException catch (e) {
    print("Occur PlatformException (${e.message})");
    }
    }
    }

    void listenEvents() {
    _seesoPlugin.getGazeEvent().listen((event) {
    GazeInfo info = GazeInfo(event);

    if (info.trackingState == TrackingState.SUCCESS) {
    setState(() {
    _x = info.x;
    _y = info.y;
    _gazeColor = Colors.green;
    });
    } else {
    setState(() {
    _gazeColor = Colors.red;
    });
    }
    });
    }

    @override
    Widget build(BuildContext context) {
    return MaterialApp(
    home: Scaffold(
    appBar: null, // Hide the AppBar
    body: Stack(children: <Widget>[
    Positioned(
    left: _x - 5,
    top: _y - 5,
    child: Container(
    width: 10,
    height: 10,
    decoration: BoxDecoration(
    color: _gazeColor,
    shape: BoxShape.circle,
    ),
    )),
    ])));
    }
    }