lagadic / visp

Open Source Visual Servoing Platform
https://visp.inria.fr/
GNU General Public License v2.0
725 stars 286 forks source link

How to remove single vpMbtDistanceLine from tracking #1218

Open constiDisch opened 1 year ago

constiDisch commented 1 year ago

Hi, i am quite new to visp and have the following question: I have a relatively complex cad model, which I wanted to load and track with the vpMbGenericTracker in particular the moving edge approach. However, I want more or less all faces in a visibility check, but be able to remove single lines individually based on other criteria (e.g. to use only lines which have faces with a large angle, or to focus on some very specific part if the model if visible, ...).

So my idea was to loop through the vpMbtDistanceLine and remove them from tracking (without removing the entire face from tracking, because this could have some side-effects to other lines).

Is there a way to achieve this? I found vpMbtDistanceLine.setTracked --> but it has some checks with the connected polygons. Thanks a lot for you hints.

fspindle commented 1 year ago

I suggest that you have a look to How to set a name to a face and How not to consider specific polygons.

constiDisch commented 1 year ago

Thanks for your hints. Perhaps I am missing something here, but I do not want to set an entire polygon as not tracked, but only a single line of polygon. Thus I was looking at the code in vpMbtDistanceLine::setTracked, but it seems to check whether all corresponding polygons are not tracked and then turn off the tracking. So is there a possibility to set tracked/not for an single edge? I think of something like an forceTrack (or similar)?

fspindle commented 1 year ago

The feature you are looking for is not implemented. I confirm that vpMbtDistanceLine::setTracked() consider all the edges of a single polygon. Introducing a way to enable/disable tracking of a single edge belonging to a polygon is possible, but will need to enter deeply in the code.

I didn't check enough, but it seems possible to modify vpMbtPolygon to add a function disableEdge(int index) that will disable a specific edge from tracking by setting for example a bool to true to the 2 vpPoints associated to the edge with index. For that, you should introduce a new private class member std::vector<bool> m_edgeDisabling that will have the same size as the vpPoint *p array. By default each element of the m_edgeDisabling is set to false.

// First edge has index 0
void vpMbtPolygon::setEdgeName(int index, const std::string &name)
{
  if (m_edgeDisabling != getNbPoint()) {
    m_edgeDisabling.resize(getNbPoint());
    for (size_t i = 0; i > m_edgeDisabling.size(); i++) {
      m_edgeDisabling[i] = false;
    }
  }
  m_edgeDisabling[i] = true;
  m_edgeDisabling[i + 1] = true;
}

Then, in vpMbtDistanceLine::initMovingEdge() you can use the bool to add or not the edge to the vector of meline.

Hope it helps

constiDisch commented 1 year ago

Thanks for your help and suggestions. I will have a try!