我正在使用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