<h3 dir="auto">Describe the feature and motivation</h3>
<p dir="auto">There is no way currently, within OpenCV, to list existing devices to let the user select them. This means that they must be obtained in a different manner (either by re-implementing manually, or using a third-party library), which may not match OpenCV's indexes and may not work on all platforms.</p>
<p dir="auto">There is a workaround to try every indexes individually, but this has 4 main issues:</p>
<ol dir="auto">
<li>Some VideoCapture devices will freeze if opened and closed quickly or if it was already in use.
<ul dir="auto">
<li>The popular SD capture card <code class="notranslate">GV-USB2</code> (confirmed myself)</li>
<li>I've had reports that an <code class="notranslate">AverMedia</code> capture card is affected as well</li>
</ul>
</li>
<li>Some devices take a long time to boot, making this technique quite slow (like my <code class="notranslate">Logitech c920</code> webcam)</li>
<li>The total amount of devices is unknown, and usable devices may not be sequential. So we have to guess how many devices maximum the user may have, trying to balance between time spent or risking missing some</li>
<li>Even if you get all the IDs after this, you don't have access to the names to present to the user. (see <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="1681657743" data-permission-text="Title is private" data-url="https://github.com/opencv/opencv/issues/23537" data-hovercard-type="issue" data-hovercard-url="/opencv/opencv/issues/23537/hovercard" href="https://github.com/opencv/opencv/issues/23537">#23537</a>)</li>
</ol>
<h3 dir="auto">Additional context</h3>
<p dir="auto"><em>No response</em></p>
<p dir="auto">Transferred from <a href="http://code.opencv.org/issues/935" rel="nofollow">http://code.opencv.org/issues/935</a></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="|| Rune Espeseth on 2011-03-08 10:27
|| Priority: Normal
|| Affected: None
|| Category: highgui-camera
|| Tracker: Feature
|| Difficulty: 
|| PR: 
|| Platform: None / None"><pre class="notranslate"><code class="notranslate">|| Rune Espeseth on 2011-03-08 10:27
|| Priority: Normal
|| Affected: None
|| Category: highgui-camera
|| Tracker: Feature
|| Difficulty: 
|| PR: 
|| Platform: None / None
</code></pre></div>
<h2 dir="auto">Add API to enumerate cameras</h2>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="OpenCV should have an API to enumerate cameras. Without it, writing programs that support non-fixed hardware is not possible.

The point of this API is to retrieve information about the cameras attached to the system:
- NumberOf
- Name of each camera (can be used for user-selection in a GUI)
- Resolution of each camera
- other properties.

It will then be possible to write programs (f.i. surveillance software) that support 1 to any number of cameras instead of requiring a given number of cameras."><pre class="notranslate"><code class="notranslate">OpenCV should have an API to enumerate cameras. Without it, writing programs that support non-fixed hardware is not possible.

The point of this API is to retrieve information about the cameras attached to the system:
- NumberOf
- Name of each camera (can be used for user-selection in a GUI)
- Resolution of each camera
- other properties.

It will then be possible to write programs (f.i. surveillance software) that support 1 to any number of cameras instead of requiring a given number of cameras.
</code></pre></div>
<h2 dir="auto">History</h2>
<h5 dir="auto">Alexander Shishkov on 2012-02-12 21:12</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="-   Description changed from [[OpenCV]] should have an API to enumerate
    cameras. Without it, writing progr... to OpenCV should have an API
    to enumerate cameras. Without it, writing programs ... More"><pre class="notranslate"><code class="notranslate">-   Description changed from [[OpenCV]] should have an API to enumerate
    cameras. Without it, writing progr... to OpenCV should have an API
    to enumerate cameras. Without it, writing programs ... More
</code></pre></div>
<h5 dir="auto">Alexander Reshetnikov on 2012-04-25 14:27</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="-   Priority changed from High to Normal
-   Assignee set to Vadim Pisarevsky"><pre class="notranslate"><code class="notranslate">-   Priority changed from High to Normal
-   Assignee set to Vadim Pisarevsky
</code></pre></div>
<h5 dir="auto">Andrey Kamaev on 2012-08-16 15:23</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="-   Category changed from highgui-images to highgui-camera"><pre class="notranslate"><code class="notranslate">-   Category changed from highgui-images to highgui-camera
</code></pre></div>
<h5 dir="auto">Neil Jansen on 2015-02-03 04:59</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Hi, I know this issue has been open for a while, but is there any chance that it could be fixed easily?  It would be very helpful for those of us using machine vision with more than 1 camera.  I am even willing to place a cash bounty on this bug if necessary (tried to do it at bountysource.com, but they don't support the ChiliProject bug tracking platform that OpenCV uses...).  Thanks!"><pre class="notranslate"><code class="notranslate">Hi, I know this issue has been open for a while, but is there any chance that it could be fixed easily?  It would be very helpful for those of us using machine vision with more than 1 camera.  I am even willing to place a cash bounty on this bug if necessary (tried to do it at bountysource.com, but they don't support the ChiliProject bug tracking platform that OpenCV uses...).  Thanks!
</code></pre></div>
<h5 dir="auto">Steven Puttemans on 2015-02-03 09:29</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Depending on which camera type you are using this already exists. The recently adapted PvAPI interface of Allied Vision Technology cameras does exactly this. No idea if other do it or not."><pre class="notranslate"><code class="notranslate">Depending on which camera type you are using this already exists. The recently adapted PvAPI interface of Allied Vision Technology cameras does exactly this. No idea if other do it or not.
</code></pre></div>