[libcamera-devel] [PATCH 1/2] simple-cam: Early return if no cameras found on the system
Umang Jain
email at uajain.com
Thu Sep 24 16:18:02 CEST 2020
Early return if no cameras are found on the system.
Failing to do so, the codepath will segfault while trying to
acquire a non-existent camera.
Signed-off-by: Umang Jain <email at uajain.com>
---
simple-cam.cpp | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/simple-cam.cpp b/simple-cam.cpp
index 3aa975e..d51000c 100644
--- a/simple-cam.cpp
+++ b/simple-cam.cpp
@@ -95,6 +95,13 @@ int main()
CameraManager *cm = new CameraManager();
cm->start();
+ if(!cm->cameras().size()) {
+ std::cout << "Please connect atleast one camera to the system."
+ << std::endl;
+ cm->stop();
+ return -1;
+ }
+
/*
* Just as a test, list all id's of the Camera registered in the
* system. They are indexed by name by the CameraManager.
--
2.26.2
More information about the libcamera-devel
mailing list