我在我的 MAC 上安装了 NAOqi C++ SDK,并尝试了一些来自 SDK 的示例。HelloWorld-Example 运行良好,但使用OnFaceDetection -Example在 NAO 检测到我的脸后,我会收到 qi.eventloop 的错误/警告。
Narongsones-MacBook-Pro:bin Narongsone$ ./onfacedetection --pip 192.168.1.138
[I] 1295 core.common.toolsmain: ..::: starting onfacedetection :::..
[I] 1295 core.common.toolsmain: Connecting to 192.168.1.138:9559...
[I] 1295 qimessaging.session: Session listener created on tcp://0.0.0.0:0
[I] 1295 qimessaging.transportserver: TransportServer will listen on: tcp://192.168.1.136:64881
[I] 1295 qimessaging.transportserver: TransportServer will listen on: tcp://127.0.0.1:64881
[I] 1295 core.common.toolsmain: Connection with 192.168.1.138:9559 established
[I] 1295 module.example: No face detected
[I] 1295 core.common.toolsmain: onfacedetection is ready... Press CTRL^C to quit
[I] 3843 module.name: 1 face(s) detected.
[I] 4355 qi.eventloop: eventloop: Spawning 更多线程(5)
[I] 4355 qi.eventloop: eventloop: Spawning 更多线程(6)
[I] 4355 qi.eventloop: eventloop: Spawning 更多线程(7)
[I] 4355 qi.eventloop: eventloop: Spawning 更多线程(8)
[I]4355 qi.eventloop: eventloop: Spawning 更多线程(9)
[I] 4355 qi.eventloop: eventloop: Spawning more threads (10)
如果您对问题所在有任何想法,请帮助我。谢谢!
我的回调函数:
void OnFaceDetection::callback() {
/** Use a mutex to make it all thread safe. */
AL::ALCriticalSection section(fCallbackMutex);
try {
/** Retrieve the data raised by the event. */
fFaces = fMemoryProxy.getData("FaceDetected");
/** Check that there are faces effectively detected. */
if (fFaces.getSize() < 2 ) {
if (fFacesCount != 0) {
qiLogInfo("module.example") << "No face detected" << std::endl;
fTtsProxy.say("No face detected.");
fFacesCount = 0;
}
return;
}
/** Check the number of faces from the FaceInfo field, and check that it has
* changed from the last event.*/
if (fFaces[1].getSize() - 1 != fFacesCount) {
qiLogInfo("module.name") << fFaces[1].getSize() - 1 << " face(s) detected." << std::endl;
char buffer[50];
sprintf(buffer, "%d faces detected.", fFaces[1].getSize() - 1);
fTtsProxy.say(std::string(buffer));
/** Update the current number of detected faces. */
fFacesCount = fFaces[1].getSize() - 1;
}
}
catch (const AL::ALError& e) {
qiLogError("module.name") << e.what() << std::endl;
}
}