Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4495

Camera board • How do I use libcamera's AE properly?

$
0
0
I am using libcamera for my C++ application to capture still frames via Raspberry Pi High Definition camera. This is how I configure it:

Code:

std::unique_ptr<lc::CameraConfiguration> cameraConfig = camera->generateConfiguration({ lc::StreamRole::StillCapture });lc::StreamConfiguration& streamConfig = cameraConfig->at(0);streamConfig.size.width = 4056;streamConfig.size.height = 3040;streamConfig.pixelFormat = lc::formats::BGR888;cameraConfig->validate();
And this is how I capture the frames:

Code:

Camera::Image Camera::capture(){    /* m_camera->start(); already called */    std::unique_lock lock(m_mutex);    std::unique_ptr<lc::Request> request = m_camera->createRequest();    lc::Stream* stream = m_cameraConfig->at(0).stream();    request->addBuffer(stream, m_allocator->buffers(stream).at(0).get());        Image image;    m_image = &image;    m_camera->queueRequest(request.get());    m_cv.wait(lock); // Wait for the capture to finish    m_image = nullptr;    return image;}
This works fine for daylight captures, but at night it is litteraly a black screen. I tried setting exposure manually and I know that the camera is able to capture good images with just 1s of exposure. I noticed that AWB starts making nice corrections for reqeusts after the first one, but AE doesn't seem to be doing anything at all.
This:

Code:

lc::ControlList& controls = request->controls();bool aeEnabled = *controls.get(lc::controls::AeEnable);uint32_t exposure = *controls.get(lc::controls::ExposureTime);std::cerr << "AeEnabled: " << aeEnabled << '\n';std::cerr << "Exposure: " << exposure / 1'000'000.0 << "s\n";
Outputs:

Code:

AeEnabled: 156 // << A bool is 156?Exposure: 0.001024s
every time I call the function.
I tried to search for guides for this, but couldn't find anything. What am I doing wrong here?

Statistics: Posted by KontraBob — Sat Oct 19, 2024 8:47 am — Replies 0 — Views 4



Viewing all articles
Browse latest Browse all 4495

Trending Articles