mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-14 16:09:51 +03:00
cam: Print user-friendly camera names
Instead of only printing the camera ID which is not intended for humans to read and parse create a more user-friendly string when printing camera names. The ID is still printed as it is one option used to select camera using the --camera option. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Umang Jain <email@uajain.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
parent
93401c036d
commit
78fcf8e17c
1 changed files with 27 additions and 1 deletions
|
@ -45,6 +45,8 @@ private:
|
||||||
int infoConfiguration();
|
int infoConfiguration();
|
||||||
int run();
|
int run();
|
||||||
|
|
||||||
|
std::string const cameraName(const Camera *camera);
|
||||||
|
|
||||||
static CamApp *app_;
|
static CamApp *app_;
|
||||||
OptionsParser::Options options_;
|
OptionsParser::Options options_;
|
||||||
CameraManager *cm_;
|
CameraManager *cm_;
|
||||||
|
@ -340,7 +342,7 @@ int CamApp::run()
|
||||||
|
|
||||||
unsigned int index = 1;
|
unsigned int index = 1;
|
||||||
for (const std::shared_ptr<Camera> &cam : cm_->cameras()) {
|
for (const std::shared_ptr<Camera> &cam : cm_->cameras()) {
|
||||||
std::cout << index << ": " << cam->id() << std::endl;
|
std::cout << index << ": " << cameraName(cam.get()) << std::endl;
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -378,6 +380,30 @@ int CamApp::run()
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string const CamApp::cameraName(const Camera *camera)
|
||||||
|
{
|
||||||
|
const ControlList &props = camera->properties();
|
||||||
|
std::string name;
|
||||||
|
|
||||||
|
switch (props.get(properties::Location)) {
|
||||||
|
case properties::CameraLocationFront:
|
||||||
|
name = "Internal front camera";
|
||||||
|
break;
|
||||||
|
case properties::CameraLocationBack:
|
||||||
|
name = "Internal back camera";
|
||||||
|
break;
|
||||||
|
case properties::CameraLocationExternal:
|
||||||
|
name = "External camera";
|
||||||
|
if (props.contains(properties::Model))
|
||||||
|
name += " '" + props.get(properties::Model) + "'";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
name += " (" + camera->id() + ")";
|
||||||
|
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
void signalHandler([[maybe_unused]] int signal)
|
void signalHandler([[maybe_unused]] int signal)
|
||||||
{
|
{
|
||||||
std::cout << "Exiting" << std::endl;
|
std::cout << "Exiting" << std::endl;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue