I'm using a docker container with minimal packages installed. I installed opencv-contrib-python
using pip3 install opencv-contrib-python
and it installed the latest build 4.1.025
and have verified that it was running and my program was ok with it. However, now I need the freetype
module but when I try:
import cv2 as cv
ft = cv.freetype.createFreeType2()
It throws the AttributeError
as in the title. I tried reinstalling different versions namely: 4.0.0.21, 4.0.1.23, 4.0.1.24, 4.1.0.25
to no avail. I am using the headless version mainly(since I'm using docker and I don't need any gui functionality). Another thing I found out was not all the modules can be imported I have tried (ccalib, tracking, sfm, xobjdetect etc) and these modules throw the same error. Does this mean that some modules are not available through the pip3
installation? Thank you.
I'm pretty late to this issue, but I hope this helps someone.
I've added links to an easy to follow guide at the bottom.
Here are the essential steps, you'd need to follow:
bootstrap-vcpkg.bat
vcpkg install freetype:x64-windows
vcpkg install harfbuzz:x64-windows
cmake -G "Visual Studio 16 2019"
-B D:\code\downloads\opencv-4.3.0\build
-D BUILD_NEW_PYTHON_SUPPORT=ON
-D BUILD_PYTHON_SUPPORT=ON
-D BUILD_opencv_python3=yes
-D PYTHON_DEFAULT_EXECUTABLE=D:\anaconda3\python.exe
-D OPENCV_SKIP_PYTHON_LOADER=ON
-D PYTHON_LIBRARY=D:\anaconda3\libs\python36.lib
-D OPENCV_EXTRA_MODULES_PATH=D:\code\downloads\opencv_contrib-4.3.0\modules
-D OPEN_CV_FORCE_PYTHON_LIBS=yes
-D CMAKE_TOOLCHAIN_FILE=D:\code\downloads\vcpkg\scripts\buildsystems\vcpkg.cmake
There's a comprehensive written guide over here:
Also, I've made a video inspired by the same tutorial, which can be found here:
I would recommend watching the video and keeping this guide open on the side.
Cheers!