mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-02-02 03:48:28 +00:00
st/gui: Add support to record from ELP 3D camera
This commit is contained in:
parent
33563ccb7e
commit
6beb57bf98
|
@ -77,6 +77,9 @@ struct record_window
|
||||||
|
|
||||||
// Use index.
|
// Use index.
|
||||||
bool index;
|
bool index;
|
||||||
|
|
||||||
|
// Use ELP.
|
||||||
|
bool elp;
|
||||||
} use;
|
} use;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
|
@ -202,9 +205,17 @@ create_pipeline(struct record_window *rw)
|
||||||
uint32_t height = rw->camera.mode.height;
|
uint32_t height = rw->camera.mode.height;
|
||||||
enum xrt_format format = rw->camera.mode.format;
|
enum xrt_format format = rw->camera.mode.format;
|
||||||
|
|
||||||
struct gstreamer_sink *gs = NULL;
|
bool do_convert = false;
|
||||||
|
if (format == XRT_FORMAT_MJPEG) {
|
||||||
|
format = XRT_FORMAT_R8G8B8;
|
||||||
|
do_convert = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct gstreamer_sink *gs = NULL;
|
||||||
gstreamer_sink_create_with_pipeline(gp, width, height, format, source_name, &gs, &tmp);
|
gstreamer_sink_create_with_pipeline(gp, width, height, format, source_name, &gs, &tmp);
|
||||||
|
if (do_convert) {
|
||||||
|
u_sink_create_to_r8g8b8_or_l8(&rw->gst.xfctx, tmp, &tmp);
|
||||||
|
}
|
||||||
u_sink_queue_create(&rw->gst.xfctx, tmp, &tmp);
|
u_sink_queue_create(&rw->gst.xfctx, tmp, &tmp);
|
||||||
|
|
||||||
os_mutex_lock(&rw->gst.mutex);
|
os_mutex_lock(&rw->gst.mutex);
|
||||||
|
@ -381,10 +392,11 @@ window_create(struct gui_program *p, const char *camera)
|
||||||
rw->use.index = camera == NULL ? false : strcmp(camera, "index") == 0;
|
rw->use.index = camera == NULL ? false : strcmp(camera, "index") == 0;
|
||||||
rw->use.leap_motion = camera == NULL ? false : strcmp(camera, "leap_motion") == 0;
|
rw->use.leap_motion = camera == NULL ? false : strcmp(camera, "leap_motion") == 0;
|
||||||
rw->use.depthai = camera == NULL ? false : strcmp(camera, "depthai") == 0;
|
rw->use.depthai = camera == NULL ? false : strcmp(camera, "depthai") == 0;
|
||||||
|
rw->use.elp = camera == NULL ? false : strcmp(camera, "elp") == 0;
|
||||||
|
|
||||||
if (!rw->use.index && !rw->use.leap_motion && !rw->use.depthai) {
|
if (!rw->use.index && !rw->use.leap_motion && !rw->use.depthai && !rw->use.elp) {
|
||||||
U_LOG_W(
|
U_LOG_W(
|
||||||
"Can't recongnize camera name '%s', options are 'depthai', index' & 'leap_motion'."
|
"Can't recongnize camera name '%s', options are 'elp', depthai', index' & 'leap_motion'."
|
||||||
"\n\tFalling back to 'index'.",
|
"\n\tFalling back to 'index'.",
|
||||||
camera);
|
camera);
|
||||||
rw->use.index = true;
|
rw->use.index = true;
|
||||||
|
@ -506,6 +518,13 @@ create_videotestsrc(struct record_window *rw)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
static bool
|
||||||
|
is_camera_elp(const char *product, const char *manufacturer)
|
||||||
|
{
|
||||||
|
return strcmp(product, "3D USB Camera") == 0 && strcmp(manufacturer, "3D USB Camera") == 0;
|
||||||
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
is_camera_index(const char *product, const char *manufacturer)
|
is_camera_index(const char *product, const char *manufacturer)
|
||||||
{
|
{
|
||||||
|
@ -532,6 +551,12 @@ on_video_device(struct xrt_prober *xp,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Hardcoded for the Index.
|
||||||
|
if (rw->use.elp && !is_camera_elp(product, manufacturer)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Hardcoded for the Index.
|
// Hardcoded for the Index.
|
||||||
if (rw->use.index && !is_camera_index(product, manufacturer)) {
|
if (rw->use.index && !is_camera_index(product, manufacturer)) {
|
||||||
return;
|
return;
|
||||||
|
@ -553,6 +578,9 @@ on_video_device(struct xrt_prober *xp,
|
||||||
u_sink_deinterleaver_create(&rw->camera.xfctx, tmp, &tmp);
|
u_sink_deinterleaver_create(&rw->camera.xfctx, tmp, &tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Just use the first one.
|
||||||
|
uint32_t mode_index = 0;
|
||||||
|
|
||||||
// Just after the camera create a quirk stream.
|
// Just after the camera create a quirk stream.
|
||||||
struct u_sink_quirk_params qp;
|
struct u_sink_quirk_params qp;
|
||||||
U_ZERO(&qp);
|
U_ZERO(&qp);
|
||||||
|
@ -560,6 +588,12 @@ on_video_device(struct xrt_prober *xp,
|
||||||
qp.ps4_cam = false;
|
qp.ps4_cam = false;
|
||||||
qp.leap_motion = rw->use.leap_motion;
|
qp.leap_motion = rw->use.leap_motion;
|
||||||
|
|
||||||
|
// Tweaks for the ELP camera.
|
||||||
|
if (rw->use.elp) {
|
||||||
|
qp.stereo_sbs = true;
|
||||||
|
mode_index = 2;
|
||||||
|
}
|
||||||
|
|
||||||
u_sink_quirk_create(&rw->camera.xfctx, tmp, &qp, &tmp);
|
u_sink_quirk_create(&rw->camera.xfctx, tmp, &qp, &tmp);
|
||||||
|
|
||||||
struct xrt_fs_mode *modes = NULL;
|
struct xrt_fs_mode *modes = NULL;
|
||||||
|
@ -567,9 +601,6 @@ on_video_device(struct xrt_prober *xp,
|
||||||
xrt_fs_enumerate_modes(rw->camera.xfs, &modes, &mode_count);
|
xrt_fs_enumerate_modes(rw->camera.xfs, &modes, &mode_count);
|
||||||
assert(mode_count > 0);
|
assert(mode_count > 0);
|
||||||
|
|
||||||
// Just use the first one.
|
|
||||||
uint32_t mode_index = 0;
|
|
||||||
|
|
||||||
rw->camera.mode = modes[mode_index];
|
rw->camera.mode = modes[mode_index];
|
||||||
free(modes);
|
free(modes);
|
||||||
modes = NULL;
|
modes = NULL;
|
||||||
|
|
Loading…
Reference in a new issue