{"id":15486805,"url":"https://github.com/hold-baby/label-img","last_synced_at":"2025-10-28T21:43:35.428Z","repository":{"id":37719324,"uuid":"320498412","full_name":"hold-baby/label-img","owner":"hold-baby","description":"图片标注工具","archived":false,"fork":false,"pushed_at":"2022-11-08T04:44:10.000Z","size":790,"stargazers_count":64,"open_issues_count":3,"forks_count":16,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-15T01:08:53.831Z","etag":null,"topics":["annotate","image-annotation","labelme"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hold-baby.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2020-12-11T07:23:24.000Z","updated_at":"2024-09-04T07:40:14.000Z","dependencies_parsed_at":"2022-07-12T16:43:49.863Z","dependency_job_id":null,"html_url":"https://github.com/hold-baby/label-img","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hold-baby%2Flabel-img","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hold-baby%2Flabel-img/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hold-baby%2Flabel-img/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hold-baby%2Flabel-img/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hold-baby","download_url":"https://codeload.github.com/hold-baby/label-img/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248986313,"owners_count":21194025,"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":["annotate","image-annotation","labelme"],"created_at":"2024-10-02T06:09:43.408Z","updated_at":"2025-10-19T16:08:58.943Z","avatar_url":"https://github.com/hold-baby.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 图片标注工具\n\nimage annotation tool with javascript\n\n\u003e 本工具专注图形标注，不局限某种方式与格式，只输出关键点位信息，不与业务逻辑耦合，并提供方法自定义展示方式与实体属性填写的实现（持续开发当中，文档更新可能滞后，请使用固定版本）\n\n### 示例\n\n[demo for react](https://hold-baby.github.io/label-img/)\n\n### 安装\n\n```\nnpm install label-img\n```\n\nor\n\n```html\n\u003cscript src=\"./labelImg.js\"\u003e\u003c/script\u003e\n```\n\n### 使用\n\n```javascript\n/**\n * 生成实例\n * @element   挂载节点\n * @options   配置 非必填\n */\nconst labeler = new LabelImg(element, {\n  width: 800,\n  height: 600,\n  bgColor: `#000`, // 背景色\n  imagePlacement: \"default\", // default | center\n});\n// 注册图形\nlabeler.register(\"polygon\", {\n  type: \"Polygon\",\n  tag: \"多边形\",\n});\n// 加载图片\nlabeler.load(url);\n// 选择标注多边形\nlabeler.label(\"polygon\");\n```\n\n### 图形\n\n```js\nconst { Shape } from \"label-img\"\n// or\nconst Shape = LabelImg.Shape\n\n// IShapeOptions\nconst shapeOptions = {\n  id, // 图形唯一 id 可自动生成\n  type, // 图形类型 必填 Polygon | Rect\n  name, // 图形名称\n  positions, // 坐标集合 ex: [[0, 0], [100, 100]]\n  data, // 自定义数据 可用于存储实体属性等内容\n  tag, // 展示在图形上的说明标签\n  showTag, // 是否展示标签\n  closed, // 是否闭合\n  visible, // 是否可见\n  active, // 是否被选中\n  disabled, // 是否禁用\n  /**\n   * { normal, active, disabled }\n   * {\n   *  normal: {\n   *    dotColor: \"red\", // 坐标点颜色\n   *    dotRadius: 3, // 坐标点大小\n   *    lineColor: \"#c30\", // 连线颜色\n   *    lineWidth: 2, // 连线宽度\n   *    fillColor: \"pink\", // 填充色\n   *  }\n   * }\n   */\n  style, // 图形样式\n}\nconst shape = new Shape(shapeOptions)\n// or\n/**\n * @id      图形注册 ID\n * @options 配置  Partial\u003cOmit\u003cIShapeOptions, \"type\"\u003e\u003e\n */\nconst shape = LabelImg.createShape(id, options)\n// 添加到画布中\nlabeler.addShape(shape)\n```\n\n### 注册图形\n\n```js\n/**\n * @id        图形 ID   Polygon: 多边形，Rect: 矩形\n * @options   图形配置  Omit\u003cIShapeCfg, \"registerID\"\u003e\n */\nlabeler.register(id, options);\n```\n\n### 加载图片\n\n```js\n/**\n * @param   url || file\n * return   Promise\n */\nlabeler.load(param);\n```\n\n### labeler API\n\n```js\nisRegister(id)  // 判断是否注册\nlabel(id, continuity)  // 选择标注类型\nlabelOff()  // 取消当前标注\naddShape(shape, index)  // 添加图形\nremove(shape || id)  // 删除图形\nsetActive(shape)  // 选中某一图形\ngetShapeList()  // 获取图形列表\nsetGuideLine(status?: boolean)  // 是否启用参照线\nsetTagShow(status?: boolean)  // 是否启用标签\nisTagShow()  // 获取是否启用标签\ntoDataURL()  // 导出标注图片的 base64 格式\nsetContinuity(status: boolean)  // 设置是否连续标注\nrender()  // 渲染画面\nforceRender()  // 强制渲染\n```\n\n### Shape API\n\n```js\ngetPositions()  // 获取坐标点集合\nupdatePositions(positions) // 更新坐标信息\nsetActive(status) // 设置选中\nisActive()  // 是否被选中\nclose()  // 图形闭合\nisClose()  // 是否闭合\ndisabled() //禁用\nisDisabled()  // 是否禁用\nhidden()  // 隐藏\nisHidden()  // 是否隐藏\nshow()  // 显示\nisShowTag()  // 是否展示标签\ntagShow(status?: boolean) // 控制标签展示\nsetTag(val)  // 标签内容\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhold-baby%2Flabel-img","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhold-baby%2Flabel-img","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhold-baby%2Flabel-img/lists"}