Open leeper opened 7 years ago
I am working on a new Shiny interface for my application of tabulizer::locate_areas. When finished I'll do a pull request.
to give you an idea, this is what my code currently looks like; suggestions are welcome.
server <- function(input, output, session) {
#This script expects to find a variable called thumbnaildir containing the name of the directory containing thumbnails
thumbnails <- normalizePath(list.files(thumbnaildir,full.names = TRUE))
pages <- length(thumbnails)
Arealist <- vector("list", pages)
updateSliderInput(session, "page", max = pages)
output$image2 <- renderImage({
return(list(
src = thumbnails[input$page],
contentType = "image/png",
width= paste0(100*input$zoom,"%"),
height=paste0(100,input$zoom,"%"),
alt = thumbnails[input$page]
))
}, deleteFile = FALSE)
xy_range_str <- function(e) {
if(is.null(e)) return("NULL")
list=c("top"=round(e$ymin/input$zoom, 1),
"left"=round(e$xmin/input$zoom, 1),
"right"=round(e$ymax/input$zoom, 1),
"bottom"=round(e$ymin/input$zoom, 1))
}
output$image_brushinfo <- renderText({
xy_range_str(input$image_brush)
})
update_list <- function(brush) {
if(!is.null(brush)) Arealist[[input$page]]<<-xy_range_str(brush)
}
observe({
if(input$page > 0) update_list(input$image_brush)
})
observe({
if(input$done > 0){
update_list(input$image_brush)
stopApp(Arealist)
}
})
}
ui <- fluidPage(
titlePanel("Image output"),
fluidRow(
column(4,
wellPanel(
sliderInput("page", "page :", min = 1, max = 10,
value = 1, step = 1),
sliderInput("zoom", "zoom :", min = 1, max = 3,
value = 1, step = .1),
actionButton("done", "Done")
),textOutput("image_brushinfo")),
column(8,
imageOutput("image2",height ="auto", width = "auto",
brush = brushOpts(id = "image_brush",
direction = c("xy"), resetOnNew = TRUE))
)
)
)
shinyApp(ui = ui, server = server)
I placed another incarnation of a potential shiny interface for tabulizer online on www.keuskamp.com. If you want to have a look please mail send me an email so that I can make an account. I am not a Shiny expert at all so I'll need some time to optimize the code, but its getting there
Both
locate_areas()
andextract_areas()
use, optionally, a Shiny interface to identify areas. This could probably improved because I'm not much of a Shiny expert. Any advice on improvements and new functionality can be pitched here and/or submitted as PRs.