Git Product home page Git Product logo

Comments (14)

makelove avatar makelove commented on August 21, 2024

ft.loadFontData(fontFileName='wqy-zenhei.ttc', id=0) # 文泉驿的开源中文字体

ch6 文件夹里有个wqy-zenhei.ttc文件
你load一下就行了

from opencv-python-tutorial.

violet17 avatar violet17 commented on August 21, 2024

@makelove
ch06-绘图函数/Drawing_UTF-8_strings.py 中使用了ft = cv2.freetype.createFreeType2()。 但是 我安装了opencv-python 和opencv-contrib-python ,还是显示cv2' has no attribute 'freetype'。 应该怎么样安装才能在cv2这个模块中调用freetype 呢?

C++中是由freetype这个模块的,但是python似乎没有把这个编译进去。您是怎么操作的呢?
是不是手动编译opencv,才能使用这个freetype的模块?
您有添加freetype 编译opencv 4.x版本的教程吗?

谢谢!

from opencv-python-tutorial.

makelove avatar makelove commented on August 21, 2024

你只需要安装 opencv-contrib-python 就行了
安装opencv-contrib-python 会替换opencv-python

我在我的MacBook上试了,没问题。
没有提示cv2' has no attribute 'freetype'

截屏2020-03-2910 20 29

from opencv-python-tutorial.

violet17 avatar violet17 commented on August 21, 2024

@makelove
Opencv 是哪个版本呢? 直接pip install opencv-contrib-python 就可以了?

我的python是3.6.8的。安装了opencv-contrib-python也不行

from opencv-python-tutorial.

makelove avatar makelove commented on August 21, 2024
pip install opencv-contrib-python==4.1.2.30

这是我电脑上的版本

from opencv-python-tutorial.

violet17 avatar violet17 commented on August 21, 2024

image
我的不行。。。

from opencv-python-tutorial.

violet17 avatar violet17 commented on August 21, 2024

image
我的也按你的命令重新安装版本了,还是不行。。。。。

from opencv-python-tutorial.

makelove avatar makelove commented on August 21, 2024
import cv2
print(cv2.__version__)

看看 输出是不是 4.1.2

如果不是,就是调用错误
pip和Anaconda不是同一个环境
截图是显示 on linux 是什么意思?

建议还是在LInux平台上开发
Windows太多问题了。
我帮不了你

from opencv-python-tutorial.

violet17 avatar violet17 commented on August 21, 2024

输出是4.1.2
pip和anaconda是一个环境。用的是linux,on linux就是linux上的。
image

from opencv-python-tutorial.

makelove avatar makelove commented on August 21, 2024

参考
opencv/opencv-python#243

解决
python+freetype+opencv 图片中文(汉字)显示 详细图文教程和项目完整源代码
https://www.cnblogs.com/datou-swag/articles/10671842.html

你自己搞吧

from opencv-python-tutorial.

violet17 avatar violet17 commented on August 21, 2024

@makelove
谢谢! 这个方法我之前了解过。。 用转换成PIL的方法和freetype-py都没有opencv自带的freetype的好用。。。
就是很好奇,为啥你装opencv-contrib-python会自带freetype,为啥我的不带。。。很奇怪。。。你没有额外安装什么么。。。

from opencv-python-tutorial.

violet17 avatar violet17 commented on August 21, 2024

@makelove
非常感谢!
我知道为啥了。
我用我的MAC试了一下,发现用4.1.2.30的opencv-contrib-python 可以用cv2.freetype. python版本试3.6的。
唉 就是linux和windows的opencv-contrib-python 没有这个功能。

from opencv-python-tutorial.

makelove avatar makelove commented on August 21, 2024

@makelove
谢谢! 这个方法我之前了解过。。 用转换成PIL的方法和freetype-py都没有opencv自带的freetype的好用。。。
就是很好奇,为啥你装opencv-contrib-python会自带freetype,为啥我的不带。。。很奇怪。。。你没有额外安装什么么。。。

我也是MacBook
Python 3.7.4

from opencv-python-tutorial.

zjykzj avatar zjykzj commented on August 21, 2024

@makelove
非常感谢!
我知道为啥了。
我用我的MAC试了一下,发现用4.1.2.30的opencv-contrib-python 可以用cv2.freetype. python版本试3.6的。
唉 就是linux和windows的opencv-contrib-python 没有这个功能。

opencv-python默认不构建FreeType模块,如果有需要可以下载源码进行构建(-DWITH_FREETYPE=ON),参考[text]绘制中文字符

from opencv-python-tutorial.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.