Raspbian安装摄像头

1. 源由

家里闲置两块树莓派,打算做个WiFi视频流RTSP/RTP:

  • Raspberry Pi Zero W
  • Raspberry Pi 3B+

注:后续打算上天,帮我在模拟航模上拍点高清视频。

2. 摄像头

2.1 选型

本来想上一个热成像摄像头,看看夜景,奈何并非这么简单,而且价格也高。就不整那个玩意了。

大白天,我们选了两款:

  • 鱼眼 OV5647 130° 1.85mm 非夜视
    在这里插入图片描述

  • 树莓派原装 V2 IMX219 NoIR
    在这里插入图片描述

2.2 系统

妥妥的原生态系统bullseye,目前来说,兼容性是比较好的。系统安装参考:Raspbian镜像无头烧录

注:如果想使用其他系统,可以访问:raspios_lite_arm64

2.3 安装

  • Raspberry Pi Zero W
    在这里插入图片描述

  • Raspberry Pi 3B+
    在这里插入图片描述

3. 配置&命令

3.1 命令

新系统已经不支持raspistillraspivid了,更多用的是libcamera

$ libcamera-
libcamera-hello  libcamera-jpeg   libcamera-raw    libcamera-still  libcamera-vid
  1. libcamera-hello: 一个简单的“ Hello World”应用程序,该应用程序启动了相机预览流并在屏幕上显示。
  2. libcamera-jpeg: 一个简单的应用程序来运行预览窗口,然后捕获高分辨率静止图像。
  3. libcamera-still: 更复杂的静止图像捕获应用程序,该应用程序模拟了Raspistill的更多特征。
  4. libcamera-vid: 视频捕获应用程序。
  5. libcamera-raw: 直接从传感器捕获原始(未加工的拜耳)框架的基本应用程序。

注:以前raspistill: command not found命令已经被逐渐淘汰,详见:raspios_armhf/release_notes.txt

2021-10-30:

  • New default camera subsystem based on libcamera
  • New camera demo applications (libcamera-still and libcamera-vid) have replaced raspistill and raspivid
  • Legacy camera subsystem removed from 64-bit RPi OS (still available on 32-bit)

3.2 配置

$ sudo nano /boot/config.txt
  • Step 1:将camera-auto-detect=1修改camera_auto_detect=0

  • Step 2:根据摄像头不同型号,添加dtoverlay驱动设置到/boot/config.txt文件中。

鱼眼 OV5647 130° 1.85mm 非夜视:dtoverlay=ov5647
树莓派原装 V2 IMX219 NoIR:dtoverlay=imx219

在这里插入图片描述

4. 测试

4.1 拍照

拍照正常,基本驱动应该就正常了,详细的指令可以参考:Pi5-IMX219, www.waveshare.com

4.1.1 libcamera-jpeg

  • 全像素JPEG拍照:
$ libcamera-jpeg -o test.jpg
  • 指定宽度高度拍照:
$ libcamera-jpeg -o test.jpg -t 2000 --width 640 --height 480
  • 指定曝光和增益拍照:// exposure 20ms, gain 1.5x
$ libcamera-jpeg -o test.jpg -t 2000 --shutter 20000 --gain 1.5
  • 指定EV补偿拍照:
$ libcamera-jpeg --ev -0.5 -o darker.jpg
$ libcamera-jpeg --ev 0 -o normal.jpg
$ libcamera-jpeg --ev 0.5 -o brighter.jpg

4.1.2 libcamera-still

  • 测试命令:
$ libcamera-still -o test.jpg
  • 不同编码格式拍照:
$ libcamera-still -e png -o test.png
$ libcamera-still -e bmp -o test.bmp
$ libcamera-still -e rgb -o test.data
$ libcamera-still -e yuv420 -o test.data
  • 原始数据保存:
$ libcamera-still -r -o test.jpg
  • 长时间曝光拍照:
$ libcamera-still -o long_exposure.jpg --shutter 100000000 --gain 1 --awbgains 1,1 --immediate

在这里插入图片描述

4.2 视频流

  • Step 1:安装vlc组件
$ sudo apt-get install vlc

4.2.1 RTSP流

  • Step 2:启动rtsp服务端
$ libcamera-vid -t 0 --inline -o - | cvlc stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8554/stream1}' :demux=h264
  • Step 3:启动VLC播放器

在这里插入图片描述

rtsp://192.168.1.201:8554/stream1
  • Step 4:确认结果

在这里插入图片描述

4.2.2 TCP流

  • Step 2:启动TCP服务端
$ libcamera-vid -t 0 --inline --listen -o tcp://0.0.0.0:8554
  • Step 3:启动VLC播放器

在这里插入图片描述

tcp/h264://192.168.1.201:8554
  • Step 4:确认结果

在这里插入图片描述

5. 参考资料

【1】Raspbian镜像无头烧录
【2】Pi5-IMX219, www.waveshare.com
【3】Introducing the Raspberry Pi Cameras

相关推荐

  1. [树莓派]树莓派Raspbian系统安装tesseract-ocr实现OCR

    2024-01-13 22:50:08       13 阅读
  2. Raspbian简易RTSP服务

    2024-01-13 22:50:08       31 阅读

最近更新

  1. tensorflow学习笔记(二)

    2024-01-13 22:50:08       0 阅读
  2. Typescript【网址取ID传入后端API】

    2024-01-13 22:50:08       0 阅读
  3. mongodb-数据备份和恢复

    2024-01-13 22:50:08       0 阅读
  4. 《C++20设计模式》中单例模式

    2024-01-13 22:50:08       1 阅读
  5. 数字孪生技术在智能家居中的应用

    2024-01-13 22:50:08       1 阅读
  6. 单例模式的多种实现方式及其在框架中的使用

    2024-01-13 22:50:08       1 阅读
  7. 一、Prometheus和Grafana搭建

    2024-01-13 22:50:08       1 阅读

热门阅读

  1. pi i2c 读取24c256

    2024-01-13 22:50:08       43 阅读
  2. C++(20):list通过erase, erase_if删除元素

    2024-01-13 22:50:08       34 阅读
  3. 【Linux】网络版计算器代码

    2024-01-13 22:50:08       43 阅读
  4. Python 面向对象之多态

    2024-01-13 22:50:08       37 阅读
  5. 编程探秘:Python深渊之旅-----调试的艺术(四)

    2024-01-13 22:50:08       45 阅读
  6. C++入门【25-C++ 从函数返回指针】

    2024-01-13 22:50:08       41 阅读
  7. Pandas实战100例 | 案例 25: 计算相关系数

    2024-01-13 22:50:08       40 阅读
  8. SpringBoot全局配置Long转String丢失精度的问题解决

    2024-01-13 22:50:08       40 阅读