R/init.R

Defines functions is_rstudio is_mojave is_check is_iterm2 is_macos .onLoad enum_id enum_label .onAttach

enums <- new.env()


.onAttach <- function(libname, pkgname){
  enums$type <- enums_types()
  enums$depth <- enums_depth()
}

enum_label <- function(type, id){
  kv <- enums[[type]]
  recoder(id, from = kv$key, to = kv$value)
}
enum_id <- function(type, label){
  kv <- enums[[type]]
  recoder(label, from = kv$value, to = kv$key)
}

.onLoad <- function(libname, pkgname){
  if(is_check()){
    set_num_threads(2)
  }
}

is_macos <- function(){
  grepl("darwin", R.Version()$platform)
}

is_iterm2 <- function(){
  identical(Sys.getenv('TERM_PROGRAM'), 'iTerm.app')
}

is_check <- function(){
  grepl('opencv.Rcheck', getwd(), fixed = TRUE)
}

is_mojave <- function(){
  ver <- utils::tail(strsplit(utils::sessionInfo()$running, ' ')[[1]], 1)
  as.numeric_version(ver) >= "10.14"
}

is_rstudio <- function(){
  Sys.getenv('RSTUDIO') == "1"
}

Try the opencv package in your browser

Any scripts or data that you put into this service are public.

opencv documentation built on Nov. 2, 2023, 5:52 p.m.