Code Monkey home page Code Monkey logo

bbox-annotator's Introduction

Bounding box annotator

A bounding box annotation tool written in CoffeeScript/JavaScript. There is an online demo at https://kyamagu.github.io/bbox-annotator/demo.html

Contents

bbox_annotator.coffee  Main code.
demo.html              Example to host on a private server.
mturk.html             Example to use in Amazon MTurk.
README.md              This documentation.

Be sure to unescape × with ร— when directly editing an MTurk template on the Amazon requester UI.

Compile

Compile the coffee script to get a javascript.

coffee -c bbox_annotator.coffee

Or, go to http://coffeescript.org/ and compile the coffeescript.

Usage

Load the compiled javascript codes inside HTML.

<script src="bbox_annotator.js" type="text/javascript"></script>

Embed a block element for annotation tool and a form element in HTML.

<div id="bbox_annotator"></div>
<input id="annotation_data" name="annotation_data" type="hidden" />

Then, attach a piece of script to launch the annotation tool. The annotator takes a callback function on change of the annotation data. Use JSON format to display the value.

<script type="text/javascript">
$(document).ready(function() {
  var editor = new BBoxAnnotator({
    url: "/url/to/image.jpg",
    onchange: function(annotation) {
      $("#annotation_data").val(JSON.stringify(annotation));
    }
  });
});
</script>

The returned annotation is an array of objects. Here is an example.

[
  {
    "top": 0,
    "left": 0,
    "width": 100,
    "height": 100,
    "label", "object"
  }
]

Check the attached demo.html and mturk.html for how to use.

Options

The BBoxAnnotator object takes options to change its behavior.

  • id: CSS selector for the annotator element. Default is "#bbox_annotator".
  • input_method: One of the "text", "select", and "fixed". This will change how to input associated annotation text.
  • labels: A string, or an array of strings. Set of labels used for suggestion in "text" or "select" input. When fixed, only the first element is chosen.
  • width: Width of the image. The default is the original width of the image.
  • height: Height of the image. The default is the original height of the image.
  • show_label: Flag to display a label in the box. Default is true for "text" and "select" input, and false for "fixed" input.
  • border_width: Size of border around the image. Default is 2. Leaving it 0 can make it hard to start annotation around the image border.
  • multiple: Defines if multiple boxes could be selected. Default is true.
  • guide: Enable vertical and horizontal guide lines. Specify true, or object that specifies color like {'color': '#fff'}.

License

The code may be redistributed under BSD license.

bbox-annotator's People

Contributors

arudenko avatar kyamagu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bbox-annotator's Issues

Reatain bounding box

Is there any way we can retain the bounding box for that particular image
i.e whenever we open the image we see the bounding boxes drawn previously.
right now annotation data can be saved in db, but drawn rectangles go after refresh

Make it work on mobile devices

Hi.

I have used this on desktop and it works well. However, I could not get it to work on a mobile device: touch events are fired instead and it does not work.

Multiple images in one MTurk HIT?

This is a dumb question, because I don't know javascript.

I've been using your Mturk html example for awhile. But I'd like to have multiple distinct images on a single HIT or screen, so that a worker can annotate, say, 5 images.

Which portion of the script would I need to repeat to display multiple images and allow an annotation on each? Thanks in advance!

Resize Image

Hello,

Thanks for your wonderful code! It is very helpful and I am trying to use it for my Mturk survey.
I would like to resize the image and I have tried to change the width of image_element but it seems that instead of resizing, the image will be cropped.
I would be grateful if you could let me know whether it is possible to resize the image by some changes in the code.

implement crosshair covering full image

Hi,

thanks for the nice tool, am planning to use it for our image annotation on Mturk as well. However, there is a small challenge I could not yet solve...

For our images, we would like to use a crosshair that extends over the whole image, such as https://codepen.io/anon/pen/LXZjwX, https://gist.github.com/salembeats/6f9aeb3f3438647a0f53715ae2e904bc or http://jsfiddle.net/WmZ44/1/. Reason behind is, is that objects tend to be somewhat large, and this is a great help in properly selecting the starting point of the bounding box.

However, tried to implement the latter link today, as being the most simple, and kinda equivalent to the former. After struggling for hours also understood some more of Javascript and Jqueri, the code seems fine and correct to my understanding, but the system does not work within the mTurk sandbox.

could you provide some clarification here? for referencing, the version of the code I created/used today is attached:
annotatescript.txt

your help / support is kindly appreciated!

ps: to add on this, //test3c seems to me the location where the relevant javascript code should be added...

Ability to zoom in

Could you give me some direction as to how I may implement a zooming in/zooming out feature to create more accurate bounding boxes?

Thanks

Ability to draw on every div

Hi there!
Could You tell me how to implement Your annotator in Angular 7 project?
And is it possible to draw on every div? (doesn't have to be img)
Regards!

Adjustable bounding boxes

Is there a way to make the boxes adjustable so that once a box has been drawn and labeled that it's dimensions can be adjusted without having to start over?

Bounding box annotation for many images

@kyamagu If I have a huge dataset with lots of images to annotate, what changes should be made in the code and where? Could you please direct me to this - I am not quite familiar with writing javascript codes.
Thanks!

Detect elements from DOM browser

Hi Kyamagu,

Thank you for making this annotator as its very useful to solve some real world problems.

But my problem is a bit different as I am looking to detect elements on web page and draw bounding boxes around them. For example: there is a form on web page and i want to detect input fields and draw bounding boxes around them.
As I explored your library, it requires the image URL and it only draws on images. Is there anything in this to achieve my requirement ?

Regards,
Ankit Aggarwal

Extend to display multiple images on same page

Thank you for this awesome tool. How would you recommend I go about extending this code so I can have 2 images being displayed on every page instead of just one? I understand that I would have a second variable $image_url2, for the other image but what are the other changes needed to make this possible?
Thanks

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.