반응형

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()은 마이크가 연결되어 있어야 표시되는 것 같다. (확인은 안해봄)

 

반응형
Posted by J-sean
: