Visual C ++ 6.0中的cvblob编译错误 [英] cvblob compile error in Visual C++ 6.0

查看:188
本文介绍了Visual C ++ 6.0中的cvblob编译错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Microsoft Visual C ++ 6.0和Microsoft Visual Studio 2008来开发学术计算机视觉项目。



在这个项目中,我需要使用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;不同的基本类型(和其他类似的,我解决与变量redefinition,每次)

cvcontour.cpp(318):错误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>&)':不能将参数1从'class std :: deque< struct CvPoint,class std :: allocator< struct CvPoint& ; > :: iterator'to'unsigned int'没有可以执行此转换的用户定义转换运算符,或者无法调用运算符

cvtrack.cpp(278):error C2440:初始化':不能从'struct cvb :: CvTrack * const'转换为'struct cvb :: CvBlob *'指向的类型是不相关的;转换需要reinterpret_cast,C风格的转换或函数式转换

这些问题?



感谢您提供帮助!



-------- UPDATE - -------



我试图编辑和更正代码,以消除我的问题中的三个错误。



错误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'=':它接受类型为'std :: deque< struct CvPoint,class std :: allocator< struct CvPoint>> :: iterator'(或
,没有可接受的转换)的右手操作数
cvcontour.cpp(321):error C2664:'push_back':无法将参数1从'int'转换为'const struct CvPoint&'
原因:无法从'int'转换为'const struct CvPoint'
没有构造函数可以接受源类型,或者构造函数重载解析不明确
cvcontour.cpp(322):error C2679:binary'!=':无操作符定义,它接受类型为'class'的右手操作数std :: deque< struct CvPoint,class std :: allocator< struct CvPoint>> :: iterator'(或没有可接受的转换)
cvcontour.cpp(322):fatal error C1903:以前的错误;停止编译

执行cl.exe时出错。



-------- UPDATE2 --------



此代码似乎工作正常! p>

  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; C2371 - VC6是局部变量的范围,它是一个很大的变量。C2371 - VC6。应该能够通过使代码明确使用变量名来解决这个问题。



C2664 - 看起来像使用deque迭代器初始化向量失败 - vector :: vector上的错误重载()被调用?



C2440 - 检查对象是否兼容(VS2008似乎认为这样),并添加适当的演员。



编辑:
您的代码不应该是这样吗?

  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);
}


I'm using Microsoft Visual C++ 6.0 and Microsoft Visual Studio 2008 to develop an academic computer vision project.

In this project i need to use OpenCV 1.1 (http://opencv.willowgarage.com/) and CvBlob (http://code.google.com/p/cvblob/).

I tried to compile this project with Microsoft Visual Studio 2008 and it compiles without errors.

With Visual C++ 6.0 i got a lot of errors.

OpenCV are not responsible of this behavior, because a trivial project with only OpenCV (without CvBlob) works well.

To understand the errors better I made an empty project with only the CvBlob inclusion.

I paste here a brief summary of the errors:

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

Have you ideas on how can i solve these problems?

Thanks in advance for the help!

-------- UPDATE --------

I tried to edit and correct the code in order to elminate the three errors in my question.

The error C2664 seems to be the more difficult to cirmumvent...

I have replaced the indicted line

return new CvContourPolygon(dq.begin(), dq.end());

where CvContourPolygon is a typedef std::vector<CvPoint> CvContourPolygon;

with

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++);
}

First, what that i wrote is correct? Than, how can i solve the errors that occured from this?

Thank you in advance!

Errors (suppose that the first line is 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

Error executing cl.exe.

-------- UPDATE2 --------

This code seems to work correctly!

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;

解决方案

C2371 - VC6 was sloppy with scope of local variables. Should be able to fix this by making the code use variable names unambiguously.

C2664 - looks like failure to initialize a vector using deque iterators - wrong overload on vector::vector() being called? Probably have to work around this by manually copying the deque elements to the new vector somehow.

C2440 - check the objects are compatible (VS2008 seems to think so) and add the appropriate cast.

EDIT: Shouldn't your code look like this?

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);
}

这篇关于Visual C ++ 6.0中的cvblob编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