# What is best practice for adding OpenCV as a dependency in a Julia Package?

**URL:** <https://discourse.julialang.org/t/what-is-best-practice-for-adding-opencv-as-a-dependency-in-a-julia-package/53990>\
**Category:** Visualization\
**Tags:** package, package-manager, binarybuilder\
**Created:** [January 26, 2021, 3:26pm UTC](https://discourse.julialang.org/t/what-is-best-practice-for-adding-opencv-as-a-dependency-in-a-julia-package/53990 "2021-01-26T15:26:45Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Erik\_Engheim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/erik_engheim/32/8122_2.png) [@Erik\_Engheim](https://discourse.julialang.org/u/Erik_Engheim)\
**Post date:** [January 26, 2021, 3:26pm UTC](https://discourse.julialang.org/t/what-is-best-practice-for-adding-opencv-as-a-dependency-in-a-julia-package/53990/1 "2021-01-26T15:26:45Z")

</div>

I went through the [recipe online](https://docs.opencv.org/master/d8/da4/tutorial_julia.html) for building the Julia OpenCV bindings. It is all based on [CxxWrap](https://github.com/JuliaInterop/CxxWrap.jl) to automatically create the bindings. So I get something locally installed, but I cannot add OpenCV as a dependency to my packages:

```julia
pkg> add OpenCV
ERROR: The following package names could not be resolved:
* OpenCV (not found in project, manifest or registry)

```

Does anyone have any advice on how to best proceed? I could add a local path I suppose, but I cooperate with somebody else on this repo. I have contemplated looking into making a local registry, or exploring BinaryBuilder to see if I could wrap this up in a more proper Julia package that can be put on a GitHub repo. But I am thinking I cannot be the first one with this problem. What do other people using OpenCV in Julia currently do?

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [January 26, 2021, 3:40pm UTC](https://discourse.julialang.org/t/what-is-best-practice-for-adding-opencv-as-a-dependency-in-a-julia-package/53990/2 "2021-01-26T15:40:12Z")

</div>

> [@Erik\_Engheim](#):
>
> But I am thinking I cannot be the first one with this problem.

Yeah, all people that tried to build OpenCV with BinaryBuilder gave up. Seems to be complicated, as far as I understand, or maybe it needs too many dependencies not yet packaged?

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [January 26, 2021, 3:40pm UTC](https://discourse.julialang.org/t/what-is-best-practice-for-adding-opencv-as-a-dependency-in-a-julia-package/53990/3 "2021-01-26T15:40:40Z")

</div>

Before you continue with the OpenCV attempt, just wanted to double check that you are aware of Images.jl? Is there a specific functionality from OpenCV that is not yet available in Images.jl?

---

<div class="post-metadata">

**Author:** ![Erik\_Engheim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/erik_engheim/32/8122_2.png) [@Erik\_Engheim](https://discourse.julialang.org/u/Erik_Engheim)\
**Post date:** [January 26, 2021, 3:49pm UTC](https://discourse.julialang.org/t/what-is-best-practice-for-adding-opencv-as-a-dependency-in-a-julia-package/53990/4 "2021-01-26T15:49:31Z")

</div>

I don’t know well what is in Images. It seems very generic what I have seen thus far. I specifically want to do stereo matching. OpenCV has this StereoBM class for that. First step is to compute a disparity map, which means taking two images of the same scene and finding how much the features are shifted left or right. This can then be later used to create a depth map.

If Images.jl can already do something like this, then I would be thrilled. Could you point me in the right direction? I am new to this domain, so it is not obvious to me what functions in Images.jl I may use for this.

---

<div class="post-metadata">

**Author:** ![Erik\_Engheim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/erik_engheim/32/8122_2.png) [@Erik\_Engheim](https://discourse.julialang.org/u/Erik_Engheim)\
**Post date:** [January 26, 2021, 3:52pm UTC](https://discourse.julialang.org/t/what-is-best-practice-for-adding-opencv-as-a-dependency-in-a-julia-package/53990/5 "2021-01-26T15:52:16Z")

</div>

Thanks, that potentially saved me a ton of wasted time. What would be best then? Just putting it all in a Docker container or something?

Also contemplate, maybe wrapping whatever I need in OpenCV in a C API as that is easy to call from Julia. But I guess that doesn’t help on the challenge of compiling OpenCV through Julia.

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [January 26, 2021, 4:01pm UTC](https://discourse.julialang.org/t/what-is-best-practice-for-adding-opencv-as-a-dependency-in-a-julia-package/53990/6 "2021-01-26T16:01:42Z")

</div>

Unfortunately I am super busy here, but try to take a look at the JuliaImages organization, and try to contact the active maintainers in Zulip for example.

[https://github.com/JuliaImages](https://github.com/JuliaImages)

---

<div class="post-metadata">

**Author:** ![Erik\_Engheim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/erik_engheim/32/8122_2.png) [@Erik\_Engheim](https://discourse.julialang.org/u/Erik_Engheim)\
**Post date:** [January 26, 2021, 4:08pm UTC](https://discourse.julialang.org/t/what-is-best-practice-for-adding-opencv-as-a-dependency-in-a-julia-package/53990/7 "2021-01-26T16:08:01Z")

</div>

Thanks for the help!

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [January 26, 2021, 4:11pm UTC](https://discourse.julialang.org/t/what-is-best-practice-for-adding-opencv-as-a-dependency-in-a-julia-package/53990/8 "2021-01-26T16:11:05Z")

</div>

In case someone wants to try again, [this PR](https://github.com/JuliaPackaging/Yggdrasil/pull/1497) might be a good starting point. Most platforms were actually successful
