Bonjour,
Voila un bon moment que je cherche d'où peut venir ma fuite mémoire sans succès:cry: je n'arrive vraiment pas à voir où j'ai pu faire une connerie...
Voici mon code :
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 void Image::_first_scan () throw () { IplImage* hsv_image = cvCreateImage (cvGetSize (this->_image), this->_image->depth, Image::CHANNEL_HSV); int span_id = 0; int hue_colorised = 0; cvCvtColor (this->_image, hsv_image, CV_BGR2HSV); for (int row=0;row<hsv_image->height;row++) { for (int col=0;col<hsv_image->width;col++) { CvScalar currentPixel = cvGet2D (hsv_image, row, col); if (((int)currentPixel.val[1] >= Image::MIN_SATURATION && (int)currentPixel.val[1] <= Image::MAX_SATURATION) && ((int)currentPixel.val[2] >= Image::MIN_VALUE && (int)currentPixel.val[2] <= Image::MAX_VALUE) && ((int)currentPixel.val[0] == this->_best_hue)) { span_id++; this->_pixel (row, col).initialize (PersoTypes::BEST, span_id); this->_listSpan.insert (std::make_pair (span_id, new Span (Image::NOT_GOOD_COLOUR, Image::BEST_COLOUR, hue_colorised, Point (col, row)))); hue_colorised = (hue_colorised + 1) % 180; } else { this->_pixel (row, col).initialize (PersoTypes::WRONG, Image::WRONG_COLOUR); } } } cvReleaseImage (&hsv_image); } Image::~Image () throw () { for (int i=0;i<Image::HEIGHT+1;i++) { delete [] this->_pixels[i]; } delete [] this->_pixels; if (this->_image != 0) { cvReleaseImage (&this->_image); } for (std::map<int, Span *>::const_iterator it=this->_listSpan.begin ();it!=this->_listSpan.end ();it++) { delete it->second; } }
Le problème vient de la ligne :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 #include "Span.h" Span::Span () throw () : _nb_good (0), _nb_best (0), _hue (0) { // nothing to do } Span::Span (int newNbGood, int newNbBest, int newHue, const Point& coordinate) throw () : _nb_good (newNbGood), _nb_best (newNbBest), _hue (newHue) { this->_content.push_back (coordinate); } Span::~Span () throw () { // nothing to do } int Span::hue () const throw () { return this->_hue; } int Span::sum () const throw () { return this->_nb_good + this->_nb_best; } void Span::merge (const Point& coordinate, PersoTypes::States state) throw () { this->_content.push_back (coordinate); if (state == PersoTypes::BEST) { this->_nb_best++; } else { this->_nb_good++; } } CvPoint Span::sumCoordinate () const throw () { int sum_x = 0; int sum_y = 0; for (int i=0;i<this->_content.size ();i++) { sum_x += this->_content.at (i).x; sum_y += this->_content.at (i).y; } return cvPoint (sum_x / this->sum (), sum_y / this->sum ()); } PersoTypes::ListPoints Span::content () const throw () { return this->_content; }
Pour l'objet "Span"Code:this->_listSpan.insert (std::make_pair (span_id, new Span (Image::NOT_GOOD_COLOUR, Image::BEST_COLOUR, hue_colorised, Point (col, row))));
Voyez vous quelque part où cela cloche ? Merci d'avance :)
Le problème vient de