hand_asl_recognition icon indicating copy to clipboard operation
hand_asl_recognition copied to clipboard

module 'cv2.cv2' has no attribute 'freetype'

Open rsangole opened this issue 4 years ago • 6 comments
trafficstars

Hello,

Having tried the example, I get this error:

(opencv) ~/g/hand_asl_recognition ❯❯❯ python3 hand_tracker_asl.py                                        main ✱ ◼
896 anchors have been created
Traceback (most recent call last):
  File "hand_tracker_asl.py", line 426, in <module>
    ht = HandTrackerASL(pd_path=args.pd_m, lm_path=args.lm_m, asl_path=args.asl_m, asl_recognition=args.asl)
  File "hand_tracker_asl.py", line 78, in __init__
    self.ft = cv2.freetype.createFreeType2()
AttributeError: module 'cv2.cv2' has no attribute 'freetype'

My system:

Conda

# packages in environment at /home/rahul/miniconda3/envs/opencv:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                 conda_forge    conda-forge
_openmp_mutex             4.5                       1_gnu    conda-forge
bzip2                     1.0.8                h7f98852_4    conda-forge
ca-certificates           2021.10.8            ha878542_0    conda-forge
ld_impl_linux-64          2.36.1               hea4e1c9_2    conda-forge
libffi                    3.4.2                h7f98852_5    conda-forge
libgcc-ng                 11.2.0              h1d223b6_11    conda-forge
libgomp                   11.2.0              h1d223b6_11    conda-forge
libnsl                    2.0.0                h7f98852_0    conda-forge
libuuid                   2.32.1            h7f98852_1000    conda-forge
libzlib                   1.2.11            h36c2ea0_1013    conda-forge
ncurses                   6.2                  h58526e2_4    conda-forge
openssl                   3.0.0                h7f98852_2    conda-forge
pip                       21.3.1             pyhd8ed1ab_0    conda-forge
python                    3.10.0          h543edf9_3_cpython    conda-forge
python_abi                3.10                    2_cp310    conda-forge
readline                  8.1                  h46c0cb4_0    conda-forge
setuptools                59.2.0                   pypi_0    pypi
sqlite                    3.36.0               h9cd32fc_2    conda-forge
tk                        8.6.11               h27826a3_1    conda-forge
tzdata                    2021e                he74cb21_0    conda-forge
wheel                     0.37.0             pyhd8ed1ab_1    conda-forge
xz                        5.2.5                h516909a_1    conda-forge
zlib                      1.2.11            h36c2ea0_1013    conda-forge

pip

Package                Version                                                Editable project location
---------------------- ------------------------------------------------------ ------------------------------------------
argcomplete            1.12.3
argon2-cffi            21.1.0
asn1crypto             1.3.0
attrs                  21.2.0
backcall               0.2.0
bleach                 4.1.0
blobconverter          1.2.7
boto3                  1.17.39
botocore               1.20.112
certifi                2019.11.28
cffi                   1.14.0
chardet                3.0.4
conda                  4.8.3
conda-package-handling 1.6.0
cryptography           2.8
cycler                 0.11.0
debugpy                1.5.1
decorator              5.1.0
defusedxml             0.7.1
depthai                2.11.1.0.dev0+dfd52ac01c3b7514e85cb894b9d5381e999859df
depthai-sdk            1.1.3                                                  /home/rahul/github/depthai/depthai_sdk/src
entrypoints            0.3
ffmpy3                 0.2.4
fonttools              4.28.1
idna                   2.9
importlib-metadata     2.1.2
importlib-resources    5.4.0
ipykernel              6.5.1
ipython                7.29.0
ipython-genutils       0.2.0
ipywidgets             7.6.5
jedi                   0.18.1
Jinja2                 3.0.3
jmespath               0.10.0
jsonschema             4.2.1
jupyter-client         7.0.6
jupyter-core           4.9.1
jupyterlab-pygments    0.1.2
jupyterlab-widgets     1.0.2
kaggle                 1.5.12
kiwisolver             1.3.2
MarkupSafe             2.0.1
matplotlib             3.5.0
matplotlib-inline      0.1.3
mistune                0.8.4
nbclient               0.5.9
nbconvert              6.3.0
nbformat               5.1.3
nest-asyncio           1.5.1
notebook               6.4.6
numpy                  1.21.4
open3d                 0.10.0.0
opencv-contrib-python  4.1.0.25
opencv-python          4.5.1.48
packaging              21.3
pandocfilters          1.5.0
parso                  0.8.2
pexpect                4.8.0
pickleshare            0.7.5
Pillow                 8.4.0
pip                    21.3.1
prometheus-client      0.12.0
prompt-toolkit         3.0.22
ptyprocess             0.7.0
py3status              3.27
pycosat                0.6.3
pycparser              2.20
Pygments               2.10.0
pyOpenSSL              19.1.0
pyparsing              3.0.6
pyrsistent             0.18.0
PySide6                6.2.0
PySocks                1.7.1
python-dateutil        2.8.2
python-slugify         5.0.2
pytube                 11.0.1
PyYAML                 6.0
pyzmq                  22.3.0
requests               2.24.0
ruamel_yaml            0.15.87
s3transfer             0.3.7
Send2Trash             1.8.0
setuptools             46.1.3.post20200330
setuptools-scm         6.3.2
shiboken6              6.2.0
six                    1.14.0
terminado              0.12.1
testpath               0.5.0
text-unidecode         1.3
tomli                  1.2.2
tornado                6.1
tqdm                   4.44.1
traitlets              5.1.1
urllib3                1.25.8
wcwidth                0.2.5
webencodings           0.5.1
wheel                  0.34.2
widgetsnbextension     3.5.2
zipp                   3.6.0

Any ideas?

rsangole avatar Nov 20 '21 09:11 rsangole

rsangole

Did you ever get this figured out? I've been beating my head against the wall with the "'cv2.cv2' has no attribute 'freetype'" issue. Countless times of rebuilding opencv-contrib on fresh installs, different machines, different OSs, nothing seems to fix this issue for me.

mr-pooglyfoop avatar Jan 24 '22 03:01 mr-pooglyfoop

Hi @mr-pooglyfoop and @rsangole , sorry for the late response, I haven't actively maintained this project as I am currently working on another project. For the FreeType issue, please install this OpenCV version:

sudo pip3 install opencv-contrib-python==4.5.2.52

This contains the freetype module.

michaelhwn avatar Mar 02 '22 20:03 michaelhwn

Hello@michaelhwn I can not make it with your idea. Any another ideas?

miscedence12 avatar Mar 21 '22 03:03 miscedence12

Hi @aichishiguocai, did the installation fail? And which OS are you running? Because if the opencv-contrib-python==4.5.2.52 is installed properly on a Raspberry Pi OS, the freetype module should be included.

michaelhwn avatar Mar 21 '22 16:03 michaelhwn

Hello@michaelhwn,thanks for your reply. The installation succeed and my Os is Win10,but It did not work.When i replaced the "self.ft = cv2.freetype.createFreeType2()" by "self.ft = PIL.ImageFont.truetype("./simsun.ttc",32)",it worked.

miscedence12 avatar Mar 22 '22 01:03 miscedence12

Hi @aichishiguocai, this project was implemented for running on a Raspberry Pi 4B. I have not tested it on Windows. You will need to find a proper OpenCV Python package version that contains the freetype module.

michaelhwn avatar Mar 22 '22 01:03 michaelhwn