|
|
|
@ -19,11 +19,14 @@
@@ -19,11 +19,14 @@
|
|
|
|
|
using libcamera::CameraManager; |
|
|
|
|
using libcamera::CameraConfiguration; |
|
|
|
|
using libcamera::Camera; |
|
|
|
|
using libcamera::ColorSpace; |
|
|
|
|
using libcamera::ControlList; |
|
|
|
|
using libcamera::FrameBufferAllocator; |
|
|
|
|
using libcamera::FrameBuffer; |
|
|
|
|
using libcamera::PixelFormat; |
|
|
|
|
using libcamera::Rectangle; |
|
|
|
|
using libcamera::Request; |
|
|
|
|
using libcamera::Size; |
|
|
|
|
using libcamera::Span; |
|
|
|
|
using libcamera::Stream; |
|
|
|
|
using libcamera::StreamRoles; |
|
|
|
@ -48,8 +51,8 @@ const char *camera_get_error() {
@@ -48,8 +51,8 @@ const char *camera_get_error() {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 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 std::vector<std::pair<std::pair<int, bool>, libcamera::PixelFormat>> table = { |
|
|
|
|
static PixelFormat mode_to_pixel_format(sensor_mode_t *mode) { |
|
|
|
|
static std::vector<std::pair<std::pair<int, bool>, PixelFormat>> table = { |
|
|
|
|
{ {8, false}, formats::SBGGR8 }, |
|
|
|
|
{ {8, true}, formats::SBGGR8 }, |
|
|
|
|
{ {10, false}, formats::SBGGR10 }, |
|
|
|
@ -77,8 +80,8 @@ struct CameraPriv {
@@ -77,8 +80,8 @@ struct CameraPriv {
|
|
|
|
|
std::vector<std::unique_ptr<Request>> requests; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
static int get_v4l2_colorspace(std::optional<libcamera::ColorSpace> const &cs) { |
|
|
|
|
if (cs == libcamera::ColorSpace::Rec709) { |
|
|
|
|
static int get_v4l2_colorspace(std::optional<ColorSpace> const &cs) { |
|
|
|
|
if (cs == ColorSpace::Rec709) { |
|
|
|
|
return V4L2_COLORSPACE_REC709; |
|
|
|
|
} |
|
|
|
|
return V4L2_COLORSPACE_SMPTE170M; |
|
|
|
@ -97,7 +100,7 @@ bool camera_create(parameters_t *params, camera_frame_cb frame_cb, camera_t **ca
@@ -97,7 +100,7 @@ bool camera_create(parameters_t *params, camera_frame_cb frame_cb, camera_t **ca
|
|
|
|
|
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 &cam) { return cam->id().find("/usb") != std::string::npos; }); |
|
|
|
|
cameras.erase(rem, cameras.end()); |
|
|
|
@ -135,14 +138,14 @@ bool camera_create(parameters_t *params, camera_frame_cb frame_cb, camera_t **ca
@@ -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.height = params->height; |
|
|
|
|
if (params->width >= 1280 || params->height >= 720) { |
|
|
|
|
video_stream_conf.colorSpace = libcamera::ColorSpace::Rec709; |
|
|
|
|
video_stream_conf.colorSpace = ColorSpace::Rec709; |
|
|
|
|
} else { |
|
|
|
|
video_stream_conf.colorSpace = libcamera::ColorSpace::Smpte170m; |
|
|
|
|
video_stream_conf.colorSpace = ColorSpace::Smpte170m; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (params->mode != NULL) { |
|
|
|
|
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.bufferCount = video_stream_conf.bufferCount; |
|
|
|
|
} |
|
|
|
|