Merge commit '1acc1085d' into merge-2.4

This commit is contained in:
Roman Donchenko 2013-12-30 16:37:39 +04:00
commit 0e552ea6e2
2 changed files with 43 additions and 1 deletions

View File

@ -297,6 +297,11 @@ public:
trees_ = get_param(params,"trees",4); trees_ = get_param(params,"trees",4);
root = new NodePtr[trees_]; root = new NodePtr[trees_];
indices = new int*[trees_]; indices = new int*[trees_];
for (int i=0; i<trees_; ++i) {
root[i] = NULL;
indices[i] = NULL;
}
} }
HierarchicalClusteringIndex(const HierarchicalClusteringIndex&); HierarchicalClusteringIndex(const HierarchicalClusteringIndex&);
@ -309,11 +314,34 @@ public:
*/ */
virtual ~HierarchicalClusteringIndex() virtual ~HierarchicalClusteringIndex()
{ {
free_elements();
if (root!=NULL) {
delete[] root;
}
if (indices!=NULL) { if (indices!=NULL) {
delete[] indices; delete[] indices;
} }
} }
/**
* Release the inner elements of indices[]
*/
void free_elements()
{
if (indices!=NULL) {
for(int i=0; i<trees_; ++i) {
if (indices[i]!=NULL) {
delete[] indices[i];
indices[i] = NULL;
}
}
}
}
/** /**
* Returns size of index. * Returns size of index.
*/ */
@ -348,6 +376,9 @@ public:
if (branching_<2) { if (branching_<2) {
throw FLANNException("Branching factor must be at least 2"); throw FLANNException("Branching factor must be at least 2");
} }
free_elements();
for (int i=0; i<trees_; ++i) { for (int i=0; i<trees_; ++i) {
indices[i] = new int[size_]; indices[i] = new int[size_];
for (size_t j=0; j<size_; ++j) { for (size_t j=0; j<size_; ++j) {
@ -387,6 +418,17 @@ public:
load_value(stream, centers_init_); load_value(stream, centers_init_);
load_value(stream, leaf_size_); load_value(stream, leaf_size_);
load_value(stream, memoryCounter); load_value(stream, memoryCounter);
free_elements();
if (root!=NULL) {
delete[] root;
}
if (indices!=NULL) {
delete[] indices;
}
indices = new int*[trees_]; indices = new int*[trees_];
root = new NodePtr[trees_]; root = new NodePtr[trees_];
for (int i=0; i<trees_; ++i) { for (int i=0; i<trees_; ++i) {

View File

@ -364,7 +364,7 @@ CV_INLINE double cvContourPerimeter( const void* contour )
} }
/* Calculates contour boundning rectangle (update=1) or /* Calculates contour bounding rectangle (update=1) or
just retrieves pre-calculated rectangle (update=0) */ just retrieves pre-calculated rectangle (update=0) */
CVAPI(CvRect) cvBoundingRect( CvArr* points, int update CV_DEFAULT(0) ); CVAPI(CvRect) cvBoundingRect( CvArr* points, int update CV_DEFAULT(0) );