{"id":13423739,"url":"https://github.com/ropensci/opencv","last_synced_at":"2025-12-27T10:56:14.417Z","repository":{"id":55529598,"uuid":"134328459","full_name":"ropensci/opencv","owner":"ropensci","description":"R bindings for OpenCV","archived":false,"fork":false,"pushed_at":"2025-03-06T19:21:43.000Z","size":399,"stargazers_count":138,"open_issues_count":15,"forks_count":27,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-03-06T19:26:17.543Z","etag":null,"topics":["opencv","opencv-library","r","r-package","rstats","unconf","unconf18"],"latest_commit_sha":null,"homepage":"https://docs.ropensci.org/opencv","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ropensci.png","metadata":{"files":{"readme":"README.md","changelog":"NEWS","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-05-21T21:44:00.000Z","updated_at":"2025-03-06T19:21:47.000Z","dependencies_parsed_at":"2023-09-24T23:53:43.522Z","dependency_job_id":"dbab3ffb-277b-4b44-ab8b-915d9ca368ac","html_url":"https://github.com/ropensci/opencv","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ropensci%2Fopencv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ropensci%2Fopencv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ropensci%2Fopencv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ropensci%2Fopencv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ropensci","download_url":"https://codeload.github.com/ropensci/opencv/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243767217,"owners_count":20344890,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["opencv","opencv-library","r","r-package","rstats","unconf","unconf18"],"created_at":"2024-07-31T00:00:41.546Z","updated_at":"2025-12-27T10:56:14.371Z","avatar_url":"https://github.com/ropensci.png","language":"C++","funding_links":[],"categories":["C++"],"sub_categories":[],"readme":"# Bindings to 'OpenCV' Computer Vision Library\n\n\u003e Experimenting with computer vision and machine learning in R. This \n  package exposes some of the available 'OpenCV' \u003chttps://opencv.org/\u003e algorithms,\n  such as edge, body or face detection. These can either be applied to analyze \n  static images, or to filter live video footage from a camera device.\n\n[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/opencv)](http://cran.r-project.org/package=opencv)\n[![CRAN RStudio mirror downloads](http://cranlogs.r-pkg.org/badges/opencv)](http://cran.r-project.org/web/packages/opencv/index.html)\n\n\n## Installation\n\nOn Windows and MacOS, the package can be installed directoy from CRAN:\n\n```r\ninstall.packages(\"opencv\")\n```\n\n### Install from source\n\nTo install from source on MacOS, you need to install the opencv library from homebrew:\n\n```sh\nbrew install opencv\n```\n\nOn Ubuntu or Fedora you need [`libopencv-dev`](https://packages.debian.org/testing/libopencv-dev) or [`opencv-devel`](https://src.fedoraproject.org/rpms/opencv):\n\n```sh\nsudo apt-get install libopencv-dev\n```\n\nAnd then install the R bindings:\n\n```r\ninstall.packages(\"opencv\", type = \"source\")\n```\n\n## Basic stuff:\n\nFace recognition:\n\n```r\nunconf \u003c- ocv_read('https://jeroen.github.io/images/unconf18.jpg')\nfaces \u003c- ocv_face(unconf)\nocv_write(faces, 'faces.jpg')\n```\n\nOr get the face location data:\n\n```r\nfacemask \u003c- ocv_facemask(unconf)\nattr(facemask, 'faces')\n```\n\n## Live Webcam Examples\n\nLive face detection:\n\n```r\nlibrary(opencv)\nocv_video(ocv_face)\n```\n\nEdge detection:\n\n```r\nlibrary(opencv)\nocv_video(ocv_edges)\n```\n\n## Combine with Graphics\n\nReplaces the background with a plot:\n\n```r\nlibrary(opencv)\nlibrary(ggplot2)\n\n# get webcam size\ntest \u003c- ocv_picture()\nbitmap \u003c- ocv_bitmap(test)\nwidth \u003c- dim(bitmap)[2]\nheight \u003c- dim(bitmap)[3]\n\npng('bg.png', width = width, height = height)\npar(ask=FALSE)\nprint(ggplot2::qplot(speed, dist, data = cars, geom = c(\"smooth\", \"point\")))\ndev.off()\nbg \u003c- ocv_read('bg.png')\nunlink('pg.png')\nocv_video(function(input){\n  mask \u003c- ocv_mog2(input)\n  return(ocv_copyto(input, bg, mask))\n})\n```\n\nPut your face in the plot:\n\n```r\n# Overlay face filter\nocv_video(function(input){\n  mask \u003c- ocv_facemask(input)\n  ocv_copyto(input, bg, mask)\n})\n```\n\n## Live Face Survey\n\nGo stand on the left if you're a tidier\n\n```r\nlibrary(opencv)\n\n# get webcam size\ntest \u003c- ocv_picture()\nbitmap \u003c- ocv_bitmap(test)\nwidth \u003c- dim(bitmap)[2]\nheight \u003c- dim(bitmap)[3]\n\n# generates the plot\nmakeplot \u003c- function(x){\n  png('bg.png', width = width, height = height, res = 96)\n  on.exit(unlink('bg.png'))\n  groups \u003c- seq(0, width, length.out = 4)\n  left \u003c- rep(\"left\", sum(x \u003c groups[2]))\n  middle \u003c- rep(\"middle\", sum(x \u003e= groups[2] \u0026 x \u003c groups[3]))\n  right \u003c- rep(\"right\", sum(x \u003e= groups[3]))\n  f \u003c- factor(c(left, middle, right), levels = c('left', 'middle', 'right'),\n              labels = c(\"Tidy!\", \"Whatever Works\", \"Base!\"))\n  color = I(c(\"#F1BB7B\", \"#FD6467\", \"#5B1A18\"))\n  plot(f, ylim = c(0, 5),\n       main = \"Are you a tidyer or baser?\", col = color)\n  dev.off()\n  ocv_read('bg.png')\n}\n\n# overlays faces on the plot\nocv_video(function(input){\n  mask \u003c- ocv_facemask(input)\n  faces \u003c- attr(mask, 'faces')\n  bg \u003c- makeplot(faces$x)\n  return(ocv_copyto(input, bg, mask))\n})\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fropensci%2Fopencv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fropensci%2Fopencv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fropensci%2Fopencv/lists"}