libcamera 只能在命令行上工作吗?

发布于 2025-01-11 22:09:56 字数 1161 浏览 3 评论 0原文

我最近升级到了运行 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

洋洋洒洒 2025-01-18 22:09:56

您可以使用 libcamera 作为 C++ 中的库。

我在 github 上找到了一个示例程序:
https://github.com/kbingham/simple-cam/ blob/master/simple-cam.cpp

#include <libcamera/libcamera.h>

using namespace libcamera;

int main()
{
    std::unique_ptr<CameraManager> cm = std::make_unique<CameraManager>();
    cm->start();
    ...
    ...
    cm->stop();
    return EXIT_SUCCESS;
}

是我认为您正在寻找的代码。

此外,可以在此处找到文档:
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

#include <libcamera/libcamera.h>

using namespace libcamera;

int main()
{
    std::unique_ptr<CameraManager> cm = std::make_unique<CameraManager>();
    cm->start();
    ...
    ...
    cm->stop();
    return EXIT_SUCCESS;
}

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文