[OpenCV] Device(Camera) Enumerator 카메라 구분하기
OpenCV 2026. 2. 16. 13:48 |반응형
OpenCV에는 컴퓨터에 연결된 카메라를 검색하거나 구분할 수 있는 기능이 없다.
Device Enumerator를 사용해 카메라를 구분해 보자.
DeviceEnumerator.h
0.00MB
DeviceEnumerator.cpp
0.00MB
#include <map>
#include <iostream>
#include "DeviceEnumerator.h"
int main()
{
/*
The id field of the Device struct can be used with an OpenCV VideoCapture object
*/
DeviceEnumerator de;
// Audio Devices
std::map<int, Device> devices = de.getAudioDevicesMap();
std::cout << "Number of Audio Devices: " << devices.size() << std::endl;
// Print information about the devices
for (auto const &device : devices) {
std::cout << "== AUDIO DEVICE (id:" << device.first << ") ==" << std::endl;
std::cout << "Name: " << device.second.deviceName << std::endl;
std::cout << "Path: " << device.second.devicePath << std::endl;
}
// Video Devices
devices = de.getVideoDevicesMap();
std::cout << "Number of Video Devices: " << devices.size() << std::endl;
// Print information about the devices
for (auto const &device : devices) {
std::cout << "== VIDEO DEVICE (id:" << device.first << ") ==" << std::endl;
std::cout << "Name: " << device.second.deviceName << std::endl;
std::cout << "Path: " << device.second.devicePath << std::endl;
}
}

getAudioDevicesMap()은 마이크가 연결되어 있어야 표시되는 것 같다. (확인은 안해봄)
반응형
'OpenCV' 카테고리의 다른 글
| [OpenCV] Python 에서 C++ DLL 사용하기 (0) | 2026.02.19 |
|---|---|
| [OpenCV] C# 에서 C++ DLL 사용하기 (0) | 2026.02.18 |
| [OpenCV] Desktop Capture 화면 캡쳐 (0) | 2026.02.11 |
| OpenCV Contour Nozzle Dripping Detection (0) | 2025.04.29 |
| IP Camera ONVIF Protocol (0) | 2025.03.01 |
