Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: Use CompletedRequestPtr in the FrameInfo constructor #666

Merged
merged 1 commit into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/rpicam_still.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ static void event_loop(RPiCamStillApp &app)

if (af_wait_state != AF_WAIT_NONE)
{
FrameInfo fi(completed_request->metadata);
FrameInfo fi(completed_request);
bool scanning = fi.af_state == libcamera::controls::AfStateScanning;
if (scanning || (af_wait_state == AF_WAIT_SCANNING && ++af_wait_timeout >= 16))
af_wait_state = AF_WAIT_FINISHED;
Expand Down
11 changes: 9 additions & 2 deletions core/frame_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,19 @@
#include <libcamera/control_ids.h>
#include <libcamera/controls.h>

#include "completed_request.hpp"

struct FrameInfo
{
FrameInfo(libcamera::ControlList &ctrls)
FrameInfo(const CompletedRequestPtr &completed_request)
: exposure_time(0.0), digital_gain(0.0), colour_gains({ { 0.0f, 0.0f } }), focus(0.0), aelock(false),
lens_position(-1.0), af_state(0)
{
const libcamera::ControlList &ctrls = completed_request->metadata;

sequence = completed_request->sequence;
fps = completed_request->framerate;

auto exp = ctrls.get(libcamera::controls::ExposureTime);
if (exp)
exposure_time = *exp;
Expand Down Expand Up @@ -53,7 +60,7 @@ struct FrameInfo
af_state = *afs;
}

std::string ToString(std::string &info_string) const
std::string ToString(const std::string &info_string) const
{
std::string parsed(info_string);

Expand Down
4 changes: 1 addition & 3 deletions core/rpicam_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1154,9 +1154,7 @@ void RPiCamApp::previewThread()
libcamera::Span span = r.Get()[0];

// Fill the frame info with the ControlList items and ancillary bits.
FrameInfo frame_info(item.completed_request->metadata);
frame_info.fps = item.completed_request->framerate;
frame_info.sequence = item.completed_request->sequence;
FrameInfo frame_info(item.completed_request);

int fd = buffer->planes()[0].fd.get();
{
Expand Down
3 changes: 1 addition & 2 deletions post_processing_stages/annotate_cv_stage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ bool AnnotateCvStage::Process(CompletedRequestPtr &completed_request)
{
BufferWriteSync w(app_, completed_request->buffers[stream_]);
libcamera::Span<uint8_t> buffer = w.Get()[0];
FrameInfo info(completed_request->metadata);
info.sequence = completed_request->sequence;
FrameInfo info(completed_request);

// Other post-processing stages can supply metadata to update the text.
completed_request->post_process_metadata.Get("annotate.text", text_);
Expand Down