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 :
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: . 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.
21 Answer
You can use libcamera as a library in c++.
I was able to find an example program on github here:
#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:
Hopefully this helps you with your project.