Eventloop 卡住:NAO C++ SDK OnFaceDetection 示例
Eventloop stuck: NAO C++ SDK OnFaceDetection Example
我在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: 生成更多线程 (5(
[I] 4355 qi.eventloop: eventloop: 生成更多线程 (6(
[I] 4355 qi.eventloop: eventloop: 生成更多线程 (7(
[I] 4355 qi.eventloop: eventloop: 生成更多线程 (8(
[I] 4355 qi.eventloop: eventloop: 生成更多线程 (9(
[I] 4355 qi.eventloop: eventloop: 生成更多线程 (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;
}
}
正如@AlexandreMazel所提到的,此错误只是向您解释系统正在创建太多新线程,因为该函数经常被调用(高达 10x/s(,但需要几秒钟才能执行,因为其中有语音。
您可能希望有一个标志或非阻塞互斥锁,以防止函数多次运行。
关于更改 tts.say,这里有一个例子:
通过处理所有文本命令的方法更改 tts.say
tts.say(txt)
成为:
if time.time() - self.lastSaidTime > 5.0 or txt != self.lastSaidText:
self.lastSaidTime = time.time()
self.lastSaidText = txt
tts.say(txt)
相关文章:
- 使用外部SDK工具链文件在VisualStudio上生成项目编译错误
- Vulkan SDK 版本 1.1.85.0 在 Kubuntu 18.10 上链接
- 升级到 Windows 10 版本 1809 SDK 后,我无法编译使用 C++/WinRT 的项目
- 在设计 SDK 时,我是否应该在 C++ 头文件中完全隐藏内部类?
- Eventloop 卡住:NAO C++ SDK OnFaceDetection 示例
- 构建失败错误:无法使用 qibuild 构建C++ SDK Helloworld
- Microsoft C++ 用于图形 API 的 Rest SDK
- 如何检索 Steamwork SDK 的当前版本
- 佳能SDK无法从相机下载图片
- 如何使用 CPP REST SDK 实现 CAS(中央认证服务)?
- 在为 iOS 构建 aws-sdk-cpp 时,cmake 上的 CXX 编译器错误已损坏
- 关于 API 文档和设备操作 在助手-sdk-cpp 上
- C++标准视窗 SDK 文件中的编译错误
- DLL:当 SDK 头文件不使用 __declspec(dllexport) 时,我可以使用它吗
- 将 aws-iot-device-sdk-cpp-v2 与 CMake 结合使用
- "byte":使用Crypto++和Windows SDK时出现不明确的符号错误
- FBX SDK 在预期 3 个顶点时返回 4 个顶点
- Qt & Firebase C++ SDK 在 iOS 上的链接问题
- Yocto-bitbake与SDK系统根冲突
- Canon SDK初始化崩溃