覆盆子皮仪表盘摄像机
pidashcam的Python项目详细描述
使用Raspberry PI提供仪表盘功能的Python包。
先决条件
- 各种标准库
- Python照相机
- Python GPS
- python-rpi.gpio
硬件
功能概述
- 启动时,相机开始录制到内存缓冲区中 可配置大小(默认为60秒)。 视频流覆盖当前日期时间、速度、位置和 行驶方向。
- 当摄像机正在录制时,LED1缓慢闪烁。
- 如果按下按钮A,缓冲区的当前内容为 刷新到一个文件,以及以下几秒钟的视频。 (这可用于捕获某个事件的前后)。这个 然后摄像机返回到缓冲区进行记录。 保存缓冲区时,LED1闪烁更快。
- 如果按下按钮B,缓冲区的当前内容为 刷新到文件并停止录制。LED1关闭。
- 如果再次按下按钮B,则从新的和 LED1再次缓慢闪烁。
- ups pico确保即使通电也能继续录制 丢失(例如在车祸中)
将视频文件从PidashCam同步到其他PC/Mac
- 在后台,resilio sync监视包含
H264格式的视频文件。如果PI连接到我家Wi-Fi,
resilio将文件夹的内容同步到家中的mac。
- 如果电源关闭(例如点火开关关闭)和PI
连接到Wi-Fi,连接的UPS使PI长时间通电
足以让视频文件同步到我的Mac。然后关闭
圆周率优雅地下降。
- 在Mac上,Hazel正在监视同步文件夹。当它看到H264
格式文件出现,它将它们移动到另一个非同步文件夹
使用ffmpeg将它们转换为mpeg4。通过将视频移动到另一个
文件夹中,将保留PI上的有限磁盘空间。
pidashcam代码概述
代码包含一个已安装的系统守护进程,它有四个线程:1。主要 螺纹2.根据需要启动的计时器线程3。摄像机线4. GPS线程
有中断程序来处理这两个按钮。
还有一些事件用于管理与线程之间的通信
伪代码
Button A interrupt handler (notable event) Start Timer thread set flushBuffer flag on timeout Button B interrupt handler (toggle recording) If we are recording flush the buffer immediately clear the recording flag Else set the recording flag EndIf Camera thread While shutdown flag is not set While recording flag is set Initialise Camera start recording into buffer While recording flag is set - inner recording loop update annotation with current date-time, position and speed If flushBuffer is set flush buffer to new file EndIf EndWhile wait for 1 second EndWhile Exit GPS Thread Initialise connection to gpsd While shutdown flag is not set add current GPS fix to inter-thread queue Exit Power failure Start Timer thread set shutdown Event on timeout Main thread Set the record flag Kick off Camera thread Kick off GPS thread While shutdown flag is not set wait for 1 second While LAN is connected and there are videos in the sync folder wait for 1 second Kill threads Initiate system shutdown Exit