@@ -21,6 +21,7 @@ enum {
OptCamera = 'c',
OptHelp = 'h',
OptList = 'l',
+ OptStreamsConfig = 'C',
};
static int parseOptions(int argc, char *argv[])
@@ -32,6 +33,7 @@ static int parseOptions(int argc, char *argv[])
"camera");
parser.addOption(OptHelp, "Display this help message", "help");
parser.addOption(OptList, "List all cameras", "list");
+ parser.addOption(OptStreamsConfig, "Configure the first stream to 640x480", "hack-config");
options = std::move(parser.parse(argc, argv));
if (!options.valid())
@@ -79,6 +81,42 @@ int main(int argc, char **argv)
}
}
+ if (options.isSet(OptStreamsConfig)) {
+ if (!options.isSet(OptCamera)) {
+ std::cout << "Can't configure stream, no camera selected" << std::endl;
+ goto out;
+ }
+
+ std::shared_ptr<Camera> cam = cm->get(options[OptCamera]);
+ if (!cam) {
+ std::cout << "Camera " << options[OptCamera]
+ << " not found" << std::endl;
+ goto out;
+ }
+
+ std::vector<Stream> streams = cam->streams();
+ if (streams.size() != 1) {
+ std::cout << "Camera have " << streams.size() <<
+ " streams, I only know how to work with 1" << std::endl;
+ goto out;
+ }
+
+ StreamConfiguration config = StreamConfiguration(streams.front());
+ config.setDimension(640, 480);
+
+ std::vector<StreamConfiguration *> configs;
+ configs.push_back(&config);
+
+ if (cam->acquire()) {
+ std::cout << "Failed to acquire camera" << std::endl;
+ goto out;
+ }
+
+ if (cam->configure(configs))
+ std::cout << "Failed to configure camera" << std::endl;
+ }
+
+out:
cm->stop();
return 0;