我正在使用Microsoft Visual C++ 6.0和Microsoft Visual Studio 2008开发学术计算机视觉项目。cvblob在Visual C++ 6.0中编译错误
在这个项目中,我需要使用OpenCV 1.1(http://opencv.willowgarage.com/)和CvBlob(http://code.google.com/p/cvblob/)。
我试图用Microsoft Visual Studio 2008编译这个项目,它编译没有错误。
随着Visual C++ 6.0我得到了很多错误。
对于这种行为,OpenCV不负责,因为一个只有OpenCV(没有CvBlob)的平凡项目效果很好。
为了更好地理解错误,我做了一个只包含CvBlob的空项目。
我这里粘贴错误的简短摘要:
cvcontour.cpp(253) : error C2371: 'i' : redefinition; different basic types (and others similar to this. i solved with variable redefinition, every time)
cvcontour.cpp(318) : error C2664: 'thiscall std::vector<struct CvPoint,class std::allocator<struct CvPoint> >::std::vector<struct CvPoint,class std::allocator<struct CvPoint> >(unsigned int,const struct CvPoint &,const class std::allocator<struct CvPoint> &)' : cannot convert parameter 1 from 'class std::deque<struct CvPoint,class std::allocator<struct CvPoint> >::iterator' to 'unsigned int' No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
cvtrack.cpp(278) : error C2440: 'initializing' : cannot convert from 'struct cvb::CvTrack *const ' to 'struct cvb::CvBlob *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
你有我如何能解决这些问题的想法?
在此先感谢您的帮助!
-------- -------- UPDATE
我试图以elminate我的问题的三个错误编辑和纠正代码。
错误C2664似乎是更难cirmumvent ...
我已经更换了起诉线
return new CvContourPolygon(dq.begin(), dq.end());
其中CvContourPolygon是typedef std::vector<CvPoint> CvContourPolygon;
与
deque<int>::iterator dq_it;dq_it = dq.begin();
CvContourPolygon v_tmp;
v_tmp.push_back(*dq_it);
while (dq_it != dq.end()){
v_tmp.push_back(*dq_it++);
}
首先,我写的是正确的?比,我该如何解决由此发生的错误?
预先感谢您!
错误(假设第一行是318:
cvcontour.cpp(319) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'class std::deque<struct CvPoint,class std::allocator<struct CvPoint> >::iterator' (or
there is no acceptable conversion)
cvcontour.cpp(321) : error C2664: 'push_back' : cannot convert parameter 1 from 'int' to 'const struct CvPoint &'
Reason: cannot convert from 'int' to 'const struct CvPoint'
No constructor could take the source type, or constructor overload resolution was ambiguous
cvcontour.cpp(322) : error C2679: binary '!=' : no operator defined which takes a right-hand operand of type 'class std::deque<struct CvPoint,class std::allocator<struct CvPoint> >::iterator' (or there is no acceptable conversion)
cvcontour.cpp(322) : fatal error C1903: unable to recover from previous error(s); stopping compilation
执行cl.exe时出错
-------- -------- UPDATE2
此代码似乎正常工作
deque<CvPoint>::iterator dq_it;
dq_it = dq.begin();
CvContourPolygon v_tmp;
for (dq_it = dq.begin(); dq_it != dq.end(); ++dq_it){
v_tmp.push_back(*dq_it);
}
//return new CvContourPolygon(dq.begin(), dq.end());
return &v_tmp;
有没有很好的理由你想使用VC 6.0?如果可以的话,避免它(你可以;你有MSVC 9.0)。 – rubenvb 2010-10-13 15:30:09
是的,有一个很好的理由!在我的电脑我有MSVS2008和所有的代码运作良好!但在学术PC中,我无法选择IDE和编译器,并且有MSVC++ 6.0!所以,不幸的是 ,我必须在这个环境中编译我的代码... – Sbaush 2010-10-14 10:36:02