标签归档:raspberry-pi

使用OpenCV时找不到模块cv2

问题:使用OpenCV时找不到模块cv2

我已经在Raspberry Pi上的Occidentalis操作系统(Raspbian的变体)上安装了OpenCV,使用的是在此处找到的jayrambhia脚本。它安装了版本2.4.5。

当我尝试import cv2使用Python程序时,收到以下消息:

pi@raspberrypi~$ python cam.py
Traceback (most recent call last)
File "cam.py", line 1, in <module>
    import cv2
ImportError: No module named cv2

该文件cv2.so存储在/usr/local/lib/python2.7/site-packages/...

/usr/local/libpython3.2和python2.6 中也有文件夹,这可能是个问题,但我不确定。

这可能是路径错误吗?感谢您的任何帮助,我是Linux的新手。

I have installed OpenCV on the Occidentalis operating system (a variant of Raspbian) on a Raspberry Pi, using jayrambhia’s script found here. It installed version 2.4.5.

When I try import cv2 in a Python program, I get the following message:

pi@raspberrypi~$ python cam.py
Traceback (most recent call last)
File "cam.py", line 1, in <module>
    import cv2
ImportError: No module named cv2

The file cv2.so is stored in /usr/local/lib/python2.7/site-packages/...

There are also folders in /usr/local/lib called python3.2 and python2.6, which could be a problem but I’m not sure.

Is this a path error perhaps? Any help is appreciated, I am new to Linux.


回答 0

首先在Terminal / CMD中运行以下命令:

conda update anaconda-navigator  
conda update navigator-updater  

那么以下说明的问题将得到解决

对于Windows,如果您安装了anaconda,则只需

pip install opencv-python

要么

conda install -c https://conda.binstar.org/menpo opencv

如果您使用的是Linux,则可以执行以下操作:

pip install opencv-python

要么

conda install opencv 

链接1 链路2

对于python3.5 +,请检查以下链接:Link3Link4

First do run these commands inside Terminal/CMD:

conda update anaconda-navigator  
conda update navigator-updater  

Then the issue for the instruction below will be resolved

For windows if you have anaconda installed, you can simply do

pip install opencv-python

or

conda install -c https://conda.binstar.org/menpo opencv

if you are on linux you can do :

pip install opencv-python

or

conda install opencv 

Link1 Link2

For python3.5+ check these links : Link3 , Link4

Update:
if you use anaconda, you may simply use this as well (and hence don’t need to add menpo channel):

conda install -c conda-forge opencv

回答 1

当python无法参考您保留了所需python文件或库的默认site-packages文件夹时,就会发生这种情况

在代码中添加以下行:

import sys

sys.path.append('/usr/local/lib/python2.7/site-packages')

或在bash中运行python命令之前,移至/usr/local/lib/python2.7/site-packages目录。如果您不想在代码中添加任何内容,则可以解决此问题。

This happens when python cannot refer to your default site-packages folder where you have kept the required python files or libraries

Add these lines in the code:

import sys

sys.path.append('/usr/local/lib/python2.7/site-packages')

or before running the python command in bash move to /usr/local/lib/python2.7/site-packages directory. This is a work around if you don’t want to add any thing to the code.


回答 2

我使用以下命令解决了我的问题:

conda install opencv

I solved my issue using the following command :

conda install opencv

回答 3

尝试在其中添加以下行 ~/.bashrc

export PYTHONPATH=/usr/local/lib/python2.7/site-packages:$PYTHONPATH

Try to add the following line in ~/.bashrc

export PYTHONPATH=/usr/local/lib/python2.7/site-packages:$PYTHONPATH

回答 4

Python3.x用户

sudo pip3 install opencv-python

Python3.x User

sudo pip3 install opencv-python

回答 5

上面的答案对我都不起作用。我一直在疯狂,直到我在下面找到了这个解决方案!

只需运行:

sudo apt install python-opencv

None of the above answers worked for me. I was going crazy until I found this solution below!

Simply run:

sudo apt install python-opencv

回答 6

对于Windows 10和Python 3.6,这对我有用

pip install opencv-contrib-python

For Windows 10 and Python 3.6, this worked for me

pip install opencv-contrib-python


回答 7

我使用以下命令解决了我的问题:

pip install opencv-python

I solved my issue using the following command :

pip install opencv-python

回答 8

我通过运行来解决:

pip3 install opencv-python

I solve it by running:

pip3 install opencv-python

回答 9

我遇到了与此问题相同的问题,我通过安装了cv2

pip install cv2

但是,当我导入cv2模块时,它没有显示名为cv2错误的模块。
然后,我cv2.pyd在计算机中搜索并找到文件,然后将其复制并粘贴到site-packages目录中

C:\Python27\Lib\site-packages

然后我关闭并重新打开了现有的应用程序,它起作用了。

编辑 我会告诉你如何安装cv2正确。

1.首先通过以下方式在计算机上安装numpy:

pip install numpy


2.从互联网(将近266 mb)下载opencv
opencv-2.4.12.exe为python 2.7 下载。然后安装此opencv-2.4.12.exe文件。
我解压缩C:\Users\harun\Downloads到此文件夹。
安装后,去寻找cv2.py文件夹。
为了我

C:\Users\harun\Downloads\opencv\build\python\2.7\x64

在此文件夹中,将cv2.pyd并复制到

C:\Python27\Lib\site-packages

现在您可以cv2在python脚本中使用了。

I have come accross same as this problem i installed cv2 by

pip install cv2

However when i import cv2 module it displayed no module named cv2 error.
Then i searched and find cv2.pyd files in my computer and i copy and paste to site-packages directory

C:\Python27\Lib\site-packages

then i closed and reopened existing application, it worked.

EDIT I will tell how to install cv2 correctly.

1. Firstly install numpy on your computer by

pip install numpy


2. Download opencv from internet (almost 266 mb).
I download opencv-2.4.12.exe for python 2.7. Then install this opencv-2.4.12.exe file.
I extracted to C:\Users\harun\Downloads to this folder.
After installation go look for cv2.py into the folders.
For me

C:\Users\harun\Downloads\opencv\build\python\2.7\x64

in this folder take thecv2.pyd and copy it in to the

C:\Python27\Lib\site-packages

now you can able to use cv2 in you python scripts.


回答 10

如果要在虚拟环境中安装opencv。在终端中运行命令以获取虚拟环境列表。

conda env list

或jupyter notebook命令是

!conda env list

然后更新您的Python。

conda update anaconda-navigator
conda update navigator-updater

在您选择的环境路径中安装opencv。

conda install -c ['environment path'] opencv

Juypter笔记本

!conda install --yes --prefix ['environment path'] opencv

If want to install opencv in virtual environment. Run command in terminal for getting virtual environment list.

conda env list

or jupyter notebook command is

!conda env list

Then update your anaconda.

conda update anaconda-navigator
conda update navigator-updater

Install opencv in your selected environment path.

conda install -c ['environment path'] opencv

Juypter notebook

!conda install --yes --prefix ['environment path'] opencv

回答 11

如果您要从刮擦中进行构建,请按照以下说明进行操作

你懂了No module named cv2.cv。儿子,您没sudo make install做错任何事,因为您没有犯错。

但是看看这一步

$ cd ~/.virtualenvs/cv/lib/python2.7/site-packages/
$ ln -s /usr/local/lib/python2.7/site-packages/cv2.so cv2.so

所有这些非常重要的步骤是将其链接起来。

ln -s /usr/local/lib/python2.7/site-packages/cv2.so cv2.so 
or 
ln -s /usr/local/lib/python2.7/dist-packages/cv2.so cv2.so

当您选择明智的链接或通过暴力破解时,只需查找cv2.so文件(如果存在)

在这里,我将输出。

    Successfully installed numpy-1.15.3
(cv) demonLover-desktop:~$ cd ~/.virtualenvs/cv/lib/python2.7/site-packages/
(cv) demonLover-desktop:~/.virtualenvs/cv/lib/python2.7/site-packages$ ln -s /usr/local/lib/python2.7/site-packages/cv2.so cv2.so
(cv) demonLover-desktop:~/.virtualenvs/cv/lib/python2.7/site-packages$ pip list
Package    Version
---------- -------
numpy      1.15.3 
pip        18.1   
setuptools 40.5.0 
wheel      0.32.2 
(cv) demonLover-desktop:~/.virtualenvs/cv/lib/python2.7/site-packages$ python
Python 2.7.12 (default, Dec  4 2017, 14:50:18) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named cv2
>>> 
[2]+  Stopped                 python
(cv) demonLover-desktop:~/.virtualenvs/cv/lib/python2.7/site-packages$ ls /usr/local/lib/python2.7/site-packages/c
ls: cannot access '/usr/local/lib/python2.7/site-packages/c': No such file or directory
(cv) demonLover-desktop:~/.virtualenvs/cv/lib/python2.7/site-packages$ ls /usr/local/lib/python2.7/site-packages/
(cv) demonLover-desktop:~/.virtualenvs/cv/lib/python2.7/site-packages$ deactivate 
demonLover-desktop:~/.virtualenvs/cv/lib/python2.7/site-packages$ ls /usr/local/lib/python2.7/site-packages/
demonLover-desktop:~/.virtualenvs/cv/lib/python2.7/site-packages$ ls
cv2.so  easy_install.py  easy_install.pyc  numpy  numpy-1.15.3.dist-info  pip  pip-18.1.dist-info  pkg_resources  setuptools  setuptools-40.5.0.dist-info  wheel  wheel-0.32.2.dist-info
demonLover-desktop:~/.virtualenvs/cv/lib/python2.7/site-packages$ ls /usr/local/lib/python2.7/site-packages/
demonLover-desktop:~/.virtualenvs/cv/lib/python2.7/site-packages$ ls -l  /usr/local/lib/python2.7/site-packages/
total 0
demonLover-desktop:~/.virtualenvs/cv/lib/python2.7/site-packages$ ls
cv2.so  easy_install.py  easy_install.pyc  numpy  numpy-1.15.3.dist-info  pip  pip-18.1.dist-info  pkg_resources  setuptools  setuptools-40.5.0.dist-info  wheel  wheel-0.32.2.dist-info
demonLover-desktop:~/.virtualenvs/cv/lib/python2.7/site-packages$ workon cv
(cv) demonLover-desktop:~/.virtualenvs/cv/lib/python2.7/site-packages$ python
Python 2.7.12 (default, Dec  4 2017, 14:50:18) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named cv2
>>> 
[3]+  Stopped                 python
(cv) demonLover-desktop:~/.virtualenvs/cv/lib/python2.7/site-packages$ find / -name "cv2.so"
find: ‘/lost+found’: Permission denied
find: ‘/run/udisks2’: Permission denied
find: ‘/run/docker’: Permission denied
find: ‘/run/exim4’: Permission denied
find: ‘/run/lightdm’: Permission denied
find: ‘/run/cups/certs’: Permission denied
find: ‘/run/sudo’: Permission denied
find: ‘/run/samba/ncalrpc/np’: Permission denied
find: ‘/run/postgresql/9.5-main.pg_stat_tmp’: Permission denied
find: ‘/run/postgresql/10-main.pg_stat_tmp’: Permission denied
find: ‘/run/lvm’: Permission denied
find: ‘/run/systemd/inaccessible’: Permission denied
find: ‘/run/lock/lvm’: Permission denied
find: ‘/root’: Permission denied
^C
(cv) demonLover-desktop:~/.virtualenvs/cv/lib/python2.7/site-packages$ sudofind / -name "cv2.so"
sudofind: command not found
(cv) demonLover-desktop:~/.virtualenvs/cv/lib/python2.7/site-packages$ ^C
(cv) demonLover-desktop:~/.virtualenvs/cv/lib/python2.7/site-packages$ sudo find / -name "cv2.so"
[sudo] password for app: 
find: ‘/run/user/1000/gvfs’: Permission denied
^C
(cv) demonLover-desktop:~/.virtualenvs/cv/lib/python2.7/site-packages$ sudo find /usr/ -name "cv2.so"
/usr/local/lib/python2.7/dist-packages/cv2.so
^C
(cv) demonLover-desktop:~/.virtualenvs/cv/lib/python2.7/site-packages$ ln -s /usr/local/lib/python2.7/dist-packages/ccv2.so cv2.so
click/                        clonevirtualenv.pyc           configparser-3.5.0.dist-info/ configparser.py               cv2.so                        cycler.py
clonevirtualenv.py            concurrent/                   configparser-3.5.0-nspkg.pth  configparser.pyc              cycler-0.10.0.dist-info/      cycler.pyc
(cv) demonLover-desktop:~/.virtualenvs/cv/lib/python2.7/site-packages$ ln -s /usr/local/lib/python2.7/dist-packages/cv2.so cv2.so
ln: failed to create symbolic link 'cv2.so': File exists
(cv) demonLover-desktop:~/.virtualenvs/cv/lib/python2.7/site-packages$ rm cv2.so 
(cv) demonLover-desktop:~/.virtualenvs/cv/lib/python2.7/site-packages$ ln -s /usr/local/lib/python2.7/dist-packages/cv2.so cv2.so
(cv) demonLover-desktop:~/.virtualenvs/cv/lib/python2.7/site-packages$ ls
cv2.so  easy_install.py  easy_install.pyc  numpy  numpy-1.15.3.dist-info  pip  pip-18.1.dist-info  pkg_resources  setuptools  setuptools-40.5.0.dist-info  wheel  wheel-0.32.2.dist-info
(cv) demonLover-desktop:~/.virtualenvs/cv/lib/python2.7/site-packages$ python
Python 2.7.12 (default, Dec  4 2017, 14:50:18) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> 

如果您的构建正确,我的步骤只会有所帮助。

IF YOU ARE BUILDING FROM SCRATCH, GO THROUGH THIS

You get No module named cv2.cv. Son, you did all step right, since your sudo make install gave no errors.

However look at this step

$ cd ~/.virtualenvs/cv/lib/python2.7/site-packages/
$ ln -s /usr/local/lib/python2.7/site-packages/cv2.so cv2.so

THE VERY IMPORTANT STEP OF ALL THESE IS TO LINK IT.

ln -s /usr/local/lib/python2.7/site-packages/cv2.so cv2.so 
or 
ln -s /usr/local/lib/python2.7/dist-packages/cv2.so cv2.so

The moment you choose wise linking, or by brute force just find the cv2.so file if that exist or not

Here I am throwing my output.

    Successfully installed numpy-1.15.3
(cv) demonLover-desktop:~$ cd ~/.virtualenvs/cv/lib/python2.7/site-packages/
(cv) demonLover-desktop:~/.virtualenvs/cv/lib/python2.7/site-packages$ ln -s /usr/local/lib/python2.7/site-packages/cv2.so cv2.so
(cv) demonLover-desktop:~/.virtualenvs/cv/lib/python2.7/site-packages$ pip list
Package    Version
---------- -------
numpy      1.15.3 
pip        18.1   
setuptools 40.5.0 
wheel      0.32.2 
(cv) demonLover-desktop:~/.virtualenvs/cv/lib/python2.7/site-packages$ python
Python 2.7.12 (default, Dec  4 2017, 14:50:18) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named cv2
>>> 
[2]+  Stopped                 python
(cv) demonLover-desktop:~/.virtualenvs/cv/lib/python2.7/site-packages$ ls /usr/local/lib/python2.7/site-packages/c
ls: cannot access '/usr/local/lib/python2.7/site-packages/c': No such file or directory
(cv) demonLover-desktop:~/.virtualenvs/cv/lib/python2.7/site-packages$ ls /usr/local/lib/python2.7/site-packages/
(cv) demonLover-desktop:~/.virtualenvs/cv/lib/python2.7/site-packages$ deactivate 
demonLover-desktop:~/.virtualenvs/cv/lib/python2.7/site-packages$ ls /usr/local/lib/python2.7/site-packages/
demonLover-desktop:~/.virtualenvs/cv/lib/python2.7/site-packages$ ls
cv2.so  easy_install.py  easy_install.pyc  numpy  numpy-1.15.3.dist-info  pip  pip-18.1.dist-info  pkg_resources  setuptools  setuptools-40.5.0.dist-info  wheel  wheel-0.32.2.dist-info
demonLover-desktop:~/.virtualenvs/cv/lib/python2.7/site-packages$ ls /usr/local/lib/python2.7/site-packages/
demonLover-desktop:~/.virtualenvs/cv/lib/python2.7/site-packages$ ls -l  /usr/local/lib/python2.7/site-packages/
total 0
demonLover-desktop:~/.virtualenvs/cv/lib/python2.7/site-packages$ ls
cv2.so  easy_install.py  easy_install.pyc  numpy  numpy-1.15.3.dist-info  pip  pip-18.1.dist-info  pkg_resources  setuptools  setuptools-40.5.0.dist-info  wheel  wheel-0.32.2.dist-info
demonLover-desktop:~/.virtualenvs/cv/lib/python2.7/site-packages$ workon cv
(cv) demonLover-desktop:~/.virtualenvs/cv/lib/python2.7/site-packages$ python
Python 2.7.12 (default, Dec  4 2017, 14:50:18) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named cv2
>>> 
[3]+  Stopped                 python
(cv) demonLover-desktop:~/.virtualenvs/cv/lib/python2.7/site-packages$ find / -name "cv2.so"
find: ‘/lost+found’: Permission denied
find: ‘/run/udisks2’: Permission denied
find: ‘/run/docker’: Permission denied
find: ‘/run/exim4’: Permission denied
find: ‘/run/lightdm’: Permission denied
find: ‘/run/cups/certs’: Permission denied
find: ‘/run/sudo’: Permission denied
find: ‘/run/samba/ncalrpc/np’: Permission denied
find: ‘/run/postgresql/9.5-main.pg_stat_tmp’: Permission denied
find: ‘/run/postgresql/10-main.pg_stat_tmp’: Permission denied
find: ‘/run/lvm’: Permission denied
find: ‘/run/systemd/inaccessible’: Permission denied
find: ‘/run/lock/lvm’: Permission denied
find: ‘/root’: Permission denied
^C
(cv) demonLover-desktop:~/.virtualenvs/cv/lib/python2.7/site-packages$ sudofind / -name "cv2.so"
sudofind: command not found
(cv) demonLover-desktop:~/.virtualenvs/cv/lib/python2.7/site-packages$ ^C
(cv) demonLover-desktop:~/.virtualenvs/cv/lib/python2.7/site-packages$ sudo find / -name "cv2.so"
[sudo] password for app: 
find: ‘/run/user/1000/gvfs’: Permission denied
^C
(cv) demonLover-desktop:~/.virtualenvs/cv/lib/python2.7/site-packages$ sudo find /usr/ -name "cv2.so"
/usr/local/lib/python2.7/dist-packages/cv2.so
^C
(cv) demonLover-desktop:~/.virtualenvs/cv/lib/python2.7/site-packages$ ln -s /usr/local/lib/python2.7/dist-packages/ccv2.so cv2.so
click/                        clonevirtualenv.pyc           configparser-3.5.0.dist-info/ configparser.py               cv2.so                        cycler.py
clonevirtualenv.py            concurrent/                   configparser-3.5.0-nspkg.pth  configparser.pyc              cycler-0.10.0.dist-info/      cycler.pyc
(cv) demonLover-desktop:~/.virtualenvs/cv/lib/python2.7/site-packages$ ln -s /usr/local/lib/python2.7/dist-packages/cv2.so cv2.so
ln: failed to create symbolic link 'cv2.so': File exists
(cv) demonLover-desktop:~/.virtualenvs/cv/lib/python2.7/site-packages$ rm cv2.so 
(cv) demonLover-desktop:~/.virtualenvs/cv/lib/python2.7/site-packages$ ln -s /usr/local/lib/python2.7/dist-packages/cv2.so cv2.so
(cv) demonLover-desktop:~/.virtualenvs/cv/lib/python2.7/site-packages$ ls
cv2.so  easy_install.py  easy_install.pyc  numpy  numpy-1.15.3.dist-info  pip  pip-18.1.dist-info  pkg_resources  setuptools  setuptools-40.5.0.dist-info  wheel  wheel-0.32.2.dist-info
(cv) demonLover-desktop:~/.virtualenvs/cv/lib/python2.7/site-packages$ python
Python 2.7.12 (default, Dec  4 2017, 14:50:18) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> 

My step will only help, if your built is done right.


回答 12

我通过运行代码解决 pip install opencv_contrib_python

I solve this by run code pip install opencv_contrib_python


回答 13

试试看:

sudo ldconfig

sudo nano /etc/ld.so.conf.d/opencv.conf

opencv.conf在命令窗口的not中添加以下行

/usr/local/lib

然后:

sudo ldconfig

sudo nano /etc/bash.bashrc

并将这两行添加到bash.bashrc不在命令窗口中

PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig       
export PKG_CONFIG_PATH

最后重启你的Pi sudo reboot now

并尝试 import cv2

Try this out:

sudo ldconfig

sudo nano /etc/ld.so.conf.d/opencv.conf

and add this following line in the opencv.conf not in the command window

/usr/local/lib

Then:

sudo ldconfig

sudo nano /etc/bash.bashrc

and add this two lines in the bash.bashrc not in the command window

PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig       
export PKG_CONFIG_PATH

at last reboot your Pi sudo reboot now

and try import cv2


回答 14

我安装和工作opencv的另一种方法是在Visual Studio 2017社区内部。Visual Studio具有一个不错的带有调试功能的python环境。
因此,从vs python env窗口中,我搜索并添加了opencv。只是想我会分享,因为我喜欢以不同的方式在不同的计算机上尝试。

Another way I got opencv to install and work was inside visual studio 2017 community. Visual studio has a nice python environment with debugging.
So from the vs python env window I searched and added opencv. Just thought I would share because I like to try things different ways and on different computers.


回答 15

我有同样的问题,只是无法通过分别安装到/ opt / opencv和opencv3中的opencv2和opencv3来解决。原来,在我的主目录中,血腥的anaconda安装的opencv首先出现在路径上,并且破坏了opencv。删除它,并使用/etc/ld.so.conf.d/opencv.conf中定义的/ opt / opencv3 / lib开始。第一次工作完美。您安装了Python吗?可能是问题。

I had the same problem, just couldn’t figure it out with opencv2 and opencv3 installed into /opt/opencv and opencv3 respectively. Turned out that bloody anaconda install of opencv in my home directory was first on path and mangled opencv. Removed it and started using /opt/opencv3/lib as defined in /etc/ld.so.conf.d/opencv.conf. Worked perfectly first go. Do you have anaconda installed? Could be the issue.


IoT-For-Beginners-面向初学者的物联网课程

微软的Azure云倡导者很高兴提供为期12周、24节课的IoT基础知识课程。每节课包括课前和课后测验、完成课程的书面说明、解决方案、作业等。我们的基于项目的教学法允许您边学边建,这是一种行之有效的新技能“坚持”的方法

这些项目涵盖了食物从农场到餐桌的旅程。这包括农业、物流、制造业、零售业和消费业-所有这些领域都是物联网设备的热门行业领域

衷心感谢我们的作者Jen FoxJen LooperJim Bennett,和我们的素描艺术家Nitya Narasimhan

也感谢我们的团队Microsoft Learn Student Ambassadors他们一直在审阅和翻译这门课程-Aditya GargAnurag SharmaArpita DasAryan JainBhavesh SunejaFaith HunjaLateefah BelloManvi JhaMireille TanMohammad Iftekher (Iftu) Ebne JalalMohammad ZulfikarPriyanshu SrivastavThanmai Gowducheruvu,以及Zina Kamel

见见团队吧!

教师,我们有included some suggestions如何使用这门课程。如果您想创建您自己的课程,我们还提供了一个lesson template

学生,自学使用本课程,分叉整个回购,自己完成练习,先从讲前小考开始,然后朗读讲座,完成活动的睡觉。尝试通过理解课程而不是复制解决方案代码来创建项目;但是,在每个面向项目的课程的/Solutions文件夹中都可以找到该代码。另一个想法是和朋友们组成一个学习小组,一起学习内容。为了进一步研究,我们建议Microsoft Learn

有关本课程的视频概述,请查看此视频:

🎥点击上面的图片观看关于该项目的视频!

教育学

在构建这门课程时,我们选择了两个教学原则:确保它是基于项目的,并包括频繁的测验。到本系列结束时,学生们将构建植物监控和浇水系统、车辆跟踪器、用于跟踪和检查食物的智能工厂设置以及声控烹饪定时器,并将学习物联网的基础知识,包括如何编写设备代码、连接到云、分析遥测和在边缘运行人工智能

通过确保内容与项目一致,这一过程对学生来说更具吸引力,并将增加对概念的保留

此外,课前的一次低风险的测验可以确定学生学习某一主题的意图,而课后的第二次测验可以确保学生更好地记住某一主题。本课程设计灵活有趣,可以全部或部分选修。这些项目一开始规模很小,到12周周期结束时变得越来越复杂。

每个项目都基于学生和业余爱好者可用的真实硬件。每个项目都着眼于特定的项目领域,提供相关的背景知识。要成为一名成功的开发人员,了解您正在解决问题的领域是很有帮助的,只要提供此背景知识,学生就可以在他们作为物联网开发人员可能被要求解决的那种现实世界问题的背景下思考他们的物联网解决方案和学习。学生了解他们正在构建的解决方案的“原因”,并了解最终用户

硬件

我们有两种物联网硬件可供选择,具体取决于个人偏好、编程语言知识或偏好、学习目标和可用性。我们还为那些无法访问硬件或想要在承诺购买之前了解更多信息的人提供了一个“虚拟硬件”版本。你可以阅读更多,并在网上找到一份“购物清单”。hardware page,包括从Seeed Studio的朋友那里购买完整套件的链接

💁找到我们的Code of ConductContributing,以及Translation指导方针。我们欢迎您的建设性意见!

每节课包括:

  • 草图注释
  • 可选补充视频
  • 课前热身测验
  • 书面课
  • 有关基于项目的课程,请参阅有关如何生成项目的分步指南
  • 知识检查
  • 一项挑战
  • 补充阅读
  • 作业
  • 课后测验

关于测验的一个注解:所有的测验都包含在内in this app,共48个测验,每个测验3个问题。它们是从课程内部链接的,但测验应用程序可以在本地运行;请按照中的说明进行操作quiz-app文件夹。他们正在逐渐本地化。

课程

