gpt4 book ai didi

python - Raspberry Pi 在引导期间关闭

转载 作者:行者123 更新时间:2023-12-02 16:23:44 25 4
gpt4 key购买 nike

我对 Raspberry Pi 很陌生。我有 Raspberry Pi 4 Model B、8 GB RAM 和 Raspbian OS。我想在启动过程中运行 OpenCV 视频。这就是我对 rc.local 进行一些更改的原因。我已经添加了

export DISPLAY=:0
sudo -H -u pi /usr/bin/python3 /home/pi/script.py &
引导设置:桌面自动登录
它工作得很好。然后我想销毁 OpenCV 视频,然后用任意键关闭 Pi,所以我设置了:
 # Press any key to quit 
key = cv2.waitKey(1) & 0xFF

if key > -1:
call("sudo poweroff", shell=True)
break
现在,当我启动 Pi 时,它正在关闭。我没有机会更改我的脚本。如何访问我的 Python 脚本并编辑我的代码?

最佳答案

您的代码设置方式只有 1ms按一个键,或 255将分配给 key .也许删除 0xFF部分代码并增加 waitKey() 内的时间以更好地捕捉按键。
来自 OpenCV documentation

The function waitKey waits for a key event infinitely (when \texttt{delay}\leq 0 ) or for delay milliseconds, when it is positive. ... .It returns the code of the pressed key or -1 if no key was pressed before the specified time had elapsed.


The function only works if there is at least one HighGUI window created and the window is active. If there are several HighGUI windows, any of them can be active.


如果您使用 Linux 作为主机,您可以按照以下说明进行操作:
  • 从 Raspberry PI 中取出 SD 卡并插入 Linux PC。
  • 通常它们会自动挂载至少两个分区,[ boot ] 和 [ rootfs ]。
  • 如果它们没有自动安装,请使用:mount /dev/mmcblk0p2 /mnt/raspb-rootfsmmcblk部分可能因您的 SD 卡适配器而异,您可以使用 dmesg检查适配器的名称。

  • 转至 /mnt/raspb-rootfs/etc/rc.local并删除脚本调用。
  • 将 SD 卡插入树莓派,板子应该可以正常启动。
  • 关于python - Raspberry Pi 在引导期间关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62772009/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com