rpicamera: avoid using explicit libcamera namespace

This commit is contained in:
aler9 2023-01-28 12:20:41 +01:00
parent fb78b8eca2
commit 246f1fb76c

View File

@ -19,11 +19,14 @@
using libcamera::CameraManager; using libcamera::CameraManager;
using libcamera::CameraConfiguration; using libcamera::CameraConfiguration;
using libcamera::Camera; using libcamera::Camera;
using libcamera::ColorSpace;
using libcamera::ControlList; using libcamera::ControlList;
using libcamera::FrameBufferAllocator; using libcamera::FrameBufferAllocator;
using libcamera::FrameBuffer; using libcamera::FrameBuffer;
using libcamera::PixelFormat;
using libcamera::Rectangle; using libcamera::Rectangle;
using libcamera::Request; using libcamera::Request;
using libcamera::Size;
using libcamera::Span; using libcamera::Span;
using libcamera::Stream; using libcamera::Stream;
using libcamera::StreamRoles; using libcamera::StreamRoles;
@ -48,8 +51,8 @@ const char *camera_get_error() {
} }
// https://github.com/raspberrypi/libcamera-apps/blob/dd97618a25523c2c4aa58f87af5f23e49aa6069c/core/libcamera_app.cpp#L42 // https://github.com/raspberrypi/libcamera-apps/blob/dd97618a25523c2c4aa58f87af5f23e49aa6069c/core/libcamera_app.cpp#L42
static libcamera::PixelFormat mode_to_pixel_format(sensor_mode_t *mode) { static PixelFormat mode_to_pixel_format(sensor_mode_t *mode) {
static std::vector<std::pair<std::pair<int, bool>, libcamera::PixelFormat>> table = { static std::vector<std::pair<std::pair<int, bool>, PixelFormat>> table = {
{ {8, false}, formats::SBGGR8 }, { {8, false}, formats::SBGGR8 },
{ {8, true}, formats::SBGGR8 }, { {8, true}, formats::SBGGR8 },
{ {10, false}, formats::SBGGR10 }, { {10, false}, formats::SBGGR10 },
@ -77,8 +80,8 @@ struct CameraPriv {
std::vector<std::unique_ptr<Request>> requests; std::vector<std::unique_ptr<Request>> requests;
}; };
static int get_v4l2_colorspace(std::optional<libcamera::ColorSpace> const &cs) { static int get_v4l2_colorspace(std::optional<ColorSpace> const &cs) {
if (cs == libcamera::ColorSpace::Rec709) { if (cs == ColorSpace::Rec709) {
return V4L2_COLORSPACE_REC709; return V4L2_COLORSPACE_REC709;
} }
return V4L2_COLORSPACE_SMPTE170M; return V4L2_COLORSPACE_SMPTE170M;
@ -97,7 +100,7 @@ bool camera_create(parameters_t *params, camera_frame_cb frame_cb, camera_t **ca
return false; return false;
} }
std::vector<std::shared_ptr<libcamera::Camera>> cameras = camp->camera_manager->cameras(); std::vector<std::shared_ptr<Camera>> cameras = camp->camera_manager->cameras();
auto rem = std::remove_if(cameras.begin(), cameras.end(), auto rem = std::remove_if(cameras.begin(), cameras.end(),
[](auto &cam) { return cam->id().find("/usb") != std::string::npos; }); [](auto &cam) { return cam->id().find("/usb") != std::string::npos; });
cameras.erase(rem, cameras.end()); cameras.erase(rem, cameras.end());
@ -135,14 +138,14 @@ bool camera_create(parameters_t *params, camera_frame_cb frame_cb, camera_t **ca
video_stream_conf.size.width = params->width; video_stream_conf.size.width = params->width;
video_stream_conf.size.height = params->height; video_stream_conf.size.height = params->height;
if (params->width >= 1280 || params->height >= 720) { if (params->width >= 1280 || params->height >= 720) {
video_stream_conf.colorSpace = libcamera::ColorSpace::Rec709; video_stream_conf.colorSpace = ColorSpace::Rec709;
} else { } else {
video_stream_conf.colorSpace = libcamera::ColorSpace::Smpte170m; video_stream_conf.colorSpace = ColorSpace::Smpte170m;
} }
if (params->mode != NULL) { if (params->mode != NULL) {
StreamConfiguration &raw_stream_conf = conf->at(1); StreamConfiguration &raw_stream_conf = conf->at(1);
raw_stream_conf.size = libcamera::Size(params->mode->width, params->mode->height); raw_stream_conf.size = Size(params->mode->width, params->mode->height);
raw_stream_conf.pixelFormat = mode_to_pixel_format(params->mode); raw_stream_conf.pixelFormat = mode_to_pixel_format(params->mode);
raw_stream_conf.bufferCount = video_stream_conf.bufferCount; raw_stream_conf.bufferCount = video_stream_conf.bufferCount;
} }