Итак, у меня в школе есть домашнее задание, чтобы перечислить камеры, доступные в Mac OS X, но я должен сделать это на C ++ под xcode. Я создал такой код:
#include <iostream>
#include <sstream>
#include <string.h>
#include <Quicktime/quicktime.h>
//#include <boost/lexical_cast.hpp>
using namespace std;
int main()
{
int i = 0;
int selectedIndex;
cout << endl << "Let us select video device." << endl << "Available capture devices are:" << endl;
// 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];
cout << i << ".1. " << theDeviceEntry.name << endl;
// 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];
cout << i << ".2. " << theInput.name << endl;
// name of input is a pstring in theInput.name
}
}
}
} // i++ we need to add...
selectedIndex = 999;
if (i <= 0)
{
cout << "No devices found." << endl;
return 999;
}
else if (i == 1)
{
cout << "Default device will be used.\n" << endl;
selectedIndex = 0;
}
else
{
while (selectedIndex > i - 1 || selectedIndex < 0)
{
try
{
cin >> selectedIndex;
//string s;
//getline(cin, s, '\n');
//selectedIndex = boost::lexical_cast<int>(s);
}
catch(std::exception& e)
{
cout << "Please input index from 0 to " << i - 1 << endl;
selectedIndex = 999;
}
}
}
return selectedIndex;
}
Не компилируется. Он показывает много странных ошибок о SeqGrabComponentType, но я Mac C ++ nube и не знаю, что делать - как сделать компиляцию моего приложения, пожалуйста, помогите?
Обновление:
Список ошибок:
camerasList: In function 'int main()':
camerasList:49: error: 'SeqGrabComponentType' was not declared in this scope
camerasList:55: error: 'seqGrabber' was not declared in this scope
camerasList:56: error: 'SGInitialize' was not declared in this scope
camerasList:57: error: 'videoChannel' was not declared in this scope
camerasList:57: error: 'SGNewChannel' was not declared in this scope
camerasList:58: error: 'SGDeviceList' was not declared in this scope
camerasList:58: error: expected `;' before 'theDevices'
camerasList:59: error: 'sgDeviceListDontCheckAvailability' was not declared in this scope
camerasList:59: error: 'sgDeviceListIncludeInputs' was not declared in this scope
camerasList:59: error: 'theDevices' was not declared in this scope
camerasList:59: error: 'SGGetChannelDeviceList' was not declared in this scope
camerasList:66: error: 'SGDeviceName' was not declared in this scope
camerasList:66: error: expected `;' before 'theDeviceEntry'
camerasList:67: error: 'theDeviceEntry' was not declared in this scope
camerasList:70: error: 'SGDeviceInputList' was not declared in this scope
camerasList:70: error: expected `;' before 'theInputs'
camerasList:71: error: 'theInputs' was not declared in this scope
camerasList:76: error: 'SGDeviceInputName' was not declared in this scope
camerasList:76: error: expected `;' before 'theInput'
camerasList:77: error: 'theInput' was not declared in this scope
Обновление:
Половина решения проблемы: компиляция в архитектуре i386 решает большинство ошибок (осталось немного).