y****n 发帖数: 15 | 1 下面是一段10行的小程序,调用OpenCV2.1
#include "cv.h"
#include "highgui.h"
#include
using namespace std;
void main()
{
string videofname = "E:\\Demo\\test.avi";
cv::VideoCapture capture;
capture.open(videofname);
cv::Mat frame;
capture >> frame;
}
这个程序在Visual Studio 2008下面编译和运行都正常。
但在VS 2010和VS 2012下运行时,执行到capture.open()产生异常。
追踪到VideoCapture::open(const string& filename)函数内部,发现这时的
filename string就变成了Bad Ptr。
大家有没有遇到过类似的问题?该怎么解决? |
O6 发帖数: 8 | 2 E:\\Demo\\test.avi
【在 y****n 的大作中提到】 : 下面是一段10行的小程序,调用OpenCV2.1 : #include "cv.h" : #include "highgui.h" : #include : using namespace std; : void main() : { : string videofname = "E:\\Demo\\test.avi"; : cv::VideoCapture capture; : capture.open(videofname);
|
y****n 发帖数: 15 | 3 嗯,是这里写错了,程序中写的还是"\\",但拷贝到帖子里就变成了"\",我已经在原
帖中改过来了。
我如果使用debug版本的lib文件(cv210d.lib)就会出这个问题,如果release版本(
cv210.lib)就没事。
【在 O6 的大作中提到】 : E:\\Demo\\test.avi
|
G*****7 发帖数: 1759 | 4 how did you compile your cv*.lib? with vs 2008? dynamic or static?
【在 y****n 的大作中提到】 : 嗯,是这里写错了,程序中写的还是"\\",但拷贝到帖子里就变成了"\",我已经在原 : 帖中改过来了。 : 我如果使用debug版本的lib文件(cv210d.lib)就会出这个问题,如果release版本( : cv210.lib)就没事。
|
y****n 发帖数: 15 | 5 cv*.lib 应该是用vs 2008编译的dynamic,这个有影响么?
【在 G*****7 的大作中提到】 : how did you compile your cv*.lib? with vs 2008? dynamic or static?
|
G*****7 发帖数: 1759 | 6 re-compile everything in vs 2010.
formal explanation: http://msdn.microsoft.com/en-us/library/ms235460.aspx
in short: use "dependency walker" to examine your debug .exe that crashed,
you will see it linked to both msvcr90d.dll and msvcr100d.dll. this is a bad
sign for impending doom.
【在 y****n 的大作中提到】 : cv*.lib 应该是用vs 2008编译的dynamic,这个有影响么?
|
G*****7 发帖数: 1759 | 7 then, if you use vs2010 and target 64-bit, be sure to install sp1 first.
the compiler in rtm (pre-sp1) is flawed. |