New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

simple-image-label

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-image-label

Javascript image annotate, use in deep learning

  • 0.0.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-33.33%
Maintainers
1
Weekly downloads
 
Created
Source

simple-image-label

View English readme | 查看中文版readme
Simple image annotate use in JavaScript , support YOLO and VOC annotate point for object detection or deep-learning.

Preview

preview

Use in your project

Install simple-image-label

# npm
npm install simple-image-label -S
# yarn
yarn add simple-image-label
# pnpm
pnpm add simple-image-label
Use in JavaScript
<div id="YourElementId"></div>
// use require
const SimpleImageLabel = require('../libs/simpleImageLabel').default
// use es6 import
import SimpleImageLabel from '../libs/simpleImageLabel'
// use simple image label in your html element, must use id selector
const simpleImageLabel = new SimpleImageLabe({
    el: 'YourElementId', 
    imageUrl: 'yourImageUrl', 
    labels: [],
    contextmenu: (e) => {
        // mouse right click event
    },
    labelClick: (label) => {
        // label click event
    },
    error: (err) => {
        // error event
        console.log(err);
    }
});
Use in vue3
<template>
    <div id="YourElementId"></div>
</template>
<script setup>
import SimpleImageLabel from 'simple-image-label'
import { ref, onMounted } from 'vue';
const simpleImageLabel = ref(null);
onMounted(() => {
    simpleImageLabel.value = new SimpleImageLabel({
        el: 'YourElementId'
        imageUrl: props.imageUrl,
        labels: props.labels,
        contextmenu: (e) => {
            emit('contextmenu', e)
        },
        labelClick: (label) => {
            emit('labelClick', label)
        },
        error: (e) => {
            emit('error', e)
        }
    });
})
</script>
Use in React
import SimpleImageLabel from 'simple-image-label';
import img from './x.png'
import { useEffect } from 'react';
const ImageLabelComponent = () => {
    let simpleImageLabel = null
    useEffect(() => {
        initSimpleDom()
    }, [])
    function initSimpleDom() {
        simpleImageLabel = new SimpleImageLabel({
            el: 'YourElementId',
            imageUrl: img,
            labels: [],
            contextmenu: (e) => {
                console.log(e);
            },
            labelClick: (label) => {
                console.log(label);
            },
            error: (e) => {
                console.log(e);
            }
        })
    }
    function getAllLabels() {
        const labels = simpleImageLabel.getLabels()
        console.log('labels', labels);
    }
    return (
        <div>
            <div id="YourElementId"></div>
            <button onClick={getAllLabels}>Get all labels</button>
        </div>
    );
}
export default ImageLabelComponent;

Develop & Install & Run demo

Install

# npm
npm install
# yarn
yarn
# pnpm
pnpm install

Run

# npm
npm run start
# yarn
yarn start
# pnpm
pnpm run start

Build

# npm
npm run build
# yarn
yarn build
# pnpm
pnpm run build

API

SimpleImageLabel options

PropertyTypeDescription
elstringHtml element id
imageUrlstringImage path
labelsarraydefault labels
readOnlybooleanEnable/Disable read only mode
contextmenufunctionright click event
labelClickfunctionleft click event
errorfunctionerror event

SimpleImageLabel function

functionparamsDescription
getLabels()-Get all labels
activeLabel()-Get active label
setImage(imageUrl)imageUrlSet image
setLabels(labels)labelsSet labels
getImageInfo()-Get image width and height
getCoordinate(label)labelGet label coordinate
getLabelsCoordinate()-Get all labels coordinate
convertToYoloCoordinate(label)labelGet label YOLO coordinate
getLabelsYoloCoordinate()-Get all labels YOLO coordinate
setLabelActive(uuid)uuidSet label active status by uuid
clearAllLabelActive()-Clear active status
removeAllLabels()-Remove all labels
removeLabelByUuid(uuid)uuidRemove a label by uuid
setLabelByUuid(uuid, attr)uuid, attrSet label attr by uuid. attr type is object
getLabelByUuid(uuid)uuidGet label by uuid
setReadOnly(readOnly)readOnlySet read only mode.readOnly type is boolean

Keywords

FAQs

Package last updated on 11 Sep 2023

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc