SimpleCV相关问题

简介

Python

众所周知,Python3和Python2差别极大,大到可以说成是两种语言

SimpleCV

SimpleCV是一个开源框架,用于在Python中方便快速的构建计算机视觉方面的应用程序。SimpleCV封装了若干强大的计算机视觉库(目前仅封装了OpenCV),简化了用户对这些库的使用难度,如无需了解位深、文件格式、颜色空间、缓冲区管理等内容,降低了学习成本。可以用于在Python下快速开发计算机视觉的原型程序。

大家可能有几个疑问:
  1. OpenCV-Python支持Python2和Python3,那SimpleCV是否支持呢?
  2. SimpleCV无法加载OpenCV怎么解决?

OpenCV

OpenCV支持多种编程语言进行开发如如c++、Python、Java等,可在不同的平台上使用,包括Windows、Linux、OS X、Android和iOS。

大家可能有几个疑问:
  1. opencv、python-opencv 和 libopencv 有什么区别?
  2. OpenCV-Python安装好了,为什么导入cv2还会报错?
  3. OpenCV-Python安装各种报错,怎样安装才会比较顺利?
  4. OpenCV如何安装?

问题

解决SimpleCV无法加载OpenCV的问题 Cannot load OpenCV library which is required by SimpleCV

错误信息
raise ImportError(“Cannot load OpenCV library which is required by SimpleCV” )
解决方案

将对应库的后缀名修改一下即可

cd /usr/local/lib/python2.7/dist-packages
mv cv2.so cv2.pyd

OpenCV-Python安装好了,为什么导入cv2还会报错

opencv的安装版本要和python的版本相匹配。在安装过程中要找到自己python版本相匹配的opencv版本

大致的python版本对应的opencv如下图
在这里插入图片描述

地址:https://www.lfd.uci.edu/~gohlke/pythonlibs/

OpenCV-Python安装各种报错,怎样安装才会比较顺利

镜像源

opencv-python 库的安装 顾名思义,Python 代码运行需要依赖使用的 openCV 库
pip install opencv-python -i https://pypi.doubanio.com/simple/   #指定豆瓣源的安装方式,可以顺利运行安装
可以指定镜像源安装试试
[root@localhost ~]# pip3 install opencv-python
Looking in indexes: https://pypi.doubanio.com/simple
Collecting opencv-python
  Downloading https://pypi.doubanio.com/packages/29/35/a791b550cdeb4efd8b66e921748f2aff938868a29794489d93575d604a02/opencv_python-4.7.0.72-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (61.8 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 61.8/61.8 MB 25.5 MB/s eta 0:00:00
Collecting numpy>=1.17.0 (from opencv-python)
  Downloading https://pypi.doubanio.com/packages/6d/ad/ff3b21ebfe79a4d25b4a4f8e5cf9fd44a204adb6b33c09010f566f51027a/numpy-1.21.6-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (15.7 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 15.7/15.7 MB 3.5 MB/s eta 0:00:00
Installing collected packages: numpy, opencv-python
Successfully installed numpy-1.21.6 opencv-python-4.7.0.72
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv

运行效果如下

[root@localhost ~]# pip3 list
Package            Version
------------------ ---------
async-timeout      4.0.2
certifi            2020.12.5
chardet            4.0.0
defusedxml         0.7.1
idna               2.10
importlib-metadata 6.6.0
javaobj-py3        0.4.3
lxml               4.9.2
numpy              1.21.6
opencv-python      4.7.0.72
pip                23.1.2
redis              4.5.5
requests           2.25.1
setuptools         67.7.2
typing_extensions  4.5.0
urllib3            1.26.3
wheel              0.40.0
zipp               3.15.0
[root@localhost ~]# python3
Python 3.7.2 (default, Feb  3 2021, 16:25:57)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> print(cv2.version)
<module 'cv2.version' from '/usr/local/python3/lib/python3.7/site-packages/cv2/version.py'>
>>> print(cv2.__version__)
4.7.0
>>>
pip install opencv-python 下载慢 原因分析

使用 pip install opencv-python 下载慢,大概率是因为默认源

posted @ 2023-06-21 11:21  坦笑&&life  阅读(8)  评论(0编辑  收藏  举报  来源