当前位置: 首页 > news >正文

树莓派 调用摄像头

环境

        树莓派3B+

        系统升级到pi os 64bit 20241119版本;使用最新的pios,利用libcamera 库,才能调用最新的一些摄像头模组imx708.

        摄像头:一代 OV5647,三代IMX708

系统配置

        OV5647默认配置可以用,

 cat /boot/firmware/config.txt
# For more options and information see
# http://rptl.io/configtxt
# Some settings may impact device functionality. See link above for details

# Uncomment some or all of these to enable the optional hardware interfaces
#dtparam=i2c_arm=on
#dtparam=i2s=on
#dtparam=spi=on

# Enable audio (loads snd_bcm2835)
dtparam=audio=on

# Additional overlays and parameters are documented
# /boot/firmware/overlays/README

# Automatically load overlays for detected cameras
camera_auto_detect=1

# Automatically load overlays for detected DSI displays
display_auto_detect=1

# Automatically load initramfs files, if found
auto_initramfs=1

# Enable DRM VC4 V3D driver
dtoverlay=vc4-kms-v3d
max_framebuffers=2

# Don't have the firmware create an initial video= setting in cmdline.txt.
# Use the kernel's default instead.
disable_fw_kms_setup=1

# Run in 64-bit mode
arm_64bit=1

# Disable compensation for displays with overscan
disable_overscan=1

# Run as fast as firmware / board allows
arm_boost=1

[cm4]
# Enable host mode on the 2711 built-in XHCI USB controller.
# This line should be removed if the legacy DWC2 controller is required
# (e.g. for USB device mode) or if USB support is not required.
otg_mode=1

[cm5]
dtoverlay=dwc2,dr_mode=host

[all]

IMX708是东莞微象摄像头

sudo nano /boot/firmware/config.txt



camera_auto_detect=1
改为
camera_auto_detect=0

最后添加
dtoverlay=imx708



sudo reboot

参考:IMX708摄像头在树莓派上操作方法_哔哩哔哩_bilibili

指令

       

libcamera-hello

这个是一个简单的“hello world" 程序,用来预览摄像头并将摄像头画面显示在屏幕上。

使用示例

libcamera-hello

拍摄一张全像素的JPEG图像

libcamera-jpeg -o test.jpg

libcamera-vid是一个视频录制程序, 默认使用的是树莓派的硬件H.264编码器。这个程序运行之后会在屏幕上显示一个预览窗口,同时将比特流编码输出到指定文件。比如,录制一个10s的视频。

libcamera-vid -t 10000 -o test.h264

如果要查看视频可以用vlc来进行播放

vlc test.h264

TCP视频流传输

可以使用TCp进行视频流传输, 树莓派端运行(server):

libcamera-vid -t 0 --inline --listen -o tcp://0.0.0.0:<port>

示例

libcamera-vid -t 0 --inline -o udp://192.168.1.101:5600

摄像头视频流显示的延迟大约几百ms

参考文档

        liecamera使用指南,参考

模板:RPi Camera libcamera Guide - Waveshare Wiki

相关文章:

  • clickhouse集群部署保姆级教程
  • C++相关数据结构的API调用
  • qemu-kvm源码解析-内存虚拟化
  • CUDA error code 201:invalid device context
  • 《灵珠觉醒:从零到算法金仙的C++修炼》卷三·天劫试炼(32)万剑归宗破妖阵 - 最长递增子序列(LIS)
  • 有哪些好用的AI视频加工创作网站
  • SpringBoot整合JPA
  • 使用 ConfigMaps 可以优化 Spring Boot应用
  • 08 | 实现版本号打印功能
  • 线索二叉树构造及遍历算法
  • Day 14: 从上到下打印二叉树
  • Android启动速度优化
  • STM32单片机FreeRTOS系统11 系统时钟节拍和时间管理,定时器组
  • 基于小波分析法的行波测距判断故障及定位故障Matlab仿真
  • std::ranges::views::split, lazy_split, std::ranges::split_view, lazy_split_view
  • vs2022用git插件重置--删除更改(--hard)后恢复删除的内容
  • 深入解析Go语言Channel:源码剖析与并发读写机制
  • 高级定时器的解码器模式
  • upload-labs-靶场(1-19关)通关攻略
  • python-leetcode 50.岛屿数量
  • 历史地理学者成一农重回母校北京大学,担任历史系教授
  • 何立峰:中方坚定支持多边主义和自由贸易,支持世贸组织在全球经济治理中发挥更大作用
  • 中美经贸高层会谈在瑞士日内瓦举行
  • 四姑娘山一游客疑因高反身亡,镇卫生院:送到时已很严重
  • 复旦相辉堂上演原创历史人物剧《王淑贞》,胡歌参演
  • 体坛联播|穆勒主场完成拜仁谢幕战,山西车队再登环塔拉力赛