Handtrack.js 项目教程

Handtrack.js 项目教程

handtrack.jsA library for prototyping realtime hand detection (bounding box), directly in the browser. 项目地址:https://gitcode.com/gh_mirrors/ha/handtrack.js

1. 项目的目录结构及介绍

Handtrack.js 项目的目录结构如下:

handtrack.js/
├── demo/
│   ├── index.html
│   ├── style.css
│   └── script.js
├── dist/
│   ├── handtrack.min.js
│   └── handtrack.min.js.map
├── src/
│   ├── data/
│   │   ├── coco.names
│   │   ├── yolov3-tiny.cfg
│   │   └── yolov3-tiny.weights
│   ├── index.js
│   └── utils.js
├── README.md
└── package.json

目录介绍

  • demo/: 包含项目的演示文件,包括 index.html, style.css, 和 script.js
  • dist/: 包含编译后的 JavaScript 文件,handtrack.min.js 是压缩后的库文件,handtrack.min.js.map 是源映射文件。
  • src/: 包含项目的源代码,data/ 目录下是模型配置和权重文件,index.js 是主入口文件,utils.js 包含一些辅助函数。
  • README.md: 项目的说明文档。
  • package.json: 项目的配置文件,包含依赖和脚本信息。

2. 项目的启动文件介绍

项目的启动文件是 demo/index.html,它是一个简单的 HTML 文件,用于展示 Handtrack.js 的基本功能。

demo/index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Handtrack.js Demo</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <h1>Handtrack.js Demo</h1>
    <video id="video" width="600" height="450" autoplay muted></video>
    <canvas id="canvas" width="600" height="450"></canvas>
    <script src="../dist/handtrack.min.js"></script>
    <script src="script.js"></script>
</body>
</html>

demo/script.js

const video = document.getElementById('video');
const canvas = document.getElementById('canvas');
const context = canvas.getContext('2d');

handTrack.startVideo(video).then((status) => {
    if (status) {
        handTrack.load().then(model => {
            console.log("Model loaded.");
            setInterval(() => {
                model.detect(video).then(predictions => {
                    console.log('Predictions: ', predictions);
                    model.renderPredictions(predictions, canvas, context, video);
                });
            }, 100);
        });
    }
});

3. 项目的配置文件介绍

项目的配置文件是 package.json,它包含了项目的依赖、脚本和其他元数据。

package.json

{
  "name": "handtrackjs",
  "version": "0.1.0",
  "description": "A library for prototyping realtime hand detection (bounding box) directly in the browser.",
  "main": "dist/handtrack.min.js",
  "scripts": {
    "build": "webpack",
    "watch": "webpack --watch",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [
    "handtracking",
    "machinelearning",
    "tensorflowjs"
  ],
  "author": "Victor Dibia",
  "license": "MIT",
  "dependencies": {
    "@tensorflow/tfjs": "^1.2.11",
    "@tensorflow/tfjs-node": "^1.2.11"
  },
  "devDependencies": {
    "webpack": "^4.41.2",
    "webpack-cli": "^3.3.10"
  }
}

配置文件介绍

handtrack.jsA library for prototyping realtime hand detection (bounding box), directly in the browser. 项目地址:https://gitcode.com/gh_mirrors/ha/handtrack.js

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

丁战崇Exalted

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值