New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@wecity/img-mark

Package Overview
Dependencies
Maintainers
18
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wecity/img-mark

图片标注工具

latest
npmnpm
Version
1.0.0
Version published
Maintainers
18
Created
Source

@wecity/img-mark

npm i @wecity/img-mark -S

@wecity/img-mark是一个二次封装的图片标注工具

imgMark

imgMark.initMap

初始化画布,返回Promise

<div id='cvs'></div>  

import { imgMark } from '@wecity/img-mark'
const gmap = await imgMark.initMap({ id: 'cvs', img: pic, options: { zoom, mode: 'BAN' } })
字段名类型描述
idobjectmap container
imgpng/gif等标注图片
optionsobject配置项

imgMark.initImg

初始化标注图片,返回Promise

<div id='cvs'></div>  

import { imgMark } from '@wecity/img-mark'
const gmap = await imgMark.initMap({ id: 'cvs', img: pic, options: { zoom, mode: 'BAN' } })
const imgLayer = await imgMark.initImg({ img: pic, map: gMap })
字段名类型描述
mapgMapgMap
imgpng/gif等标注图片
zIndexint层级

imgMark.initFeature

初始化Feature,返回Promise

<div id='cvs'></div>  

import { imgMark } from '@wecity/img-mark'
const gmap = await imgMark.initMap({ id: 'cvs', img: pic, options: { zoom, mode: 'BAN' } })
const imgLayer = await imgMark.initImg({ img: pic, map: gMap })
const featureLayer = await imgMark.initFeature({ map: gMap, img: pic, registerEvt: true })
字段名类型描述
mapgMapgMap
imgpng/gif等标注图片
zIndexint层级
registerEvtboolean默认注册一些通用的事件

registerEvt注册事件

  • 标注新增、编辑上图
  • 选中图层
    map.events.on('featureSelected', feature => {
      map.setActiveFeature(feature);
    })
    map.events.on('featureUnselected', () => {
      map.setActiveFeature(null);
    })
    map.events.on('featureUpdated', (feature, shape) => {
      feature.updateShape(shape);
    })
    map.events.on('drawDone', async (type, data) => {
      const drawingStyle = map.drawingStyle
      const uuid = utils.getUuid(type)
      if (FEATURE_MODULE.includes(type)) {
        const module = utils.bigCamel(type)
        const instance = new AILabel.Feature[module](
          uuid, // id
          getModeData(type, data), // shape
          {name: uuid}, // props
          drawingStyle // style
        )
        feature.addFeature(instance)
      }
    })

imgMark.binExtraData

绑定自定义数据大屏props到feature

字段名类型描述
anyany自定义数据
// 设置
const instance = new AILabel.Feature[module](
    uuid, // id
    shape, // shape
    { name: uuid, extra: this.extraData }, // props
    drawingStyle // style
)
feature.addFeature(instance)


// 获取
feature = {
    props: {
        extra: ''
    }
}   

utils

方法名参数描述
bigCamelstr => string字符串转大驼峰,如: Camel
getUuidstr => stringuuid
getImgInfoimage获取图片信息:宽高等, 返回promise
hex2rgbcolor(16进制), 透明的16进制转rgba
import { utils } from '@wecity/img-mark' 

utils.bigCamel('CAMEL') // Camel
utils.bigCamel('camel') // Camel

其他包含ailabel方法

import AILabel from 'ailabel'
const imgMark = {
  ...AILabel
}
export default imgMark

Keywords

图片标注;计算机视觉

FAQs

Package last updated on 18 Jan 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts