Raspberry Pi Camera无法连接到代码

问题描述 投票:0回答:1

我是编程的绝对初学者,我试图制作一个用AI描述照片的照相机(微软的Azure计算机视觉API)。我使用了Charles Channon的代码,它将指令放在Hacker.io上。

通过按照说明我发现,由于某种原因,代码只能在Linux终端中工作,而不是在Tronny中(一直说错误No moduled named 'urllib2'),这很奇怪,因为它是完全相同的代码?它只有在我将它粘贴到Adafruit_CharLCD/examples文件夹时才有效,而说明告诉我在/home/pi文件夹中粘贴它应该足够了,这不是因为代码会告诉它无法找到module named Adafruit_CharLCD

所以我发送了代码RaspberryPi(包括PiCamera和LCD)。它将重新启动并告诉我“拍照!”。在这之后,屏幕告诉我它正在“捕捉......”图像,但从未真正做到过?

我有一种感觉,对于普通程序员来说,这是一个非常简单的初学者问题,可以通过正确粘贴正确的文件夹中的正确文件来解决,但我已经尝试了几个文件夹并重命名,但它仍然无法正常工作.. 。

知道如何使用Computer Vision API将Raspberry Pi Camera正确连接到代码的人?

PS。包括沮丧的形象

Raspberry Pi hardware

Photo of my raspberry PI monitor

raspberry-pi connection
1个回答
0
投票
By just following the instructions I found out that for some reason
the code only works in the Linux Terminal and not from the Tronny
(keeps saying error No moduled named 'urllib2'), 
which is weird because it's the exact same code? 

我想也许在Tronny python版本3中使用而不是像Raspberry中的python版本2。你可以使用这个命令检查Tronny中的python版本吗?

python --version

python urllib2所述,它在几个较小的模块中分开。所以如果在Tronny中它是python版本3,那么你应该修改脚本头来导入正确的库

It also only works when I paste it in the Adafruit_CharLCD/examples
folder, while the instructions tell me that pasting it in the 
/home/pi folder should be sufficient enough, 
which isn't since the code will then tell that it cannot find 
the module named Adafruit_CharLCD.

在源代码中,有一个导入需要Adafruit_CharLCD。因此,当您移动到其他目录时,当前目录中不存在Adafruit_CharLCD。这就是脚本无法加载的原因

LCD = None
import Adafruit_CharLCD as LCD

要使脚本正常加载Adafruit_CharLCD,请在代码中添加以下行。

sys.path.append("absolute path to Adafruit_CharLCD")

希望有所帮助

© www.soinside.com 2019 - 2024. All rights reserved.