probleme avec constructeur
Bonjour,
comme indiqué j'ai un problème avec mon constructeur lorsque j'essaie de créer une classe. (je code sur Microsoft Visual Studio 2010)
J'ai créé une classe Line_hough dans le but d'utiliser une transformé de Hough
Et en fonction de mes sources j'obtiens plusieurs manières de créer un constructeur :
Code:
1 2 3 4 5 6 7
| Line_hough::Line_hough(){
deltaRho=1;
deltaTheta=PI/180;
minVote=10;
minLength=0;
maxGap=0;
} |
m'indique le problème suivant :
1>c:\documents and settings\sy_r\mes documents\visual studio 2010\projects\open_cv\open_cv\line_hough.cpp(27): error C3254: 'Line_Hough'*: la classe contient une substitution explicite '{ctor}', mais ne dérive pas d'une interface qui contient la déclaration de fonction
1>c:\documents and settings\sy_r\mes documents\visual studio 2010\projects\open_cv\open_cv\line_hough.cpp(27): error C2838: '{ctor}'*: nom qualifié non conforme dans une déclaration de membre
1>c:\documents and settings\sy_r\mes documents\visual studio 2010\projects\open_cv\open_cv\line_hough.cpp(67): fatal error C1004: fin de fichier inattendue rencontrée
Code:
1 2 3 4 5 6 7
| Line_hough(){
deltaRho=1;
deltaTheta=PI/180;
minVote=10;
minLength=0;
maxGap=0;
} |
==>
1>c:\documents and settings\sy_r\mes documents\visual studio 2010\projects\open_cv\open_cv\line_hough.cpp(27): error C4430: spécificateur de type manquant - int est pris en compte par défaut. Remarque*: C++ ne prend pas en charge int par défaut
1>c:\documents and settings\sy_r\mes documents\visual studio 2010\projects\open_cv\open_cv\line_hough.cpp(33): warning C4183: 'Line_hough'*: type de retour manquant*; fonction membre retournant 'int' prise par défaut
1>c:\documents and settings\sy_r\mes documents\visual studio 2010\projects\open_cv\open_cv\line_hough.cpp(67): fatal error C1004: fin de fichier inattendue rencontrée
Code:
Line_hough():deltaRho(1), deltaTheta(PI/180), minVote(10), minLength(0), maxGap(0){}
==>
1>c:\documents and settings\sy_r\mes documents\visual studio 2010\projects\open_cv\open_cv\line_hough.cpp(25): error C2590: 'Line_hough' : seul un constructeur peut avoir une liste d'initialiseurs de base/membre
1>c:\documents and settings\sy_r\mes documents\visual studio 2010\projects\open_cv\open_cv\line_hough.cpp(67): fatal error C1004: fin de fichier inattendue rencontrée
Je ne comprend pas trop la différence entre ces méthodes et pourquoi elles ne fonctionnent pas ?
Cordialement,
Ronan
Voici le code complet du .cpp :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
| #include "Line_hough.h"
# include "cv.h"
# include "highgui.h"
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <string>
using namespace cv;
using namespace std;
class Line_Hough{
cv::Mat img;
std::vector<Vec4i> lines;
double deltaRho;
double deltaTheta;
int minVote;
double minLength;
double maxGap;
Line_hough():deltaRho(1), deltaTheta(PI/180), minVote(10), minLength(0), maxGap(0){}
/*Line_hough(){
deltaRho=1;
deltaTheta=PI/180;
minVote=10;
minLength=0;
maxGap=0;
}*/
void setAccResolution(double dRho, double dTheta){
this->deltaRho=dRho;
this->deltatTheta=dTheta;
}
void setMinvote(int minv){
this->minVote=minv;
}
void setLineLengthAndGap(double length, double gap){
this->minLength=length;
this->maxGap=gap;
}
std::vector<Vec4i> findLines(Mat& binary){
lines.clear();
HoughLinesP(binary,lines,deltaRho,deltaTheta,minVote,minLength,maxGap);
return lines;
}
void drawDetectedLines(Mat &image,Scalar color=cv::Scalar(255,255,255)){
std::vector<Vec4i>::const_iterator it2=lines.begin();
while(it2!=lines.end()){
Point pt1((*it2)[0],(-it2)[1]);
Point pt2((*it2)[2],(*it2)[3]);
line(image,pt1,pt2,color);
++it2;
}
}
} |
et voici le code complet du .h :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| #ifndef LINE_HOUGH_H
#define LINE_HOUGH_H
# include "cv.h"
# include "highgui.h"
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <string>
using namespace cv;
#define PI 3.1415926;
class Line_hough
{
public:
Line_hough();
void setAccResolution(double dRho, double dTheta);
void setMinvote(int minv);
void setLineLengthAndGap(double length, double gap);
std::vector<Vec4i> findLines(Mat& binary);
void drawDetectedLines(Mat& image,Scalar color=Scalar(255,255,255));
};
#endif |