Coder Social home page Coder Social logo

annotorious / annotorious-v2-selector-pack Goto Github PK

View Code? Open in Web Editor NEW
11.0 11.0 19.0 1.49 MB

Additional selection tools for Annotorious and the Annotorious OpenSeadragon plugin

License: BSD 3-Clause "New" or "Revised" License

HTML 5.18% JavaScript 94.82%

annotorious-v2-selector-pack's Introduction

Aerial view of Schönbrunn Palace in Vienna annotated with Annotorious

IMPORTANT This repository is work in progress. I am building the next major release of Annotorious. If you are looking for the most recent official release, visit the main project homepage. Documentation in this Readme is only for the upcoming alpha release and will not work with Annotorious 2.7.x!

Annotorious 3.0 Beta

Add image annotation functionality to any web page with a few lines of JavaScript.

Getting Started

npm install --save @annotorious/annotorious

Create an annotator instance on an existing Image element.

import { createImageAnnotator } from '@annotorious/annotorious';

// Import essential CSS styles
import '@annotorious/annotorious/annotorious.css';

// Image element ID or DOM element
const anno = createImageAnnotator('sample-image');

// Load annotations in W3C Web Annotation format
anno.loadAnnotations('./annotations.w3c.json');
       
// Attach listeners to handle annotation events
anno.on('createAnnotation', function(annotation) {
  console.log('created', annotation);
});

Script Import via CDN

<html>
  <head>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@annotorious/annotorious@latest/dist/annotorious.css">
    <script src="https://cdn.jsdelivr.net/npm/@annotorious/annotorious@latest/dist/annotorious.js"></script>
  </head>
  <body>
    <img id="my-image" src="my-image.jpg" />

    <script>
      window.onload = function() {
        var anno = Annotorious.createImageAnnotator('my-image');
      }
    </script>
  </body>
</html>

Using with OpenSeadragon

Annotorious provides seamless integration with the OpenSeadragon viewer for zoomable images and IIIF.

npm install @annotorious/openseadragon

Set up your OpenSeadragon viewer first, and then create an annotator instance for the viewer. Note that Annotorious requires OpenSeadragon 3 or higher.

import { createOSDAnnotator } from '@annotorious/openseadragon';

// Import essential CSS styles
import '@annotorious/annotorious/annotorious-openseadragon.css';

window.onload = function() {
  var viewer = OpenSeadragon({
    id: 'openseadragon',
    tileSources: {
      type: 'image',
      url:  '/my-image.jpg'
    }
  });

  var anno = createOSDAnnotator(viewer);

  anno.loadAnnotations('./annotations.w3c.json');
       
  anno.on('createAnnotation', function(annotation) {
    console.log('created', annotation);
  });
}

Script Import via CDN

<html>
  <head>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@annotorious/openseadragon@latest/dist/annotorious-openseadragon.css">
    <script src="https://cdn.jsdelivr.net/npm/@annotorious/openseadragon@latest/dist/annotorious-openseadragon.js"></script>
  </head>
  <body>
    <div id="openseadragon"></div>

    <script>
      window.onload = function() {
        var viewer = OpenSeadragon({
          id: 'openseadragon',
          tileSources: {
            type: 'image',
            url:  '/my-image.jpg'
          }
        });
        
        var anno = AnnotoriousOSD.createOSDAnnotator(viewer);
      }
    </script>
  </body>
</html>

Using in React

Annotorious provides React bindings for both the standard and the OpenSeadragon module.

npm install @annotorious/react

The <Annotorious> component provides a root context for all Annotorious utility hooks. Use <ImageAnnotator> or <OpenSeadragonAnnotator> to attach annotation layers on images or OpenSeadragon.

import { Annotorious, ImageAnnotator } from '@annotorious/react';

import '@annotorious/react/annotorious-react.css';

export function AnnotatableImage() => {

  return (
    <Annotorious>
      <ImageAnnotator>
        <img src="my-image.jpg" alt="Example" />
      </ImageAnnotator>
    </Annotorious>
  )

}

annotorious-v2-selector-pack's People

Contributors

architrixs avatar erikradisch avatar hero-solutions avatar pvbaudin avatar rsimon avatar yyhhkk12 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

annotorious-v2-selector-pack's Issues

Free draw tool naming

I'm currently working out a free drawing tool, but I'm unsure what to call it. For my current work in progress, I'll call it "freedrawing", with class names such as "EditableFreeDrawing". Please let me know if you think this should be called differently.

Point annotation tool

Since this would be pretty fundamental, it's probably worth including into the core distribution. (I.e. not as an extra plugin.)

Circle Annotation Tool Causes Error On Clicking OK

I know this is in early form, but most of the functionality works for us! But there's an error on hitting OK on the note:

ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'split' of null
TypeError: Cannot read property 'split' of null
    at Xu (openseadragon-annotorious.min.js:21649)
    at Object.Ju [as SvgSelector] (openseadragon-annotorious.min.js:21658)
    at openseadragon-annotorious.min.js:22744
    at i.addAnnotation (openseadragon-annotorious.min.js:22745)

I prettified openseadragon-annatorious before getting this error, so the code that's bombing is:

       Xu = function (e) {
          return Ku(e)
            .getAttribute("points")
            .split(" ")
            .map(function (e) {
              return e.split(",").map(function (e) {
                return parseFloat(e.trim());
              });
            });
        },

Register the RubberBandCircleTool in the ToolsRegistry

Registering the RubberBandCircleTool in the ToolsRegistry currently still happens in the main repository. This probably needs to moved to the selector pack. I'd do it myself, but I'm not sure what the preferred way is to do this.

Multipolygon annotation tool

This has been brought up as a feature request multiple times. A tool for creating an annotation target consisting of multiple polygon shapes. There's nothing that prevents this in principle. Just needs thinking through the interaction design (and writing the code :-)

Probably, this is best implemented as a separate drawing tool plugin.

Issue with executing `npm start` command.

I met an error Error: Cannot find module 'webpack-cli/bin/config-yargs' while executing npm start.
According to stackoverflow, It looks webpack version is the cause of the error.
Thus, I changed start script in package.json from "webpack-dev-server --open --mode=development -d" to webpack serve --open --mode=development.
After changing script, I got another error Error: Cannot find module '@babel/core'. I solved this error by executing command npm install --save-dev @babel/core.

Point tool not working on touch

Seems completely broken for Annotorious standard, and partially broken in the OpenSeadragon version. In OSD it's possible to create a point. But it's not possible to move the point after creating.

point tool bug

I'm using selector pack and formatters, it is ok for all shapes except point, its label is too large and doesn't fit in viewer:
image
please fix this bug
thanks in advance

Fixing the starting point of the circle

Annotorious version: standard
Hello. I'm trying drawing circle annotation on image. When I drag the mouse to bottom right to draw a circle, starting point is fixed. But, other direction is not fixed.
I want to fix the starting point. Could you make a fix mode?

g

Selecting to the left or up with the Ellipse tool

Hi,

Just wanted to let you know that when selecting with the ellipse tool, it works as expected when mouse moves to the right, but works unexpectedly, when moving mouse to the left. See the GIF:
ellipse

Other tools worked as expected.

Integrating annotorius selector pack with openseadragon

I am trying to integrate annotorius selector pack with openseadragon and below is my code.

import { Component, OnInit, ViewChild, ElementRef, HostListener } from '@angular/core';
import * as OpenSeadragon from 'openseadragon';
import * as SelectorPack from '@recogito/annotorious-selector-pack';
import * as Annotorious from '@recogito/annotorious-openseadragon';
import {ColorSelectorClassWidget} from './widgets/color-selector-class';
@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit{

  url: any = 'https://recogito.github.io/images/640px-Hallstatt.jpg';
  @ViewChild('ref') ref!: ElementRef;
  viewer: any;
  annotorius: any;


  constructor() { }

 

  ngOnInit(){
  }

  ngAfterViewInit() {

    setTimeout(()=>{
      this.initOpenSeadragon();

    })
  }
  initOpenSeadragon() {
     const tileSources = {
      type: "image",
      url: this.url
    };
    this.viewer = OpenSeadragon({
      element: this.ref.nativeElement,
      prefixUrl: "assets/openseadragon/",
      panHorizontal: true,
      // defaultZoomLevel: 0,
      // homeFillsViewer: true,
      minZoomLevel: 0,
      maxZoomLevel: 10,
      visibilityRatio: 0,
      tileSources: tileSources,
      degrees: 0,
      showRotationControl: true,
    });
    this.viewer.addHandler('open', () => {
    setTimeout(()=>{
      var tiledImage = this.viewer.world.getItemAt(0); 
      const point = new OpenSeadragon.Point(0,0);
      this.viewer.viewport.zoomTo(1.1, null, true);
    })
  })
    this.initAnnotorius();
  }
  initAnnotorius() {
    this.annotorius = Annotorious(this.viewer, { widgets: [
      {widget: ColorSelectorClassWidget},
      { widget: 'COMMENT' },
      
    ] });
    console.log(SelectorPack)
    Annotorious.SelectorPack(this.annotorius);
    console.log(this.annotorius.listDrawingTools());
  }
}

And i am getting error

image

Need help using the line tool

I can't use the line tool, it exists in the src tools folder but cannot be used. It doesn't exist in the latest min.js file released. I tried to generate it from the source code typing "npm run build" command, but it did not work so I could not build it for the latest selector min.js file. What is the best practice to use the line tool without suffering?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.