mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-17 17:35:06 +03:00
cam: Add --info option to print information about stream(s)
Add a new option to the cam tool that prints information about the configuration supplied by the user. If the option is specified, information about the configuration is printed after the configuration has been verified and possibly adjusted by the camera. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
parent
7c856201c7
commit
802d47068b
2 changed files with 43 additions and 0 deletions
|
@ -5,6 +5,7 @@
|
||||||
* main.cpp - cam - The libcamera swiss army knife
|
* main.cpp - cam - The libcamera swiss army knife
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <iomanip>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -34,6 +35,7 @@ public:
|
||||||
private:
|
private:
|
||||||
int parseOptions(int argc, char *argv[]);
|
int parseOptions(int argc, char *argv[]);
|
||||||
int prepareConfig();
|
int prepareConfig();
|
||||||
|
int infoConfiguration();
|
||||||
int run();
|
int run();
|
||||||
|
|
||||||
static CamApp *app_;
|
static CamApp *app_;
|
||||||
|
@ -169,6 +171,8 @@ int CamApp::parseOptions(int argc, char *argv[])
|
||||||
"Set configuration of a camera stream", "stream", true);
|
"Set configuration of a camera stream", "stream", true);
|
||||||
parser.addOption(OptHelp, OptionNone, "Display this help message",
|
parser.addOption(OptHelp, OptionNone, "Display this help message",
|
||||||
"help");
|
"help");
|
||||||
|
parser.addOption(OptInfo, OptionNone,
|
||||||
|
"Display information about stream(s)", "info");
|
||||||
parser.addOption(OptList, OptionNone, "List all cameras", "list");
|
parser.addOption(OptList, OptionNone, "List all cameras", "list");
|
||||||
|
|
||||||
options_ = parser.parse(argc, argv);
|
options_ = parser.parse(argc, argv);
|
||||||
|
@ -258,8 +262,40 @@ int CamApp::prepareConfig()
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CamApp::infoConfiguration()
|
||||||
|
{
|
||||||
|
if (!config_) {
|
||||||
|
std::cout << "Cannot print stream information without a camera"
|
||||||
|
<< std::endl;
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int index = 0;
|
||||||
|
for (const StreamConfiguration &cfg : *config_) {
|
||||||
|
std::cout << index << ": " << cfg.toString() << std::endl;
|
||||||
|
|
||||||
|
const StreamFormats &formats = cfg.formats();
|
||||||
|
for (unsigned int pixelformat : formats.pixelformats()) {
|
||||||
|
std::cout << " * Pixelformat: 0x" << std::hex
|
||||||
|
<< std::setw(8) << pixelformat << " "
|
||||||
|
<< formats.range(pixelformat).toString()
|
||||||
|
<< std::endl;
|
||||||
|
|
||||||
|
for (const Size &size : formats.sizes(pixelformat))
|
||||||
|
std::cout << " - " << size.toString()
|
||||||
|
<< std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int CamApp::run()
|
int CamApp::run()
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (options_.isSet(OptList)) {
|
if (options_.isSet(OptList)) {
|
||||||
std::cout << "Available cameras:" << std::endl;
|
std::cout << "Available cameras:" << std::endl;
|
||||||
|
|
||||||
|
@ -270,6 +306,12 @@ int CamApp::run()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options_.isSet(OptInfo)) {
|
||||||
|
ret = infoConfiguration();
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
if (options_.isSet(OptCapture)) {
|
if (options_.isSet(OptCapture)) {
|
||||||
Capture capture(camera_.get(), config_.get());
|
Capture capture(camera_.get(), config_.get());
|
||||||
return capture.run(loop_, options_);
|
return capture.run(loop_, options_);
|
||||||
|
|
|
@ -12,6 +12,7 @@ enum {
|
||||||
OptCapture = 'C',
|
OptCapture = 'C',
|
||||||
OptFile = 'F',
|
OptFile = 'F',
|
||||||
OptHelp = 'h',
|
OptHelp = 'h',
|
||||||
|
OptInfo = 'I',
|
||||||
OptList = 'l',
|
OptList = 'l',
|
||||||
OptStream = 's',
|
OptStream = 's',
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue