在我的 GUI 代码中,我尝试通过单击一个按钮来同时运行循环 1 和循环 2。因此,我曾经Thread实现过这一点。但我也尝试通过单击另一个按钮来阻止它,但失败了。在stackoverflow上搜索后,我发现没有直接杀死 的方法Thread。这是代码的一部分:
def loop1():
while True:
call (["raspivid -n -op 150 -w 640 -h 480 -b 2666666.67 -t 5000 -o test.mp4"],shell=True)
call (["raspivid -n -op 150 -w 640 -h 480 -b 2666666.67 -t 5000 -o test1.mp4"],shell=True)
def loop2():
while True:
call (["arecord -D plughw:1 --duration=5 -f cd -vv rectest.wav"],shell=True)
call (["arecord -D plughw:1 --duration=5 -f cd -vv rectest1.wav"],shell=True)
def combine():
Thread(target = loop1).start()
Thread(target = loop2).start()
def stop():
Thread(target = loop1).terminate() …Run Code Online (Sandbox Code Playgroud) 我尝试过执行 NTP,但是这个 pi 在每月的不同时间从不同的地方旅行,并且并不总是能够正确访问 NTP。有没有办法让它在启动过程中与科罗拉多州的原子钟同步?
我目前在 Model B 的 512 版本上运行 Raspian OS
我在互联网上找到了这个脚本,并尝试在 Google 上找到完整的参数列表,但没有成功:
# Record a video
v4l2-ctl --set-fmt-video=width=800,height=600,pixelformat=4
v4l2-ctl --stream-mmap=3 --stream-count=100 --stream-to=$1
exit
Run Code Online (Sandbox Code Playgroud)
你们知道如何旋转相机吗?
谢谢!
我对 Python 很陌生,正在尝试使用 Python 在 Raspberry Pi2 中制作一个小项目
目前我有 2 个代码文件run1.py和run2.py
我想写一个if-else条件Project.py,但我不知道如何正确编写代码......
if (condition is true) ----> run the code from file "run1.py"
else ----> run the code from file "run2.py"
Run Code Online (Sandbox Code Playgroud)
__main__是关于“ ”或“ ”的主题import os吗?我也想了解它是如何工作的,但还没有真正理解。
谢谢
我正在为树莓派使用 adafruit python 库。
这是我要导入到我的文件中的文件位置
/projectfolder/Adafruit-Raspberry-Pi-Python-Code/Adafruit_LEDBackpack/Adafruit_7Segment.py
Run Code Online (Sandbox Code Playgroud)
这就是我试图将库导入到的文件所在的位置
/projectfolder/start.py
Run Code Online (Sandbox Code Playgroud)
我在 start.py 中有这个,但它不起作用。知道为什么吗?
from Adafruit-Raspberry-Pi-Python-Code/Adafruit_LEDBackpack/Adafruit_7Segment import SevenSegment
Run Code Online (Sandbox Code Playgroud)
这是我收到的错误:
File "timer.py", line 5
from Adafruit-Raspberry-Pi-Python-Code/Adafruit_LEDBackpack/Adafruit_7Segment import SevenSegment
^
SyntaxError: invalid syntax
Run Code Online (Sandbox Code Playgroud) 我是嵌入式编程的新手,想了解在功能强大的嵌入式处理器上运行 python scikit-learn 需要做什么。
以树莓派为例。
我为 CLI 实用程序创建了一个 Dockerfile,它在我的 Linux 笔记本电脑上运行良好。我尝试在安装了 Docker 的 Raspberry Pi 上运行容器,但它不起作用。
我知道无数公司创建图像来支持多种架构,他们是如何做到这一点的?
我想知道,因为我希望 CLI 的容器可以部署到 Raspberry Pi 以及我的 Linux 笔记本电脑。
我只想在树莓派中加载 onnx 模型。如何在边缘设备中加载 onnx 模型?
我使用 RPI3B 并尝试安装 Virtualenvwrapper 和 Virtualenvs。在我添加之后
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh
Run Code Online (Sandbox Code Playgroud)
在 ~/.profile 中。然后source ~ ~/.profile
我使用mkvirtualenv cv -p python2. 之后我收到这些消息:
created virtual environment CPython2.7.16.final.0-32 in 672ms
creator CPython2Posix(dest=/home/pi/.virtualenvs/cv, clear=False, global=False)
seeder FromAppData(download=False, pip=latest, setuptools=latest, wheel=latest, via=copy,
app_data_dir=/home/pi/.local/share/virtualenv/seed-v1)
activators PythonActivator,CShellActivator,FishActivator,PowerShellActivator,BashActivator
virtualenvwrapper.user_scripts creating /home/pi/.virtualenvs/cv/usr/local/bin/predeactivate
ERROR: Environment '/home/pi/.virtualenvs/cv' does not contain an activate script.
Run Code Online (Sandbox Code Playgroud)
但我不能使用 workon cv。最后的消息一次又一次地出现。我该如何解决?我也尝试重新安装,但没有帮助。
python virtualenv virtualenvwrapper raspberry-pi raspberry-pi3
总结:我有一个连接到 rpi-zero 的 microbit。我对 microbit 进行了编码,当A button按下它时,它会将数据发送uart.write到 rpi-zero。
在这个测试中,microbit 将向uart.write("Test")rpi-0 写入一个“测试”字。
我的最终目标是使用 rpi-zero 的 BLE 功能作为控制设备,从 microbit 按钮发送指令。
我找到了用 python 为 rpi 编写的GATT 服务器代码。它运行完全没有问题。
下面的代码将用于监听 microbit uart 服务并检查接收到的数据是否为"Test":
import serial
serialPort = serial.Serial(port = "/dev/ttyACM0", baudrate=115200, bytesize=8, timeout=0.5, stopbits=serial.STOPBITS_ONE)
serialString = " "
(serialPort.in_waiting > 0)
while True:
serialString = serialPort.readline()
if serialString == b'Test':
print("Yes")
else:
print("F")
Run Code Online (Sandbox Code Playgroud)
但真正的问题是当我尝试将这个循环代码实现到 GATT 服务器代码中时。
我似乎无法理解如何将此值传递给 self.send_tx
此外,似乎 GATT 服务器代码中已经存在一个全局循环。所以我尝试使用线程同时运行这两个函数,但是当我添加self.send_tx("Test")它时只会抛出一个错误Self is …
raspberry-pi ×10
python ×6
arm ×1
bbc-microbit ×1
docker ×1
if-statement ×1
iot ×1
linux ×1
onnx ×1
raspbian ×1
scikit-learn ×1
shell ×1
tkinter ×1
uart ×1
v4l2 ×1
virtualenv ×1
x86 ×1