Skip to content

3. Installing OpenCV

Alexander Kleemann edited this page Feb 11, 2021 · 1 revision

Introduction

OpenCV (Open Source Computer Vision Library) is a cross-platform library of programming functions for a wide variety of purposes ranging from facial recognition and augmented reality to 2D toolkits and deep neural networks. We will be utilizing the two latter in order to improve your lightmaps.

It is available in a lot of different programming langugaes, but we will be interfacing with it from Blender, thus use Python. You will of course not have to code anything yourself - All you have to do is install it to gain access to the following lightmapping features:

  • Filtering (Mainly blurring, including Box, Median, Bilateral and Gaussian)
  • Image upscale
  • Image downscale
  • More features are planned

Installation

There are 2 ways to install OpenCV - An automatic and a manual way. Generally it is recommended to use the automatic installer from the Blender preferences menu. The manual way is meant as a secondary method in case something goes wrong or isn't working.

Automatic:

  • Start your Blender session as an administrator (or the Sudo equivalent in Linux, Mac), this is necessary as OpenCV needs to be installed as as package alongside your bundled Python package in Blender.
  • Go to Edit > Preferences > Add-ons to open up the Blender preferences menu with the Add-On submenu: Image here
  • Find The Lightmapper on the list
  • Scroll down to where it says OpenCV and click Install OpenCV
  • Restart Blender and you'll now be good to go!

Manual:

  • Start your command-line (cmd.exe on win), terminal on Linux (and mac?) as an administrator
  • Go to your Blender/version/python/bin directory
  • Run the following command (without .exe if you're not on windows): python.exe -m pip install opencv-python
  • NB! If you get an error with PIP, try running this command first (without .exe if you're not on windows): python.exe -m ensurepip --upgrade --user
  • Don't worry if something shows up red, as long as you get a message saying OpenCV was installed at the end.
  • If you still get an error, feel free to open up a ticket