Rel*_*lla 5 c c++ macos webcam device
所以我需要的很简单 - 当前可用的视频捕获设备(网络摄像机)的列表。我需要在简单或 C++ 控制台应用程序中使用它。通过列表,我的意思是类似这样的控制台输出:
1) Asus Web Camera
2) Sony Web Camera
Run Code Online (Sandbox Code Playgroud)
所以这看起来很简单,但我有一个要求 - 尽可能多地使用本机操作系统 api - 没有外部库 - 毕竟 - 我们想要的只是打印出一个列表 - 不要飞上月球!)(并且不使用Objective-C,请 - 纯 C/C++)
这样的事情怎么办?
也来自这个系列:
您需要使用 SGGetChannelDeviceList,它是 QuickTime C API 的一部分。每个设备可以有多个输入。解析它的正确方法是这样的:
// first get a video channel from the sequence grabber
ComponentDescription theDesc;
Component sgCompID;
ComponentResult result;
theDesc.componentType = SeqGrabComponentType;
theDesc.componentSubType = 0L;
theDesc.componentManufacturer = 'appl';
theDesc.componentFlags = 0L;
theDesc.componentFlagsMask = 0L;
sgCompID = FindNextComponent (NULL, &theDesc);
seqGrabber = OpenComponent (sgCompID);
result = SGInitialize (seqGrabber);
result = SGNewChannel (seqGrabber, VideoMediaType, &videoChannel);
SGDeviceList theDevices;
SGGetChannelDeviceList(videoChannel, sgDeviceListDontCheckAvailability | sgDeviceListIncludeInputs, &theDevices);
if (theDevices)
{
int theDeviceIndex;
for (theDeviceIndex = 0; theDeviceIndex != (*theDevices)->count; ++theDeviceIndex)
{
SGDeviceName theDeviceEntry = (*theDevices)->entry[theDeviceIndex];
// name of device is a pstring in theDeviceEntry.name
SGDeviceInputList theInputs = theDeviceEntry.inputs;
if (theInputs != NULL)
{
int theInputIndex;
for ( theInputIndex = 0; theInputIndex != (*theInputs)->count; ++theInputIndex)
{
SGDeviceInputName theInput = (*theInputs)->entry[theInputIndex];
// name of input is a pstring in theInput.name
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5095 次 |
| 最近记录: |