覆盆子皮仪表盘摄像机

pidashcam的Python项目详细描述


使用Raspberry PI提供仪表盘功能的Python包。

先决条件

  • 各种标准库
  • Python照相机
  • Python GPS
  • python-rpi.gpio

硬件

  • 覆盆子皮(我用的是B+型)
  • 覆盆子皮摄像头模块v2
  • Adafruit Ultimate GPS转接板使用GPIO上的UART连接 14和15
  • 带450mAh电池的UPS Pico ModMyPi。Pico使用GPIO 22和27
  • pi摄像机hdmi扩展器来自Tindie
  • 两个瞬时按钮
    • 按钮A使用GPIO 23
    • 按钮B使用GPIO 24
  • 一个LED
    • LED1使用GPIO 16

功能概述

  • 启动时,相机开始录制到内存缓冲区中 可配置大小(默认为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

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
在Java中从本地文件系统导入文件   spring boot如何在Java SpringBoot项目中集成Olingo(Odata)   java查找连续数组中缺少的第k个元素(超过时间限制)   java为什么在mySql中插入1/2行时会得到2/4行   java不能在静态上下文中使用它   File Observer方法的java My onEvent()部分不起作用   java Netty NioSocketChannel在多线程写入时收到中断消息   java将文件夹与父文件夹一起复制   java我的TictaToe代码出了什么问题?如何检查已采取的措施?   java Swing JTable更新   java如何将cordinates查找为int   如何使用selenium和java在firefox中打开新的空选项卡   java Gradle构建输出Jar未运行   java没有GET/WEBINF/jsp/login的映射。jsp