Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/140.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在mac os x上捕获相机列表未编译 我在学校有一份作业,列出了Mac OS X上可用的相机,但是我必须在XC+下用C++完成。我创建了这样的代码: #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; }_C++_Macos_Camera_Device - Fatal编程技术网

在mac os x上捕获相机列表未编译 我在学校有一份作业,列出了Mac OS X上可用的相机,但是我必须在XC+下用C++完成。我创建了这样的代码: #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; }

在mac os x上捕获相机列表未编译 我在学校有一份作业,列出了Mac OS X上可用的相机,但是我必须在XC+下用C++完成。我创建了这样的代码: #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; },c++,macos,camera,device,C++,Macos,Camera,Device,更新: 问题解决方案的一半:在i386体系结构下编译可以解决大多数错误(只剩下少数错误)。尝试添加#导入并链接到QuickTime.framework。正如您所发现的,为i386而不是x64编译非常有帮助 其余的,我补充道 ComponentInstance seqGrabber; SGChannel videoChannel; 你能提供一些错误吗?不管在is missingSeqGrabComponentType中定义了什么头SeqGrabCompon

更新:


问题解决方案的一半:在i386体系结构下编译可以解决大多数错误(只剩下少数错误)。

尝试添加
#导入
并链接到QuickTime.framework。

正如您所发现的,为i386而不是x64编译非常有帮助

其余的,我补充道

   ComponentInstance    seqGrabber;
   SGChannel            videoChannel;

你能提供一些错误吗?不管在is missingSeqGrabComponentType中定义了什么头SeqGrabComponentType等,都会在quicktime.h中定义。但是不可能获取ODefeninition…它将在x64下使用它编译?我很确定quicktime不是64位的。
   ComponentInstance    seqGrabber;
   SGChannel            videoChannel;