Skip to content

Enhancement discussion

Fabien Spindler edited this page May 5, 2017 · 6 revisions

vpMbtMeEllipse class

In vpMbtMeEllipse::reSample() there is the line

  if ((double)n<0.9*expecteddensity){

saying that we expect 90% of the expected moving-edges that should be tracked. This threshold sounds to high. We should analyse the behavior of the tracker when this value is reduced to 50% as it was done in vpMeEllipse class in commit https://github.com/lagadic/visp/commit/4b1c146d1ada50948d70a4b0fa7f1037d38c20f2

vpArray2D class

Behavior of vpArray2D::resize()

The purpose of this section is just to record the behavior of vpArray2D::resize() in some possibly edge cases (on gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609).

vpMatrix null_matrix(6,0);
std::cout << "(null_matrix.data == NULL)? " << (null_matrix.data == NULL) << std::endl;
null_matrix.resize(0,1);
std::cout << "(null_matrix.data == NULL)? " << (null_matrix.data == NULL) << std::endl;
null_matrix.resize(0,2);
std::cout << "(null_matrix.data == NULL)? " << (null_matrix.data == NULL) << std::endl;

(null_matrix.data == NULL)? 0

(null_matrix.data == NULL)? 1

(null_matrix.data == NULL)? 0

This comes from the behavior of realloc when new_size is zero:

If new_size is zero, the behavior is implementation defined (null pointer may be returned (in which case the old memory block may or may not be freed), or some non-null pointer may be returned that may not be used to access storage).

int* ptr = NULL;
ptr = (int*) realloc(ptr, 0);
std::cout << "(ptr==NULL)? " << (ptr==NULL) << std::endl;
ptr = (int*) realloc(ptr, 0);
std::cout << "(ptr==NULL)? " << (ptr==NULL) << std::endl;

(ptr==NULL)? 0

(ptr==NULL)? 1

At the end, there should be no problem with this behavior.

Dimension of vpColVector and vpRowVector:

  • colNum is always equal to one with vpColVector, when calling resize(0) dimension [row,col] is [0x1]
  • rowNum is always equal to one with vpRowVector, when calling resize(0) dimension [row,col] is [1x0]

The exceptions are when calling the default constructor:

vpColVector null_colvector;
std::cout << "null_colvector: " << null_colvector.getRows() << "x" << null_colvector.getCols() << std::endl;

null_colvector: 0x0

vpRowVector null_rowvector;
std::cout << "null_rowvector: " << null_rowvector.getRows() << "x" << null_rowvector.getCols() << std::endl;

null_rowvector: 0x0

When calling clear():

vpColVector colvector(5);
colvector.clear();
std::cout << "colvector: " << colvector.getRows() << "x" << colvector.getCols() << std::endl;

colvector: 0x0

vpRowVector rowvector(5);
rowvector.clear();
std::cout << "rowvector: " << rowvector.getRows() << "x" << rowvector.getCols() << std::endl;

rowvector: 0x0

This should not be a problem in general (there was a small bug but can be fixed easily) but can be standardized somehow.