Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: shiny app crashes on browser when using qr_scanner #42

Open
mkaranja opened this issue Mar 21, 2024 · 3 comments
Open

Error: shiny app crashes on browser when using qr_scanner #42

mkaranja opened this issue Mar 21, 2024 · 3 comments

Comments

@mkaranja
Copy link

mkaranja commented Mar 21, 2024

I have a minimal app working well on my local but crashes on shiny server pro when I click 'Scan Barcode' button (see attached error log). I think the app can't find camera on browser. Is it possible to have a pop-window on browser requesting access to your camera?

library(shiny)
library(opencv)

UI

ui <- fluidPage(
titlePanel("Read QR code in real-time"),
fluidRow(
actionButton("barcode", "Scan Barcode"),
textOutput("results")
)
)

server logic

server <- function(input, output) {
observeEvent( input$barcode , {
identity <- opencv::qr_scanner(draw = FALSE, decoder = "wechat")
output$results <- renderText({
identity
})
})
}

Run the application

shinyApp(ui = ui, server = server)

Error log:
Screenshot from 2024-03-21 10-19-38

Thanks

@mkaranja
Copy link
Author

mkaranja commented Mar 26, 2024

I have seen many applications using BisonCam, https://cozmo.github.io/jsQR/. And I think it would be a good addition to the opencv::qr_scanner() function.

@jeroen
Copy link
Member

jeroen commented Mar 26, 2024

Sadly it is not so easy. The qr_scanner will open a camera on the R session, which is on the server side.

But it seems like you can accomplish what you need with BisonCam without the need for R? Or you can use a library to take a picture in the browser and upload that to R and use opencv:: ocv_qr_detect to read and scan the image.

@mkaranja
Copy link
Author

Maybe but I'm not giving up.
We can borrow from this shiny app: https://matthew-j-oldach.shinyapps.io/shiny-filteRs/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants