ropensci / opencv

R bindings for OpenCV
https://docs.ropensci.org/opencv
Other
137 stars 27 forks source link

magick to opencv #36

Open jwijffels opened 3 years ago

jwijffels commented 3 years ago

I'm using this package a lot to parse out data from Transkribus and get the text lines in order to build some handwritten text recognition models. For the data preparation there, I regularly switch between tools part of magick and tools part of opencv, normally I do this now as follows, it would be nice to have something more native in opencv.

magick_to_opencv <- function(img){
  p <- tempfile()
  on.exit({
    if(file.exists(p)){
      file.remove(p) 
    }
  })
  magick::image_write(img, path = p)
  image <- opencv::ocv_read(p)
  image
}
jeroen commented 3 years ago

Go for it, you have write access :P Maybe keep the magick dependency a Suggets though, we don't want to make things too heavy to install.

jwijffels commented 3 years ago

Yes, I know, just putting this here as a reminder to myself.

JanMarvin commented 1 year ago

Just stumbled over this issue, I have a conversion function here: https://github.com/JanMarvin/opencv/commit/269433e78006064f2166092379228e8d4f8f32d8. The config part was not straight forward, but maybe its useful for you.