cam: Add option to list camera properties
Add the '-p'|'--list-properties' option to the cam application to list the properties of a camera. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
parent
50478550e5
commit
a14b6baca9
2 changed files with 29 additions and 0 deletions
|
@ -11,6 +11,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <libcamera/libcamera.h>
|
#include <libcamera/libcamera.h>
|
||||||
|
#include <libcamera/property_ids.h>
|
||||||
|
|
||||||
#include "capture.h"
|
#include "capture.h"
|
||||||
#include "event_loop.h"
|
#include "event_loop.h"
|
||||||
|
@ -36,6 +37,7 @@ public:
|
||||||
private:
|
private:
|
||||||
int parseOptions(int argc, char *argv[]);
|
int parseOptions(int argc, char *argv[]);
|
||||||
int prepareConfig();
|
int prepareConfig();
|
||||||
|
int listProperties();
|
||||||
int infoConfiguration();
|
int infoConfiguration();
|
||||||
int run();
|
int run();
|
||||||
|
|
||||||
|
@ -180,6 +182,8 @@ int CamApp::parseOptions(int argc, char *argv[])
|
||||||
parser.addOption(OptInfo, OptionNone,
|
parser.addOption(OptInfo, OptionNone,
|
||||||
"Display information about stream(s)", "info");
|
"Display information about stream(s)", "info");
|
||||||
parser.addOption(OptList, OptionNone, "List all cameras", "list");
|
parser.addOption(OptList, OptionNone, "List all cameras", "list");
|
||||||
|
parser.addOption(OptProps, OptionNone, "List cameras properties",
|
||||||
|
"list-properties");
|
||||||
|
|
||||||
options_ = parser.parse(argc, argv);
|
options_ = parser.parse(argc, argv);
|
||||||
if (!options_.valid())
|
if (!options_.valid())
|
||||||
|
@ -268,6 +272,24 @@ int CamApp::prepareConfig()
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CamApp::listProperties()
|
||||||
|
{
|
||||||
|
if (!camera_) {
|
||||||
|
std::cout << "Cannot list properties without a camera"
|
||||||
|
<< std::endl;
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const auto &prop : camera_->properties()) {
|
||||||
|
const ControlId *id = properties::properties.at(prop.first);
|
||||||
|
const ControlValue &value = prop.second;
|
||||||
|
|
||||||
|
std::cout << "Property: " << id->name() << " = " << value.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int CamApp::infoConfiguration()
|
int CamApp::infoConfiguration()
|
||||||
{
|
{
|
||||||
if (!config_) {
|
if (!config_) {
|
||||||
|
@ -312,6 +334,12 @@ int CamApp::run()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options_.isSet(OptProps)) {
|
||||||
|
ret = listProperties();
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
if (options_.isSet(OptInfo)) {
|
if (options_.isSet(OptInfo)) {
|
||||||
ret = infoConfiguration();
|
ret = infoConfiguration();
|
||||||
if (ret)
|
if (ret)
|
||||||
|
|
|
@ -14,6 +14,7 @@ enum {
|
||||||
OptHelp = 'h',
|
OptHelp = 'h',
|
||||||
OptInfo = 'I',
|
OptInfo = 'I',
|
||||||
OptList = 'l',
|
OptList = 'l',
|
||||||
|
OptProps = 'p',
|
||||||
OptStream = 's',
|
OptStream = 's',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue