OpenCV.jl is a Julia interface to the OpenCV computer-vision
library โ image and video processing, object detection, feature extraction,
calibration, and more โ backed by the precompiled library through OpenCV_jll.
๐ Documentation โ a quick-start example,
the Mat image type and its (channels, cols, rows) layout, the cv:: โ OpenCV.
naming convention, reading/writing images, and the API reference.
] add OpenCVThis installs the package and the precompiled OpenCV binaries; no system OpenCV is required.
On Linux with an NVIDIA GPU and a CUDA 13 driver, OpenCV can use binaries built with CUDA
and cuDNN, which enable the DNN_BACKEND_CUDA backend for cv.dnn. Install them next to
OpenCV and restart Julia:
] add OpenCV_CUDA_jllOpenCV then loads the CUDA build whenever it has binaries for the system, and falls back to
the CPU build otherwise. Remove OpenCV_CUDA_jll to go back to the CPU build. It is a separate
package because installing it downloads the CUDA runtime and cuDNN (about 2 GB).
OpenCV finds OpenCV_CUDA_jll in any environment on the load path, so installing it in the
default environment (@v1.x) enables the CUDA build for every project. OpenCV ignores it, with a
warning, if its OpenCV version differs from that of OpenCV_jll.
To hack on OpenCV.jl, check out the repository and dev it from Julia:
pkg> dev /path/to/OpenCV.jl # or: pkg> dev OpenCV
pkg> test OpenCV
using OpenCV pulls in a matching OpenCV_jll automatically. Changes under src/ are
picked up on the next using (or immediately with Revise). Changes under gen/ take
effect only after regenerating the wrappers; rebuilding OpenCV_jll is needed only when
the underlying OpenCV version changes.
Contributions are welcome โ please open issues and PRs. The codebase has three layers:
- Hand-written Julia in
src/โ the module entry (OpenCV.jl), theMat/Vecarray types, the cppโjulia conversions (mat_conversion.jl,types_conversion.jl), the geometry structs (typestructs.jl),errors.jl,show.jl,fileio.jl, and thevideoio.jlconveniences. Edit these for the Julia-side API and array interop. - Auto-generated wrappers in
src/generated/โ produced by the generator undergen/. Do not hand-edit these. Regenerate withjulia gen/regenerate.jl; seegen/PROVENANCE.mdfor the determinism guarantees and the OpenCV-bump checklist.cv_cxx_wrap.jlends with a hand-authored "Manual Wrapping" section (GUI callbacks,CascadeClassifier) that the header parser cannot derive; its source isgen/binding_templates_jl/manual_cxx.jl, paired with the C++ side ingen/binding_templates_cpp/cv_core.cpp. - The binding generator in
gen/โ vendored fromopencv_contrib/modules/juliawith JuliaImages patches folded in. Edits here changesrc/generated/on the next regeneration.
The compiled libopencv_julia lives in OpenCV_jll, built from Yggdrasil's
O/OpenCV/build_tarballs.jl;
it must come from the same OpenCV tag pinned in gen/OPENCV_VERSION, or @wrapmodule
fails on mismatched symbols.
MIT โ see LICENSE.
OpenCV.jl is built on the work of the OpenCV community. @archit120 was instrumental in developing this package during GSoC 2020 and 2021.