项目名称 教授的概念 学习目标 链接的课程
01 Getting started 物联网简介 在设置您的第一台物联网设备时,了解物联网的基本原理以及物联网解决方案的基本构建块,如传感器和云服务 Introduction to IoT
02 Getting started 更深入地研究物联网 了解有关物联网系统组件以及微控制器和单板计算机的更多信息 A deeper dive into IoT
03 Getting started 通过传感器和执行器与物理世界交互 了解用于从物理世界收集数据的传感器和用于发送反馈的执行器,同时构建夜灯 Interact with the physical world with sensors and actuators
04 Getting started 将您的设备连接到互联网 通过将夜灯连接到MQTT代理,了解如何将物联网设备连接到Internet以发送和接收消息 Connect your device to the Internet
05 Farm 预测植物生长 了解如何使用物联网设备捕获的温度数据预测植物生长 Predict plant growth
06 Farm 检测土壤水分 了解如何检测土壤水分和校准土壤水分传感器 Detect soil moisture
07 Farm 植物自动浇水 了解如何使用继电器和MQTT自动和定时浇水 Automated plant watering
08 Farm 将您的工厂迁移到云 了解云和云托管的物联网服务,以及如何将您的工厂连接到这些服务之一,而不是公共MQTT代理 Migrate your plant to the cloud
09 Farm 将您的应用程序逻辑迁移到云 了解如何在云中编写响应物联网消息的应用程序逻辑 Migrate your application logic to the cloud
10个 Farm 确保您的工厂安全 了解物联网的安全性,以及如何使用密钥和证书保护您的工厂安全 Keep your plant secure
11个 Transport 位置跟踪 了解物联网设备的GPS位置跟踪 Location tracking
12个 Transport 存储位置数据 了解如何存储物联网数据以便稍后可视化或分析 Store location data
13个 Transport 可视化位置数据 了解有关在地图上可视化位置数据以及地图如何以2维形式表示真实3D世界的信息 Visualize location data
14. Transport 土工栅栏 了解GeoFence,以及如何使用它们在供应链中的车辆接近目的地时发出警报 Geofences
15个 Manufacturing 培训一名水果质量检测员 了解有关在云中培训图像分类器以检测水果质量的信息 Train a fruit quality detector
16个 Manufacturing 通过物联网设备检查水果质量 了解如何使用物联网设备上的水果质量检测仪 Check fruit quality from an IoT device
17. Manufacturing 在边缘运行你的水果探测器 了解有关在边缘的物联网设备上运行水果检测器的信息 Run your fruit detector on the edge
18岁 Manufacturing 从传感器触发水果质量检测 了解如何从传感器触发水果质量检测 Trigger fruit quality detection from a sensor
19个 Retail 培训一名库存检验员 了解如何使用对象检测来训练库存检测器清点商店中的库存 Train a stock detector
20个 Retail 检查物联网设备的库存 了解如何使用对象检测模型检查物联网设备的库存 Check stock from an IoT device
21岁 Consumer 使用物联网设备识别语音 了解如何识别来自物联网设备的语音以构建智能计时器 Recognize speech with an IoT device
22 Consumer 理解语言 了解如何理解对物联网设备说的句子 Understand language
23个 Consumer 设置计时器并提供语音反馈 了解如何在物联网设备上设置计时器,并就计时器何时设置和何时结束提供口头反馈 Set a timer and provide spoken feedback
24个 Consumer 支持多种语言 了解如何支持多种语言,包括与您的智能计时器对话和从您的智能计时器响应 Support multiple languages

脱机访问

您可以使用以下命令脱机运行此文档Docsify分叉这个回购,install Docsify在本地计算机上,然后在此存储库的根文件夹中键入docsify serve该网站将在您的本地主机上的端口3000上提供服务:localhost:3000

PDF格式

如果需要,您可以生成此内容的PDF以供脱机访问。要做到这一点,请确保您拥有npm installed并在此存储库的根文件夹中运行以下命令:

npm i
npm run convert

需要帮助!

你愿意贡献一份翻译吗?请阅读我们的translation guidelines并添加输入to one of the translations issues如果您想要翻译成一种新的语言,请提出一个新的问题进行跟踪

其他课程

我们团队制作其他课程!查看:

图像属性

您可以在本课程中所需的位置找到本课程中使用的图像的所有属性Attributions

Core-🏡开源家庭自动化,将本地控制和隐私放在首位

家庭助理

开源家庭自动化,将本地控制和隐私放在首位。由世界各地的修补工人和DIY爱好者社区提供动力。非常适合在Raspberry PI或本地服务器上运行

检查home-assistant.ioa
demo
installation instructionstutorialsdocumentation

特色集成

该系统使用模块化方法构建,因此可以轻松实现对其他设备或操作的支持。另请参阅section on architecture以及section on creating your own
components

如果在使用Home Assistant或开发组件期间遇到问题,请检查Home Assistant help section有关更多帮助和信息,请访问我们的网站