Код: Выделить всё
static void world_frame_callback(libcamera::Request *request) {
// Determine if we have received invalid image data (e.g. during application shutdown)
if (request->status() == libcamera::Request::RequestCancelled) {return;}
// Define a variable to hold the arguments passed to the callback function
world_callback_data* data;
// There should be a single buffer per capture
const libcamera::Request::BufferMap &buffers = request->buffers();
auto buffer_pair = *buffers.begin();
// (Unused) Stream *stream = bufferPair.first;
libcamera::FrameBuffer *buffer = buffer_pair.second;
// Capture the metadata of this frame. This lets us know if a frame was successfully captured and also
// the frame sequence number. Gaps in the sequence number indicate dropped frames
const libcamera::FrameMetadata &metadata = buffer->metadata();
// Check if the frame was captured without any sort of error
if(metadata.status != libcamera::FrameMetadata::Status::FrameSuccess) {
std::cout planes().front();
void *memory_map = mmap(nullptr, pixel_data_plane.length, PROT_READ, MAP_SHARED, pixel_data_plane.fd.get(), pixel_data_plane.offset);
if (memory_map == MAP_FAILED) {
std::cout data() + data->buffer_offset, pixel_data, pixel_data_plane.length);
}
Код: Выделить всё
// Retrieve the first available camera from the manager to be the world camera
camera = cm->get(cameras[0]->id());
// Acquire the camera
camera->acquire();
// Define the configuration for the camera (this MUST be raw for raw images)
std::unique_ptr config = camera->generateConfiguration( { libcamera::StreamRole::Raw} );
libcamera::StreamConfiguration &streamConfig = config->at(0);
streamConfig.pixelFormat = libcamera::formats::SRGGB8;
streamConfig.size.width = 640;
streamConfig.size.height = 480;
if (config->validate() == libcamera::CameraConfiguration::Invalid) {
std::cerr
Подробнее здесь: [url]https://stackoverflow.com/questions/79390774/libcamera-explanation-for-slightly-changing-pattern-of-constantly-black-null[/url]
Мобильная версия