Files
opencv-MIRROR/apps/camera-enumerate/camera_enumerate.cpp
Savya Sanchi Sharma a1de5285b0 Merge pull request #29843 from SavyaSanchi-Sharma:camurate
videoio: Added camera device enumeration - #29843#29843

 **Resolves** [Issue#4269](https://github.com/opencv/opencv/issues/4269)

### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [ ] The PR is proposed to the proper branch
- [ ] There is a reference to the original bug report and related work
- [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [ ] The feature is well documented and sample code can be built with the project CMake
2026-10-12 16:38:07 +03:00

40 lines
1.2 KiB
C++

// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
// Copyright (C) 2026, BigVision LLC, all rights reserved.
// Third party copyrights are property of their respective owners.
#include <iostream>
#include <opencv2/videoio.hpp>
#include <opencv2/videoio/registry.hpp>
static void dumpCameraDevices()
{
const std::vector<cv::VideoDeviceInfo> devices = cv::videoio_registry::enumerateDevices();
std::cout << "Camera devices available via cv::VideoCapture(index):" << std::endl;
for (size_t i = 0; i < devices.size(); i++)
{
std::cout << " index=" << devices[i].cam_idx
<< " (" << cv::videoio_registry::getBackendName(devices[i].backend) << ")"
<< " -> " << devices[i].cam_name << std::endl;
}
std::cout << "Total available: " << devices.size() << std::endl;
}
int main(int argc, const char** argv)
{
cv::CommandLineParser parser(argc, argv,
"{ help h usage ? | | show this help message }"
);
if (parser.has("help"))
{
parser.printMessage();
return 0;
}
dumpCameraDevices();
return 0;
}