[英]read/write access violation c++ using libfreenect2
I'm a newbe to C++ and started fooling around with my Kinect V2 and libfreenect2. 我是C ++的新手,开始玩我的Kinect V2和libfreenect2。 The building of the library worked fine for me, I guess.
我想,图书馆的建设对我来说很好。 But when I try to use it in my code I get some weird exceptions.
但是当我尝试在我的代码中使用它时,我得到了一些奇怪的例外。
Freenect2 freenect2;
std::string serial="";
Freenect2Device *dev = 0;
freenect2.enumerateDevices();
serial = freenect2.getDefaultDeviceSerialNumber();
dev = freenect2.openDevice(serial);
Everytime I run this code, it fails at getting the serial number [serial = freenect2.getDefaultDeviceSerialNumber();] with: 每次运行此代码时,都无法获取序列号[serial = freenect2.getDefaultDeviceSerialNumber();]:
"Unhandled exception thrown: read access violation. “抛出未处理的异常:读取访问冲突。
_Pnext was 0xFFFFFFFFFFFFFFFF." _Pnext是0xFFFFFFFFFFFFFFFF。“
In case I'm using 如果我正在使用
Freenect2 freenect2;
Freenect2Device *dev = 0;
SyncMultiFrameListener listener(Frame::Color);
FrameMap frames;
freenect2.enumerateDevices();
dev = freenect2.openDefaultDevice();
dev->setColorFrameListener(&listener);
dev->start();
listener.waitForNewFrame(frames)
instead, it fails while waiting for a new frame [listener.waitForNewFrame(frames)] with following exception thrown: 相反,它在等待新的帧[listener.waitForNewFrame(frames)]时失败,抛出以下异常:
" Exception thrown at 0x000000018026D0C2 (ig75icd64.dll) in ConsoleApplication1.exe: 0xC0000005: Access violation writing location 0x000000002BA0D700. " “ConsoleApplication1.exe中的0x000000018026D0C2(ig75icd64.dll)异常抛出:0xC0000005:访问冲突写入位置0x000000002BA0D700。”
So, what am I doing wrong and how can I do it better? 那么,我做错了什么,我怎么能做得更好呢?
Thanks for your advice. 谢谢你的建议。
Edit: shortened the code... 编辑:缩短代码...
I was facing the same problem on Debug mode but it worked on Release. 我在调试模式下遇到了同样的问题,但它在Release上工作。
After some hours researching, I've managed to solve the problem through a compilation flag on the libfreenect2 project (on debug setting). 经过几个小时的研究,我已经设法通过libfreenect2项目上的编译标志解决问题(在调试设置上)。
The freenect2 project was marked as
Multi-threaded DLL (/MD)
and if you change it toMulti-threaded Debug DLL (/MDd)
it should work.freenect2项目被标记为
Multi-threaded DLL (/MD)
,如果将其更改为Multi-threaded Debug DLL (/MDd)
它应该可以工作。
In VS2015 you can access this property on: 在VS2015中,您可以访问此属性:
Project Properties -> C/C++ -> Code Generation ->Runtime Library
项目属性 - > C / C ++ - >代码生成 - >运行时库
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.