{"id":25863201,"url":"https://github.com/theankurkedia/blink-detection","last_synced_at":"2025-07-02T09:32:31.210Z","repository":{"id":40536520,"uuid":"410017399","full_name":"theankurkedia/blink-detection","owner":"theankurkedia","description":"Detect the user's blink and wink using machine learning","archived":false,"fork":false,"pushed_at":"2022-05-03T17:09:07.000Z","size":14350,"stargazers_count":37,"open_issues_count":5,"forks_count":9,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-06-27T01:46:26.563Z","etag":null,"topics":["eye-detection","eye-tracking","face-landmark-detection","javascript","machine-learning","tensorflow","tensorflowjs","tfjs"],"latest_commit_sha":null,"homepage":"https://blink-detection.vercel.app","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/theankurkedia.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-09-24T15:39:31.000Z","updated_at":"2025-02-11T17:46:25.000Z","dependencies_parsed_at":"2022-07-27T09:32:08.973Z","dependency_job_id":null,"html_url":"https://github.com/theankurkedia/blink-detection","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/theankurkedia/blink-detection","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theankurkedia%2Fblink-detection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theankurkedia%2Fblink-detection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theankurkedia%2Fblink-detection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theankurkedia%2Fblink-detection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/theankurkedia","download_url":"https://codeload.github.com/theankurkedia/blink-detection/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theankurkedia%2Fblink-detection/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263111469,"owners_count":23415463,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["eye-detection","eye-tracking","face-landmark-detection","javascript","machine-learning","tensorflow","tensorflowjs","tfjs"],"created_at":"2025-03-01T23:59:21.883Z","updated_at":"2025-07-02T09:32:31.157Z","avatar_url":"https://github.com/theankurkedia.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Blink Detection\n\nUse machine learning in JavaScript to detect a blink and build blink-controlled experiences!\n\n## Demo\n\nVisit [https://blink-detection.vercel.app](https://blink-detection.vercel.app) _(Works on mobile too!!)_\n\n\u003c!-- ![](blink-demo.gif) --\u003e\n\nUses Tensorflow.js's [face landmark detection model](https://www.npmjs.com/package/@tensorflow-models/face-landmarks-detection).\n\n## Detection\n\nThis tool detects when the user blinks. It can also detect a wink and separate eye blinks as well.\n\n## Installation\n\nVia npm:\n\nUsing `yarn`:\n\n    $ yarn add blink-detection\n\n## How to use\n\n### Code sample\n\nStart by importing it:\n\n```js\nimport blink from 'blink-detection';\n```\n\nLoad the machine learning model:\n\n```js\nawait blink.loadModel();\n```\n\nThen, set up the camera feed needed for the detection. The `setUpCamera` method needs a `video` HTML element and, optionally, a camera device ID if you are using more than the default webcam.\n\n```js\nconst videoElement = document.querySelector('video');\n\nconst init = async () =\u003e {\n  // Using the default webcam\n  await gaze.setUpCamera(videoElement);\n\n  // Or, using more camera input devices\n  const mediaDevices = await navigator.mediaDevices.enumerateDevices();\n  const camera = mediaDevices.find(\n    (device) =\u003e\n      device.kind === 'videoinput' \u0026\u0026\n      device.label.includes(/* The label from the list of available devices*/)\n  );\n\n  await gaze.setUpCamera(videoElement, camera.deviceId);\n};\n```\n\nRun the predictions:\n\n```js\nconst predict = async () =\u003e {\n  const blinkPrediction = await blink.getBlinkPrediction();\n  console.log('Blink: ', blinkPrediction); // will return an object indicating the booleans for different states\n  // expect blinkPrediction to be {\n  //  blink: boolean,\n  //  wink: boolean,\n  //  longBlink: boolean,\n  //  left: boolean,\n  //  right: boolean,\n  //  rate: number\n  // }\n  if (blinkPrediction.blink) {\n    // do something when the user blinks\n  }\n  let raf = requestAnimationFrame(predict);\n};\npredict();\n```\n\nStop the detection:\n\n```js\ncancelAnimationFrame(raf);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheankurkedia%2Fblink-detection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftheankurkedia%2Fblink-detection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheankurkedia%2Fblink-detection/lists"}