RBP as a streaming server(一)

本文介绍了Raspberry Pi摄像头模块的安装方法及使用技巧,包括如何通过命令行工具raspistill和raspivid捕获静态图片和录制视频,并提供了一些示例命令。此外,还介绍了一种无需依赖OpenCV即可实现视频流传输的方法。

1. Raspberry Pi camera software

一旦安装好Pi摄像头,RBP的开发者们提供了两个简单但强大的命令行工具,用来直接对摄像头获取的图像或视频流进行保存或分流

raspivid is a command line application that allows you to capture video with the camera module

raspistill allows you to capture images


Example Commands

 (http://www.raspberrypi.org/archives/3890)

Capture an image in jpeg format:

raspistill -o image.jpg

Capture a 5s video in h264 format:

raspivid -o video.h264

Capture a 10s video:

raspivid -o video.h264 -t 10000

Capture a 10s video in demo mode:

raspivid -o video.h264 -t 10000 -d

To see a list of possible options for running raspivid orraspistill, you can run:

raspivid | less

raspistill | less


How to install the Raspberry Pi camera module

http://www.techradar.com/news/computing-components/peripherals/how-to-install-the-raspberry-pi-camera-module-1172034

Display a five-second demo: raspivid -d
Display a 640x480 preview: raspivid -p 0,0,640,480
Capture 20s of h264 video: raspivid -t 20000 -o video.h264
Take a 640x480 shot: raspistill -o image.jpg -w 640 -h 480
Take a reduced quality JPEG: raspistill -o image.jpg -q 5


2. Streaming video in RBP native way (Without OpenCV)

RBP的作者们还演示了一种通过网络stream视频流的方式。
在Pi上需要用到raspivid和netcat
raspivid -t 999999 -o – | nc [insert the IP address of the client] 5001


在客户端(包括Linux, Windows和Mac)运行netcat和mplayer即可。比如Linux下只要:
nc -l -p 5001 | mplayer -fps 31 -cache 1024 -


但我如果运行上面命令则直接退出,

libavformat version 53.21.1 (external)
Mismatching header version 53.19.0

Exiting... (End of file)

运行
nc.traditional -l -p 5001 | mplayer -fps 31 -cache 1024 -

就一切正常。


### rbp寄存器在x86架构中的作用及使用场景 #### 基本定义与功能 rbp(Base Pointer 或 Frame Pointer)是个重要的寄存器,在x86/x64架构中用于指向当前堆栈帧的基地址[^1]。它的主要用途是在函数调用过程中帮助维护堆栈结构并提供种机制来访问局部变量和函数参数。 #### 使用场景分析 当程序执行到某个函数时,通常会在堆栈上创建个新的堆栈帧以存储该函数的相关数据,包括局部变量、返回地址以及可能被覆盖的寄存器值等。此时,rsp(Stack Pointer)会动态变化以反映堆栈顶部的位置,而rbp则保持固定不变,作为基准点方便计算偏移量从而定位所需的数据项[^2]。 具体来说,在进入个新函数之前,处理器先将旧的rbp值压入堆栈保存起来;接着把当前rsp赋给rbp,这样就建立了新的堆栈框架基础位置标记。之后每当需要访问特定于这个层次上的对象比如形参或者自动变量的时候就可以通过相对固定的rbp加上适当位移得到确切内存单元地址而不是依赖随时变动着的rsp来进行复杂运算得出目标所在处所了。 另外值得注意的是,在某些优化编译选项下为了节省条额外使用的寄存器资源可能会让编译器选择不保留frame pointer即省略掉设置rbp步骤而是单纯依靠调整后的rsp完成同样工作——尽管如此做法虽然能够稍微提升性能但却牺牲了些调试便利性和可读性因此般仅限于release版本而非debug模式采用这种策略。 ```assembly push rbp ; Save the old base pointer on stack. mov rbp, rsp ; Set new base pointer to current SP. sub rsp, 0x20 ; Allocate space for local variables (e.g., allocate 32 bytes). ; Accessing a local variable at offset -8 from RBP. mov qword ptr [rbp-8], 42 ; Store value '42' into one of our locals. add rsp, 0x20 ; Deallocate local vars before returning. pop rbp ; Restore caller's base pointer. ret ; Return control back to calling function. ``` 上述汇编代码片段展示了如何利用rbp建立函数堆栈帧,并展示了个简单的例子说明怎样基于rbp操作本地变量。 #### 总结 综上所述,rbp寄存器对于维持清晰有序的子例程间通信至关重要,尤其是在多层嵌套调用情况下提供了稳定可靠的参照系使得开发者可以更加直观便捷地追踪各阶段内的状态信息。即使现代高级语言抽象掉了大部分底层细节,理解这类基本原理仍然有助于深入掌握计算机体系结构知识。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值