# OpenCv with JupyterLite/Voici?

**URL:** <https://discourse.jupyter.org/t/opencv-with-jupyterlite-voici/19015>\
**Category:** ipynb\
**Created:** [April 18, 2023, 11:21am UTC](https://discourse.jupyter.org/t/opencv-with-jupyterlite-voici/19015 "2023-04-18T11:21:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dfialaire](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/dfialaire/32/4069_2.png) [@dfialaire](https://discourse.jupyter.org/u/dfialaire)\
**Post date:** [April 18, 2023, 11:21am UTC](https://discourse.jupyter.org/t/opencv-with-jupyterlite-voici/19015/1 "2023-04-18T11:21:04Z")

</div>

Hi,

I’m working with Jupyterlite on Github Pages : the Voici version.

For the moment, it is possible to put image on the screen of the application with PIL (pillow) or with Ipywidgets Image : Both work :

[Test\_load\_image](https://peter-fialaire.github.io/Test_image/voici/render/Test_load_image.html)?

But I would like also to use OpenCv : is it possible ?

I modified the build-environment.yml like this :

```auto
…

- pip:

- voici>=0.3.2,<0.4.0

- jupyterlite-xeus-python>=0.8.0,<0.9.0

- numpy==1.23.1

- opencv-contrib-python==4.6.0.66

```

… And so, the build and the deployment were fine.

But when i write : import cv2 : in my jupyter notebook, I have the classic message : ModuleNotFoundError: No module named ‘cv2’

Is it possible to use OpenCv or is it forbidden ?

If it is possible, how can we configure it ?

Thank for your help

---

<div class="post-metadata">

**Author:** ![bollwyvl](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/bollwyvl/32/904_2.png) [@bollwyvl](https://discourse.jupyter.org/u/bollwyvl)\
**Post date:** [April 18, 2023, 12:26pm UTC](https://discourse.jupyter.org/t/opencv-with-jupyterlite-voici/19015/2 "2023-04-18T12:26:38Z")

</div>

If using `jupyterlite-pyodide-kernel`, this seems to work:

```python
%pip install opencv-python
import cv2

```

I’m not sure what would be different with `xeus-python-kernel`, but it’s at least _theoretically_ possible in lite, given sufficiently motivated upstream packaging.

Of course, not everything is going to work the same way. Here’s the [first detection tutorial](https://docs.opencv.org/4.x/dc/d0d/tutorial_py_features_harris.html), with some tweaks: lite doesn’t know what a window is, so using `PIL` to show stuff:

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/jupyter/original/2X/d/da8f6456ff8aaed7a202edd86d595fe6d0a46687.png)

---

<div class="post-metadata">

**Author:** ![dfialaire](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/dfialaire/32/4069_2.png) [@dfialaire](https://discourse.jupyter.org/u/dfialaire)\
**Post date:** [April 18, 2023, 4:32pm UTC](https://discourse.jupyter.org/t/opencv-with-jupyterlite-voici/19015/3 "2023-04-18T16:32:00Z")

</div>

Thank You a lot Bollwyvl,

You are right, OpenCv work in Jupyterlite :

I did this work :  
[https://dfialaire.github.io/Formation-NSI-\_-Presentation-Jupyterlite/lab/index.html](https://dfialaire.github.io/Formation-NSI-_-Presentation-Jupyterlite/lab/index.html)  
… where I open and transform an image with OpenCv in Jupyterlite…

But when I tried videocapture from OpenCv, it didn’t worked… whereas CameraStream from Ipywebrtc worked nearly perfectly…

I have a script wich work localy on my computer to construct a Harry potter invisibility ( [https://biotech-online.pagesperso-orange.fr/Cape/Cape\_invisibilit%C3%A9\_HTML.html](https://biotech-online.pagesperso-orange.fr/Cape/Cape_invisibilit%C3%A9_HTML.html) ) … it needed to get and transfrom a frame from a videocapture at every frame of the stream… but it seems complex to do it from a server…

Do you have an idea why videocapture from opencv doesn’t work ?  
Thanks.

---

<div class="post-metadata">

**Author:** ![bollwyvl](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/bollwyvl/32/904_2.png) [@bollwyvl](https://discourse.jupyter.org/u/bollwyvl)\
**Post date:** [April 18, 2023, 7:01pm UTC](https://discourse.jupyter.org/t/opencv-with-jupyterlite-voici/19015/4 "2023-04-18T19:01:37Z")

</div>

> videocapture from OpenCv

Much like with the window: what’s a camera? The whole “computer” is just a pile of JS, and a whole lot of things are missing: devices, threads, processes. Perhaps `PIL` or something could be used to convert the `CameraStream` frame by frame.
