module 'cv2.cv2' has no attribute 'freetype'
ArduinoBen opened this issue · 3 comments
Been having trouble getting qbr running for the past week or so, long story short, now running it in a Linux Mint VM and thought I'd ask for some help.
The issue I am now stuck on is "module 'cv2.cv2' has no attribute 'freetype'" when I run "python3 qbr.py".
I have done a lot of testing and am able to access my webcam through opencv from another script I wrote. I am also fairly positive that I have all the dependencies properly installed.
The full output is as follows:
(env) ben@ben-VirtualBox:~/qbr-2/qbr/src$ python3 qbr.py
Traceback (most recent call last):
File "qbr.py", line 84, in
Qbr(args.normalize).run()
File "qbr.py", line 40, in run
state = webcam.run()
File "/home/ben/qbr-2/qbr/src/video.py", line 504, in run
self.draw_current_language(frame)
File "/home/ben/qbr-2/qbr/src/video.py", line 343, in draw_current_language
(textsize_width, textsize_height), _ = self.get_text_size(text)
File "/home/ben/qbr-2/qbr/src/video.py", line 276, in get_text_size
ft2 = self.get_freetype2_font()
File "/home/ben/qbr-2/qbr/src/video.py", line 263, in get_freetype2_font
ft2 = cv2.freetype.createFreeType2()
AttributeError: module 'cv2.cv2' has no attribute 'freetype'
Thanks for any help.
Make sure you run pip3 install opencv-python
and then pip3 install opencv-contrib-python
. The order here is important. Closing this, because this is not related to the project.
Sorry, same issue :(
Have I installed the correct versions? See below:
opencv-python:
Requirement already satisfied: opencv-python in ./env/lib/python3.8/site-packages (4.5.1.48)
Requirement already satisfied: numpy>=1.17.3 in ./env/lib/python3.8/site-packages (from opencv-python) (1.20.1)
opencv-contrib-python:
Requirement already satisfied: opencv-contrib-python in ./env/lib/python3.8/site-packages (4.5.1.48)
Requirement already satisfied: numpy>=1.17.3 in ./env/lib/python3.8/site-packages (from opencv-contrib-python) (1.20.1)
Hi. I just released a new version which uses pillow to draw the text and have completely removed the opencv-contrib-python dependency. Reinstall the dependencies with pip3 install -r requirements.txt
and then run ./src/qbr.py
should be working without the error that freetype
doesn't exists.