# OpenCV.jl: OpenCV's Julia Bindings

**URL:** <https://discourse.julialang.org/t/opencv-jl-opencvs-julia-bindings/99853>\
**Category:** Package Announcements\
**Tags:** image-processing, juliaimages\
**Created:** [June 4, 2023, 3:58pm UTC](https://discourse.julialang.org/t/opencv-jl-opencvs-julia-bindings/99853 "2023-06-04T15:58:42Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ashwani\_Rathee](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ashwani_rathee/32/49551_2.png) [@Ashwani\_Rathee](https://discourse.julialang.org/u/Ashwani_Rathee)\
**Post date:** [June 4, 2023, 3:58pm UTC](https://discourse.julialang.org/t/opencv-jl-opencvs-julia-bindings/99853/1 "2023-06-04T15:58:42Z")

</div>

# [OpenCV.jl](https://github.com/JuliaImages/OpenCV.jl)

* * *

**OpenCV.jl** is a Julia package that provides an interface to the popular computer vision library OpenCV. It allows Julia users to leverage the extensive functionalities and algorithms offered by OpenCV for various computer vision tasks, such as image and video processing, object detection, feature extraction, and more.

#### Example:

```julia-auto
using ImageCore, OpenCV, TestImages, MosaicViews

img_orig = testimage("Mandrill")

img_raw = collect(rawview(channelview(img_orig)))

img_gray = OpenCV.cvtColor(img_raw, OpenCV.COLOR_RGB2GRAY)

img_blur = OpenCV.blur(img_gray, OpenCV.Size(Int32(9), Int32(9)))

img_back = colorview(Gray, float.(img_blur)./255)[1,:,:]

mosaic(img_orig, img_back; nrow=1)

```

#### Output:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/3/0/3084cab3fb61eb0b4a2322c17889cc1c3cfb833c.jpeg)

#### Relevant Details:

- List of wrapped methods is available here: [wrapped methods](https://github.com/opencv/opencv_contrib/blob/4.x/modules/julia/gen/funclist.csv)
- Repository: [https://github.com/JuliaImages/OpenCV.jl](https://github.com/JuliaImages/OpenCV.jl)
- Documentation: [OpenCV.jl · OpenCV.jl](https://juliaimages.org/OpenCV.jl/dev/)

We welcome new contributors to help improve the package and performance of existing solutions.

---

<div class="post-metadata">

**Author:** ![Ashwani\_Rathee](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ashwani_rathee/32/49551_2.png) [@Ashwani\_Rathee](https://discourse.julialang.org/u/Ashwani_Rathee)\
**Post date:** [June 4, 2023, 4:04pm UTC](https://discourse.julialang.org/t/opencv-jl-opencvs-julia-bindings/99853/2 "2023-06-04T16:04:22Z")

</div>

## OpenCV.jl 4.5.3 is out

- It should work on Julia 1.9 and is now being maintained in JuliaImages after Archit Rungta joined JuliaImages some days back.
- Currently in maintenance mode given limited contributors. In list of wrapped methods mentioned above if any user finds a specific usecase/methods in OpenCV.jl which other packages in JuliaImages don’t solve and you really need it, do let us know(here, on slack(# image-processing) or zulip(# image-processing). Then we can collabratively work on providing those in a more streamlined way.

---

<div class="post-metadata">

**Author:** ![Kampuny11](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kampuny11/32/18985_2.png) [@Kampuny11](https://discourse.julialang.org/u/Kampuny11)\
**Post date:** [February 14, 2024, 5:33am UTC](https://discourse.julialang.org/t/opencv-jl-opencvs-julia-bindings/99853/3 "2024-02-14T05:33:26Z")

</div>

I tried to install OpenCV.jl version 1.10, but it didn’t work. Is there any reason for that or is it just because it’s still in release? It’s only working on version 1.6, which is the LTS. I wanted to take advantage of the performance of version 1.10, which is extremely good. Is there any way to make it work?

---

<div class="post-metadata">

**Author:** ![roflmaostc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/roflmaostc/32/30123_2.png) [@roflmaostc](https://discourse.julialang.org/u/roflmaostc)\
**Post date:** [February 14, 2024, 10:02am UTC](https://discourse.julialang.org/t/opencv-jl-opencvs-julia-bindings/99853/4 "2024-02-14T10:02:01Z")

</div>

Someone could run it on [1.9, see that GitHub issue.](https://github.com/JuliaImages/OpenCV.jl/issues/36)

---

<div class="post-metadata">

**Author:** ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)\
**Post date:** [February 14, 2024, 10:58am UTC](https://discourse.julialang.org/t/opencv-jl-opencvs-julia-bindings/99853/5 "2024-02-14T10:58:47Z")

</div>

It seems this is needed:  
CxxWrap = “0.11, 0.12, 0.13, 0.14”

I tried that, though not enough:

```julia
(@v1.10) pkg> dev OpenCV

shell> vi /home/pharaldsson/.julia/dev/OpenCV/Project.toml

```

```julia
ERROR: LoadError: InitError: could not load library "/home/pharaldsson/.julia/artifacts/d454559ec7ae7732c2a6191fad8f40f16fdd75c8/lib/libopencv_julia.so"
/home/pharaldsson/.julia/artifacts/d454559ec7ae7732c2a6191fad8f40f16fdd75c8/lib/libopencv_julia.so: undefined symbol: small_typeof, version JL_LIBJULIA_1.10

```

i.e. similar change to:

> <https://github.com/ahumenberger/Z3.jl/pull/27/files>
>
> In particular, \`CxxWrap\` needs to be upgraded to be compatible with Julia 1.10 (…see https://github.com/JuliaInterop/CxxWrap.jl/issues/379). Fixes #26

> <https://github.com/JuliaInterop/CxxWrap.jl/issues/379#issuecomment-1746787291>
>
> \`\`\`
> Failed to precompile CxxWrap \[1f15a43c-97ca-5a2a-ae31-89f07a497df4\] to "/ho…me/wuli/.julia/compiled/v1.10/CxxWrap/jl\_tafPdI".
> ERROR: LoadError: InitError: could not load library "/home/wuli/.julia/artifacts/0804d06469cf9f602bc65f9db473c23d07a90039/lib/libcxxwrap\_julia.so"
> /home/wuli/.julia/artifacts/0804d06469cf9f602bc65f9db473c23d07a90039/lib/libcxxwrap\_julia.so: undefined symbol: small\_typeof, version JL\_LIBJULIA\_1.10
> \`\`\`

> <https://github.com/JuliaLang/julia/issues/50714>
>
> If I try to compile code on Windows that uses \`jl\_typeof\` compilation fails beca…use \`small\_typeof\` can't be resolved.
> 
> Reproducer:
> 
> \`\`\`C
> \#include \<julia.h\>
> 
> int main(int argc, char\* argv\[\])
> {
> jl\_init();
> jl\_value\_t \*v = jl\_eval\_string("print(sqrt(2.0))");
> jl\_value\_t \*t = jl\_typeof(v);
> jl\_atexit\_hook(0);
> return 0;
> }
> \`\`\`

---

<div class="post-metadata">

**Author:** ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)\
**Post date:** [February 14, 2024, 11:25am UTC](https://discourse.julialang.org/t/opencv-jl-opencvs-julia-bindings/99853/6 "2024-02-14T11:25:40Z")

</div>

This one might be relevant:

```julia
(@v1.11) pkg> add libcxxwrap_julia_jll@v0.12
   Resolving package versions...
ERROR: Unsatisfiable requirements detected for package CxxWrap [1f15a43c]:
 CxxWrap [1f15a43c] log:
 ├─possible versions are: 0.7.0 - 0.14.2 or uninstalled
 ├─restricted by compatibility requirements with libcxxwrap_julia_jll [3eaa8342] to versions: 0.7.0 - 0.9.1 or uninstalled
 │ └─libcxxwrap_julia_jll [3eaa8342] log:
 │ ├─possible versions are: 0.6.5 - 0.12.0 or uninstalled
 │ └─restricted to versions 0.12 by an explicit requirement, leaving only versions: 0.12.0
 └─restricted by compatibility requirements with OpenCV [f878e3a2] to versions: 0.11.0 - 0.13.4 — no versions left
   └─OpenCV [f878e3a2] log:
     ├─possible versions are: 4.5.2 - 4.5.3 or uninstalled
     └─restricted to versions * by an explicit requirement, leaving only versions: 4.5.2 - 4.5.3

```

I thought 1.11 might maybe work even if 1.10 didn’t:

```julia
$ juliaup add nightly
Installing Julia latest-linux-x86_64

julia> [Info: Precompiling REPLExt [e5eb5ef1-03cf-53a7-ae1d-5a66b08e832b] (cache misses: mismatched flags (2), dep uuid changed (2))

(@v1.11) pkg> add OpenCV_jll

and note I get different errors before and after this:

(@v1.11) pkg> up
    Updating registry at `~/.julia/registries/General.toml`
    Updating `~/.julia/environments/v1.11/Project.toml`
  [33b9d88c] ↑ OpenCV_jll v4.6.0+1 ⇒ v4.6.0+2

old error, probably not to worry about:

Precompiling OpenCV
        Info Given OpenCV was explicitly requested, output will be shown live 
ERROR: LoadError: UndefVarError: `artifact_dir` not defined in `OpenCV_jll`

```

> [@Kampuny11](#):
>
> I tried to install [OpenCV.jl](https://juliahub.com/ui/Packages/OpenCV) version 1.10, but it didn’t work. Is there any reason for that or is it just because it’s still in release?

OpenCV.jl isn’t my package, just trying to explain. If there had not been a problem elsewhere; in Julia, then the package would have worked.

It doesn’t _directly_ depend on anything in Julia not guaranteed stable (while it does indirectly), but it relies on CxxWrap to call [OpenCV] C++ code, and Julia changed breaking CxxWrap.jl.

@Ashwani_Rathee It’s unfortunate that CxxWrap breaks. When it is “fixed”, seemingly all its dependants, e.g. OpenCV.jl, need to update its compatibility.

@barche, I see there’s also [pybind11\_jll](https://juliahub.com/ui/Packages/General/pybind11_jll) that could have been used… but we don’t want to need to avoid your package (calling Python is stable, and will be, and apparently pybind11 is stable, and well documented, so also stable to call C++ that way indirectly even though a bit ugly to have to rely on Python for that…). I know the problem is Julia doesn’t keep stable for you (calling from Python to Julia also broke with 1.10.1, though not in the other direction), or you used something not promised to be stable, so do you know if that’s about to change? Was it the last thing Julia broke, unlikely to be more, or guaranteed, or no end in sight?

---

<div class="post-metadata">

**Author:** ![barche](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/barche/32/79_2.png) [@barche](https://discourse.julialang.org/u/barche)\
**Post date:** [February 17, 2024, 6:18pm UTC](https://discourse.julialang.org/t/opencv-jl-opencvs-julia-bindings/99853/7 "2024-02-17T18:18:29Z")

</div>

I think the problem is that OpenCV\_jll is compiled against libcxxwrap\_julia 0.10 or older. These older versions don’t support Julia 1.10 yet, so the correct solution would be to rebuild OpenCV\_jll against libcxxwrap\_julia 0.11 and set a compat bound. Version 0.12 of libcxxwrap\_julia is not yet ready for use, but it also should not be pulled in automatically if compat is set correctly.

---

<div class="post-metadata">

**Author:** ![Kampuny11](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kampuny11/32/18985_2.png) [@Kampuny11](https://discourse.julialang.org/u/Kampuny11)\
**Post date:** [February 25, 2024, 2:42am UTC](https://discourse.julialang.org/t/opencv-jl-opencvs-julia-bindings/99853/8 "2024-02-25T02:42:05Z")

</div>

Did OpenCV.jl does not wrap Feature Matching methods, like SURF, SIFT, ORB?

---

<div class="post-metadata">

**Author:** ![Marco\_Antoniotti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marco_antoniotti/32/18697_2.png) [@Marco\_Antoniotti](https://discourse.julialang.org/u/Marco_Antoniotti)\
**Post date:** [May 24, 2024, 9:55am UTC](https://discourse.julialang.org/t/opencv-jl-opencvs-julia-bindings/99853/9 "2024-05-24T09:55:27Z")

</div>

Hi

we are hitting that (or similar) problem with CxxWrap. In May 2024.

Do you have any pointers about solving it?

Thanks

Marco

---

<div class="post-metadata">

**Author:** ![barche](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/barche/32/79_2.png) [@barche](https://discourse.julialang.org/u/barche)\
**Post date:** [May 24, 2024, 3:41pm UTC](https://discourse.julialang.org/t/opencv-jl-opencvs-julia-bindings/99853/10 "2024-05-24T15:41:21Z")

</div>

Hi Marco,

The problem is that OpenCV\_jll.jl hasn’t been built against a libcxxwrap\_julia that supports Julia 1.10. To do this, the [build file](https://github.com/JuliaPackaging/Yggdrasil/blob/master/O/OpenCV/build_tarballs.jl) needs to be updated with a PR to Yggdrasil. Easiest would be to build against libcxxwrap\_julia version 0.11, and then also update the OpenCV.jl Project.toml to add the CxxWrap 0.14 compat. If you are looking to do this, feel free to tag me in the Yggdrasil PR, I can help.

---

<div class="post-metadata">

**Author:** ![Marco\_Antoniotti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marco_antoniotti/32/18697_2.png) [@Marco\_Antoniotti](https://discourse.julialang.org/u/Marco_Antoniotti)\
**Post date:** [May 29, 2024, 9:18pm UTC](https://discourse.julialang.org/t/opencv-jl-opencvs-julia-bindings/99853/11 "2024-05-29T21:18:15Z")

</div>

Hi,

sorry but I am a bit at a loss here…

What exactly is a PR (a “pull request”?) to Yggdrasil?

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [May 29, 2024, 10:23pm UTC](https://discourse.julialang.org/t/opencv-jl-opencvs-julia-bindings/99853/12 "2024-05-29T22:23:54Z")

</div>

It means one of two things.

1. You pray to the Norse gods to pull you up to the world tree.
2. You go to Github, navigate to the following Github repository, and you suggest a change:  
[GitHub - JuliaPackaging/Yggdrasil: Collection of builder repositories for BinaryBuilder.jl](https://github.com/JuliaPackaging/Yggdrasil)

Sometimes these are one and the same, except that that the Norse god you encounter is a helpful Italian fellow who lives in London.

---

<div class="post-metadata">

**Author:** ![Marco\_Antoniotti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marco_antoniotti/32/18697_2.png) [@Marco\_Antoniotti](https://discourse.julialang.org/u/Marco_Antoniotti)\
**Post date:** [May 30, 2024, 7:51pm UTC](https://discourse.julialang.org/t/opencv-jl-opencvs-julia-bindings/99853/13 "2024-05-30T19:51:59Z")

</div>

I understand… and we do have a PR ready (hopefully).

Just curious why no PR was produced yet, as this issue seems to have appeared some time ago.

---

<div class="post-metadata">

**Author:** ![cdsousa](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cdsousa/32/215553_2.png) [@cdsousa](https://discourse.julialang.org/u/cdsousa)\
**Post date:** [May 31, 2024, 1:28pm UTC](https://discourse.julialang.org/t/opencv-jl-opencvs-julia-bindings/99853/14 "2024-05-31T13:28:31Z")

</div>

> [@Marco\_Antoniotti](#):
>
> and we do have a PR ready (hopefully).
> 
> Just curious why no PR was produced yet, as this issue seems to have appeared some time ago

Related: [Add comment to OpenCV to force rebuild by cdsousa · Pull Request #7941 · JuliaPackaging/Yggdrasil · GitHub](https://github.com/JuliaPackaging/Yggdrasil/pull/7941)  
(after that I just gave up)

---

<div class="post-metadata">

**Author:** ![Marco\_Antoniotti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marco_antoniotti/32/18697_2.png) [@Marco\_Antoniotti](https://discourse.julialang.org/u/Marco_Antoniotti)\
**Post date:** [May 31, 2024, 3:33pm UTC](https://discourse.julialang.org/t/opencv-jl-opencvs-julia-bindings/99853/15 "2024-05-31T15:33:34Z")

</div>

Thank you @cdsousa  
Things do not seem easy. At all.

---

<div class="post-metadata">

**Author:** ![viralbshah](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/viralbshah/32/54_2.png) [@viralbshah](https://discourse.julialang.org/u/viralbshah)\
**Post date:** [November 1, 2024, 6:27pm UTC](https://discourse.julialang.org/t/opencv-jl-opencvs-julia-bindings/99853/16 "2024-11-01T18:27:31Z")

</div>

Thanks to @barche OpenCV.jl is now updated to the latest opencv release (4.10) in BB, and works with Julia 1.10 and 1.11.

The package probably should be set up so that the wrappers are in the OpenCV.jl repo as discussed in [Organization of the source code for the wrappers · Issue #49 · JuliaImages/OpenCV.jl · GitHub](https://github.com/JuliaImages/OpenCV.jl/issues/49)
