Package 'annotator'

Title: Image Annotation and Polygon Outlining using Free Drawing
Description: Provides functions to create image annotations through polygon outlining. Annotator has the same function as 'graphics::locator()' but achieves its purpose through drawing, rather than multiple mouse clicks. It is based on the 'htmlwidgets' package and 'fabric.js' JavaScript library <http://fabricjs.com/>.
Authors: Mihai Valcu [aut, cre]
Maintainer: Mihai Valcu <[email protected]>
License: GPL (>= 3)
Version: 0.0.3.1
Built: 2025-02-08 02:51:23 UTC
Source: https://github.com/valcu/annotator

Help Index


Create an annotation widget

Description

This function creates an annotation using htmlwidgets. The widget can be rendered on HTML pages generated from Shiny or other applications.

Usage

annotate(
  im,
  resultId = "annot_id",
  brushWidth = 4,
  brushColor = "red",
  opacity = 0.5,
  fill = "grey"
)

Arguments

im

the input image. If missing, a transparent 800x600 png is used.

resultId

the id of the div in the UI where the annotation (the drawn polygon) is stored. Only relevant when the widget is used in shiny. Defaults to "annot_id".

brushWidth

default to 3 pixels.

brushColor

Any valid CSS color. For example "red", "rgba(255,93,0,1)", or "#1c4564".

opacity

default to 0.5.

fill

default to 'gray'

Value

An object generated by htmlwidgets::createWidget().

Examples

if (interactive()) {
  require(annotator)
  im = system.file("sample_images", "aves", "5.png", package = "annotator")
  annotate(im)
}

Image annotation

Description

Image annotation using free drawing.

Author(s)

Mihai Valcu [email protected]


Widget output function for use in Shiny

Description

Widget output function for use in Shiny

Usage

annotatorOutput(outputId, width = "auto", height = "auto", ...)

Arguments

outputId

The name of the input.

width

in CSS units, default to "auto".

height

in CSS units, default to "auto".

...

further arguments to pass to htmlwidgets::shinyWidgetOutput() e.g. inline.

Value

An object generated by htmlwidgets::shinyWidgetOutput().

See Also

runExample()

Examples

# Print the directory containing the code for all examples to see this function in use.
system.file("examples", package = "annotator")

this is an 800x600 transparent png

Description

this is an 800x600 transparent png

Usage

empty_png()

Widget render function for use in Shiny

Description

Widget render function for use in Shiny

Usage

renderAnnotator(expr, env = parent.frame(), quoted = FALSE)

Arguments

expr

An annotator expression.

env

A environment. Default to parent.frame().

quoted

A boolean value.

Value

An object generated by htmlwidgets::shinyRenderWidget().

See Also

runExample()

Examples

# Print the directory containing the code for all examples to see this function in use.
system.file("examples", package = "annotator")

Run Shiny Examples

Description

Launch Shiny example applications bundled in annotator.

Usage

runExample(example, ...)

Arguments

example

The name of the example to run. Available are: ⁠01_hello⁠, ⁠02_pipeline⁠

...

further arguments to pass to shiny::runApp()

Value

No return value, called for its side effects.

Examples

## Only run this example in interactive R sessions
if (interactive()) {
 annotator::runExample("01_hello")
 annotator::runExample("02_pipeline")

 # Print the directory containing the code for all examples
 system.file("examples", package = "annotator")
}