0

I am trying to store image frames in memory in a libcamera app on a Raspberry Pi 4b. I created a container class 'ImageData' containing image metadata and a new buffer for the frame data.

class ImageData 
{
public:
    ImageData(std::vector<libcamera::Span<uint8_t>> m, StreamInfo i, libcamera::ControlList met, std::string fil, std::string cam) :

    mem (m),
    info (i),
    metadata (met),
    filename (fil),
    cam_name (cam),
    buffer(new uint8_t[mem[0].size_bytes()]) {}
        
    ~ImageData() {delete[] buffer;}
    
    std::vector<libcamera::Span<uint8_t>> mem;
    StreamInfo info;
    libcamera::ControlList metadata;
    std::string filename;
    std::string cam_name;
    uint8_t* buffer;
};

I create a buffer object

std::vector<ImageData> imageBuffer;

and store the information in a new ImageData instance

const std::vector<libcamera::Span<uint8_t>> mem = app.Mmap(completed_request->buffers[stream]);
                    ImageData d = ImageData(mem, info, completed_request->metadata, new_name, app.CameraId());
                    memcpy(d.buffer, mem[0].data(), mem[0].size_bytes() );
                    imageBuffer.push_back(std::move(d));

This works for a single frame but crashes with multiple frames.

I have no clue why.

0 Answers0