libcamera 只能在命令行上工作吗?
我最近升级到了运行 Bullseye 的 Pi 4,并了解了如何切换到 libcamera。我从未使用过这个库,所以请原谅这可能是一个明显的问题。有没有一种方法可以像程序中的 picamera 一样运行 libcamera(该库正在作为 picamera 的替代品而推出)?
例如,以下是来自 https://picamera 的代码片段。 readthedocs.io/en/release-1.13/recipes2.html#web-streaming:
with picamera.PiCamera(resolution='640x480', framerate=24) as camera:
output = StreamingOutput()
camera.start_recording(output, format='mjpeg')
try:
address = ('', 8000)
server = StreamingServer(address, StreamingHandler)
server.serve_forever()
finally:
camera.stop_recording()
我知道目前 libcamera 没有官方的 Python 包装器,但是有吗相当于 Python 或其他语言中的 'picamera.PiCamera(...)' 声明/实例化?我能找到的调用 libcamera 的唯一示例来自命令行或 bash 脚本。我正在寻找一种以与 picamera 相同的方式将 libcamera 库合并到程序中的方法。编程语言并不重要。
我在官方文档中看到了启用旧相机并使用 picamera 库的解决方法: https://www.raspberrypi.com/documentation/accessories/camera.html 。我对遗留选项不感兴趣,但如果有必要的话我会使用它们,因为这是一个小型的个人学习项目。
I've upgraded to a Pi 4 running Bullseye recently and learned about the switch to libcamera. I have never used this library, so please excuse what is probably an obvious question. Is there a way to run libcamera, the library that is being pushed as a replacement for picamera, in the same way as picamera within a program?
For example, here's a code snippit from https://picamera.readthedocs.io/en/release-1.13/recipes2.html#web-streaming:
with picamera.PiCamera(resolution='640x480', framerate=24) as camera:
output = StreamingOutput()
camera.start_recording(output, format='mjpeg')
try:
address = ('', 8000)
server = StreamingServer(address, StreamingHandler)
server.serve_forever()
finally:
camera.stop_recording()
I understand there's no official Python wrappers for libcamera right now, but is there some equivalent to the 'picamera.PiCamera(...)' declaration/instantiation in either Python or another language? The only examples I can find of calls to libcamera are from the command line, or from a bash script. I'm looking for a way to incorporate the libcamera library into a program in the same way as picamera. The programming language doesn't matter.
I've seen the workaround for enabling the legacy camera and using the picamera library in the official docs here: https://www.raspberrypi.com/documentation/accessories/camera.html . I'm not interested in the legacy options, but will use them if I have to because this is for a small, personal learning project.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 libcamera 作为 C++ 中的库。
我在 github 上找到了一个示例程序:
https://github.com/kbingham/simple-cam/ blob/master/simple-cam.cpp
是我认为您正在寻找的代码。
此外,可以在此处找到文档:
https://libcamera.org/api-html/namespacelibcamera.html
希望这有帮助你和你的项目。
You can use libcamera as a library in c++.
I was able to find an example program on github here:
https://github.com/kbingham/simple-cam/blob/master/simple-cam.cpp
is the sort of code I think you're looking for.
Additionally the documentation can be found here:
https://libcamera.org/api-html/namespacelibcamera.html
Hopefully this helps you with your project.