[libcamera-devel,10/10] DO NOT MERGE: Reports camera properties in cam

Message ID 20191204132106.21582-11-jacopo@jmondi.org
State Superseded
Headers show
Series
  • Introduce camera properties
Related show

Commit Message

Jacopo Mondi Dec. 4, 2019, 1:21 p.m. UTC
Running cam -l lists the camera properties registered by the pipeline
handler.

In example, for the VIMC pipelinehandler:

Available cameras:
1: Integrated Camera: Integrated C
2: VIMC Sensor B
Rotation: 0
Location: 0

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
---
 src/cam/main.cpp | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Laurent Pinchart Dec. 4, 2019, 4:35 p.m. UTC | #1
Hi Jacopo,

Thank you for the patch.

On Wed, Dec 04, 2019 at 02:21:06PM +0100, Jacopo Mondi wrote:
> Running cam -l lists the camera properties registered by the pipeline
> handler.
> 
> In example, for the VIMC pipelinehandler:
> 
> Available cameras:
> 1: Integrated Camera: Integrated C
> 2: VIMC Sensor B
> Rotation: 0
> Location: 0

If you want to produce a mergeable patch, I think you could simply add a
new command line argument to print the properties. And you would need to
handle types, as the hardcoded int32_t below wouldn't be enough.

> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
> ---
>  src/cam/main.cpp | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/src/cam/main.cpp b/src/cam/main.cpp
> index a38cca959aca..8d37754773af 100644
> --- a/src/cam/main.cpp
> +++ b/src/cam/main.cpp
> @@ -11,6 +11,7 @@
>  #include <string.h>
>  
>  #include <libcamera/libcamera.h>
> +#include <libcamera/property_ids.h>
>  
>  #include "capture.h"
>  #include "event_loop.h"
> @@ -309,6 +310,16 @@ int CamApp::run()
>  		for (const std::shared_ptr<Camera> &cam : cm_->cameras()) {
>  			std::cout << index << ": " << cam->name() << std::endl;
>  			index++;
> +
> +			const ControlList &properties = cam->properties();
> +			for (const auto &prop : properties) {
> +				auto it = properties::properties.find(prop.first);
> +				if (it == properties::properties.end())
> +					continue;
> +
> +				std::cout << it->second->name() << ": " <<
> +					prop.second.get<int32_t>() << "\n";
> +			}
>  		}
>  	}
>
Jacopo Mondi Dec. 5, 2019, 9:41 a.m. UTC | #2
Hi Laurent,

On Wed, Dec 04, 2019 at 06:35:16PM +0200, Laurent Pinchart wrote:
> Hi Jacopo,
>
> Thank you for the patch.
>
> On Wed, Dec 04, 2019 at 02:21:06PM +0100, Jacopo Mondi wrote:
> > Running cam -l lists the camera properties registered by the pipeline
> > handler.
> >
> > In example, for the VIMC pipelinehandler:
> >
> > Available cameras:
> > 1: Integrated Camera: Integrated C
> > 2: VIMC Sensor B
> > Rotation: 0
> > Location: 0
>
> If you want to produce a mergeable patch, I think you could simply add a
> new command line argument to print the properties. And you would need to
> handle types, as the hardcoded int32_t below wouldn't be enough.
>

Would this be something useful ? I can try to add a '-p' switch to cam
in that case.. And yes, I think it might be useful indeed...


> > Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
> > ---
> >  src/cam/main.cpp | 11 +++++++++++
> >  1 file changed, 11 insertions(+)
> >
> > diff --git a/src/cam/main.cpp b/src/cam/main.cpp
> > index a38cca959aca..8d37754773af 100644
> > --- a/src/cam/main.cpp
> > +++ b/src/cam/main.cpp
> > @@ -11,6 +11,7 @@
> >  #include <string.h>
> >
> >  #include <libcamera/libcamera.h>
> > +#include <libcamera/property_ids.h>
> >
> >  #include "capture.h"
> >  #include "event_loop.h"
> > @@ -309,6 +310,16 @@ int CamApp::run()
> >  		for (const std::shared_ptr<Camera> &cam : cm_->cameras()) {
> >  			std::cout << index << ": " << cam->name() << std::endl;
> >  			index++;
> > +
> > +			const ControlList &properties = cam->properties();
> > +			for (const auto &prop : properties) {
> > +				auto it = properties::properties.find(prop.first);
> > +				if (it == properties::properties.end())
> > +					continue;
> > +
> > +				std::cout << it->second->name() << ": " <<
> > +					prop.second.get<int32_t>() << "\n";
> > +			}
> >  		}
> >  	}
> >
>
> --
> Regards,
>
> Laurent Pinchart

Patch

diff --git a/src/cam/main.cpp b/src/cam/main.cpp
index a38cca959aca..8d37754773af 100644
--- a/src/cam/main.cpp
+++ b/src/cam/main.cpp
@@ -11,6 +11,7 @@ 
 #include <string.h>
 
 #include <libcamera/libcamera.h>
+#include <libcamera/property_ids.h>
 
 #include "capture.h"
 #include "event_loop.h"
@@ -309,6 +310,16 @@  int CamApp::run()
 		for (const std::shared_ptr<Camera> &cam : cm_->cameras()) {
 			std::cout << index << ": " << cam->name() << std::endl;
 			index++;
+
+			const ControlList &properties = cam->properties();
+			for (const auto &prop : properties) {
+				auto it = properties::properties.find(prop.first);
+				if (it == properties::properties.end())
+					continue;
+
+				std::cout << it->second->name() << ": " <<
+					prop.second.get<int32_t>() << "\n";
+			}
 		}
 	}