Install OpenCV on Windows
The how-to instruction is only valid for Work.AI versions up to 10.3.2. In 10.3.2, Python 3.7 was deprecated.
To install OpenCV version 4.3.0-DEV or later for Windows 10.x, do as follows:
Install Python 3.7.7 or the latest version.
Download the Windows x86-64 executable installer from https://www.python.org/downloads.
On the RPA server, install the package for all users to
C:/Python37.Verify that Python 3.7.7 is installed successfully.
C:\Windows\System32> python --versionLaunch Command Prompt as an Administrator and run the following command to update pip.
C:\Windows\System32> python -m pip install --upgrade pip
Install the latest Visual Studio C++ Build Tools.
- Download the executable installer from https://visualstudio.microsoft.com/visual-cpp-build-tools.
- Install the package with default options selected.
Install the latest Git.
- Download the 64-bit Git for Windows Setup installer from https://git-scm.com/download/win.
- Install the package with the default text editor set as Sublime Text 3 and other default options selected.
Install the latest CMake.
- Download the Windows win64-x64 installer from https://cmake.org/download.
- Install the package with selected default options.
Install the latest Visual Studio Community.
Download the executable installer from https://visualstudio.microsoft.com/downloads.
Install the package with the Desktop Development with the selected C++ option. Optionally, change the grouping name on the second page from 2 to the Visual Studio version (15, 16, and so on).
Launch Command Prompt as an Administrator and run the following command to install NumPy:
C:\Windows\System32> pip install numpyCheck if 4.3.0-DEV is available from https://pypi.org/project/opencv-python and https://pypi.org/project/opencv-contrib-python.
If they are available, launch Command Prompt as an Administrator and run the following two commands to install them:
C:\Windows\System32> pip install opencv-python
C:\Windows\System32> pip install opencv-contrib-pythonIf they are not available, continue to Step 7 to build OpenCV from source.
Launch Command Prompt as an Administrator and run the following commands to download the source code from GitHub.
C:\Windows\System32> mkdir C:\projects && cd C:\projects && mkdir build
C:\Windows\System32> git clone https://github.com/opencv/opencv.git
C:\Windows\System32> git clone https://github.com/opencv/opencv_contrib.gitBegin installing OpenCV from source. Before you begin, refer to this guide.
Set source to C:/projects/opencv.
Set build to C:/projects/build.
Select Grouped and Advanced.
Hit Configure.
Select Visual Studio 16 2019 as the generator.
Select x64 as the platform.
Select Use native default compilers.
Hit Finish.
Set BUILD "BUILD_PERF_TESTS=OFF".
Set BUILD "BUILD_TESTS=OFF".
Set ENABLE "ENABLE_SOLUTION_FOLDERS=OFF".
Set OPENCV "OPENCV_ENABLE_NONFREE=ON".
Set OPENCV "OPENCV_EXTRA_MODULES_PATH=C:/projects/opencv_contrib/modules".
Set OPENCV "OPENCV_PYTHON3_VERSION=ON".
Confirm PYTHON3 "PYTHON3_NUMPY_INCLUDE_DIRS=C:/Python37/lib/site-packages/numpy/core/include".
Hit Generate.
Open C:\projects\build\ALL_BUILD.vcxproj in Visual Studio Community.
Change mode from Debug to Release.
Select Build for ALL_BUILD (takes up to 30 minutes).
Select Build for INSTALL.
Install PIP to set up and manage Python modules:
Launch Command Prompt as an Administrator and run the following command to install Wheel:
C:\Windows\System32> pip install wheelLaunch Command Prompt as an Administrator and run the specified command from https://pytorch.org/get-started/locally (Stable/Windows/Pip/Python/None) to install PyTorch:
C:\Windows\System32> pip install torch==1.5.0+cpu torchvision==0.6.0+cpu -f https://download.pytorch.org/whl/torch_stable.htmlLaunch Command Prompt as an Administrator and run the following commands to install any additional Python modules:
C:\Windows\System32> pip install lxml
C:\Windows\System32> pip install requests
C:\Windows\System32> pip install matplotlib
C:\Windows\System32> pip install tqdm
C:\Windows\System32> pip install boto3
C:\Windows\System32> pip install pandas
To check the OpenCV installation, verify that OpenCV 4.3.0-DEV is installed successfully.
C:\Windows\System32> python
>>> import cv2
>>> print(cv2.__version__)
Python is not pre-installed on RPA servers.