PlusLib  2.9.0
Software library for tracked ultrasound image acquisition, calibration, and processing.
PlusFidPatternRecognition.cxx
Go to the documentation of this file.
1 /*=Plus=header=begin======================================================
2 Program: Plus
3 Copyright (c) Laboratory for Percutaneous Surgery. All rights reserved.
4 See License.txt for details.
5 =========================================================Plus=header=end*/
6 
7 #include "PlusConfigure.h"
9 #include "vtkMath.h"
10 #include "vtkPoints.h"
11 #include "vtkLine.h"
12 
13 #include "vtkIGSIOTrackedFrameList.h"
14 #include "igsioTrackedFrame.h"
15 
16 static const double DOT_STEPS = 4.0;
17 static const double DOT_RADIUS = 6.0;
18 
19 //-----------------------------------------------------------------------------
20 
22 {
23 
24 }
25 
26 //-----------------------------------------------------------------------------
27 
29 {
30 }
31 
32 //-----------------------------------------------------------------------------
33 
34 PlusStatus PlusFidPatternRecognition::ReadConfiguration(vtkXMLDataElement* rootConfigElement)
35 {
36  LOG_TRACE("FidPatternRecognition::ReadConfiguration");
37 
38  if (ReadPhantomDefinition(rootConfigElement) != PLUS_SUCCESS)
39  {
40  LOG_ERROR("Reading phantom definition failed!");
41  return PLUS_FAIL;
42  }
43 
44  //Read the configuration in each of the component of the algorithm
45  m_FidSegmentation.ReadConfiguration(rootConfigElement);
46  m_FidLineFinder.ReadConfiguration(rootConfigElement);
48 
49  return PLUS_SUCCESS;
50 }
51 
52 //-----------------------------------------------------------------------------
53 
54 PlusStatus PlusFidPatternRecognition::RecognizePattern(igsioTrackedFrame* trackedFrame, PlusPatternRecognitionResult& patternRecognitionResult, PatternRecognitionError& patternRecognitionError, unsigned int frameIndex)
55 {
56  LOG_TRACE("FidPatternRecognition::RecognizePattern");
57 
58  patternRecognitionError = PATTERN_RECOGNITION_ERROR_NO_ERROR;
59 
60  if (RecognizePattern(trackedFrame, patternRecognitionError, frameIndex) != PLUS_SUCCESS)
61  {
62  LOG_ERROR("Recognizing pattern failed!");
63  return PLUS_FAIL;
64  }
65 
66  //Set the results
67  patternRecognitionResult.SetIntensity(m_FidLabeling.GetPatternIntensity());
68  patternRecognitionResult.SetNumDots(m_FidLabeling.GetDotsVector().size());
69  patternRecognitionResult.SetDotsFound(m_FidLabeling.GetDotsFound());
72 
73  return PLUS_SUCCESS;
74 }
75 
76 //-----------------------------------------------------------------------------
77 
78 PlusStatus PlusFidPatternRecognition::RecognizePattern(igsioTrackedFrame* trackedFrame, PatternRecognitionError& patternRecognitionError, unsigned int frameIndex)
79 {
80  LOG_TRACE("FidPatternRecognition::RecognizePattern");
81 
82  patternRecognitionError = PATTERN_RECOGNITION_ERROR_NO_ERROR;
83 
87 
88  m_FidSegmentation.SetFrameSize(trackedFrame->GetFrameSize());
89  m_FidLineFinder.SetFrameSize(trackedFrame->GetFrameSize());
90  m_FidLabeling.SetFrameSize(trackedFrame->GetFrameSize());
91 
92  if (trackedFrame->GetImageData()->GetVTKScalarPixelType() != VTK_UNSIGNED_CHAR)
93  {
94  LOG_ERROR("FidPatternRecognition::RecognizePattern only supports 8-bit images");
95  patternRecognitionError = PATTERN_RECOGNITION_ERROR_UNKNOWN;
96  return PLUS_FAIL;
97  }
98 
99  int bytes = trackedFrame->GetFrameSize()[0] * trackedFrame->GetFrameSize()[1] * sizeof(PlusFidSegmentation::PixelType);
100  PlusFidSegmentation::PixelType* image = reinterpret_cast<PlusFidSegmentation::PixelType*>(trackedFrame->GetImageData()->GetScalarPointer());
101 
102  memcpy(m_FidSegmentation.GetWorking(), image, bytes);
103  memcpy(m_FidSegmentation.GetUnalteredImage(), image, bytes);
104 
105  //Start of the segmentation
108  bool tooManyCandidates = false;
109  bool clusteringSuccessful = m_FidSegmentation.Cluster(tooManyCandidates);
110  if (tooManyCandidates)
111  {
112  patternRecognitionError = PATTERN_RECOGNITION_ERROR_TOO_MANY_CANDIDATES;
113  }
114  if (!clusteringSuccessful)
115  {
116  patternRecognitionError = PATTERN_RECOGNITION_ERROR_UNKNOWN;
117  }
118 
119  //End of the segmentation
120 
122 
126 
128 
129  if (m_FidLineFinder.GetLinesVector().size() > 3)
130  {
133  }
134 
136  {
137  //Displays the result dots
139  m_FidSegmentation.WritePossibleFiducialOverlayImage(m_FidSegmentation.GetCandidateFidValues(), m_FidSegmentation.GetUnalteredImage(), "candidateFiducials", frameIndex); //Display all candidates dots
140  }
141 
142  // Set results
143  std::vector< std::vector<double> > fiducials = m_FidLabeling.GetFoundDotsCoordinateValue();
144 
145  vtkSmartPointer<vtkPoints> fiducialPoints = vtkSmartPointer<vtkPoints>::New();
146  fiducialPoints->SetNumberOfPoints(fiducials.size());
147 
148  for (unsigned int i = 0; i < fiducials.size(); ++i)
149  {
150  fiducialPoints->InsertPoint(i, fiducials[i][0], fiducials[i][1], 0.0);
151  }
152  fiducialPoints->Modified();
153 
154  trackedFrame->SetFiducialPointsCoordinatePx(fiducialPoints);
155 
156  return PLUS_SUCCESS;
157 }
158 
159 //-----------------------------------------------------------------------------
160 
161 PlusStatus PlusFidPatternRecognition::RecognizePattern(vtkIGSIOTrackedFrameList* trackedFrameList, PatternRecognitionError& patternRecognitionError, int* numberOfSuccessfullySegmentedImages/*=NULL*/, std::vector<unsigned int>* segmentedFramesIndices)
162 {
163  LOG_TRACE("FidPatternRecognition::RecognizePattern");
164 
165  patternRecognitionError = PATTERN_RECOGNITION_ERROR_NO_ERROR;
166 
167  // Check if TrackedFrameList is MF oriented BRIGHTNESS image
168  if (vtkIGSIOTrackedFrameList::VerifyProperties(trackedFrameList, US_IMG_ORIENT_MF, US_IMG_BRIGHTNESS) != PLUS_SUCCESS)
169  {
170  LOG_ERROR("Failed to perform calibration - tracked frame list is invalid");
171  patternRecognitionError = PATTERN_RECOGNITION_ERROR_UNKNOWN;
172  return PLUS_FAIL;
173  }
174 
175  PlusStatus status = PLUS_SUCCESS;
176  if (numberOfSuccessfullySegmentedImages)
177  {
178  *numberOfSuccessfullySegmentedImages = 0;
179  }
180 
181  for (unsigned int currentFrameIndex = 0; currentFrameIndex < trackedFrameList->GetNumberOfTrackedFrames(); currentFrameIndex++)
182  {
183  igsioTrackedFrame* trackedFrame = trackedFrameList->GetTrackedFrame(currentFrameIndex);
184 
185  // segment only non segmented frames
186  if (trackedFrame->GetFiducialPointsCoordinatePx() != NULL)
187  {
188  continue;
189  }
190 
191  if (RecognizePattern(trackedFrame, patternRecognitionError, currentFrameIndex) != PLUS_SUCCESS)
192  {
193  if (patternRecognitionError != PATTERN_RECOGNITION_ERROR_TOO_MANY_CANDIDATES)
194  {
195  LOG_ERROR("Recognizing pattern failed on frame " << currentFrameIndex);
196  status = PLUS_FAIL;
197  }
198  }
199 
200  if (numberOfSuccessfullySegmentedImages)
201  {
202  // compute the number of successfully segmented images
203  if (trackedFrame->GetFiducialPointsCoordinatePx()
204  && trackedFrame->GetFiducialPointsCoordinatePx()->GetNumberOfPoints() > 0)
205  {
206  (*numberOfSuccessfullySegmentedImages)++;
207  if (segmentedFramesIndices != NULL)
208  {
209  segmentedFramesIndices->push_back(currentFrameIndex);
210  }
211  }
212  }
213  }
214 
215  return status;
216 }
217 
218 //-----------------------------------------------------------------------------
219 
221 {
222  LOG_TRACE("FidPatternRecognition::DrawDots");
223 
224  for (unsigned int d = 0; d < m_FidLabeling.GetFoundDotsCoordinateValue().size(); d++)
225  {
226  double row = m_FidLabeling.GetFoundDotsCoordinateValue()[d][1];
227  double col = m_FidLabeling.GetFoundDotsCoordinateValue()[d][0];
228 
229  for (double t = 0; t < 2 * vtkMath::Pi(); t += vtkMath::Pi() / DOT_STEPS)
230  {
231  int r = (int)floor(row + cos(t) * DOT_RADIUS);
232  int c = (int)floor(col + sin(t) * DOT_RADIUS);
233 
234  if (r >= 0 && static_cast<unsigned int>(r) < m_FidSegmentation.GetFrameSize()[1] && c >= 0 && static_cast<unsigned int>(c) < m_FidSegmentation.GetFrameSize()[0])
235  {
236  image[r * m_FidSegmentation.GetFrameSize()[0] + c] = UCHAR_MAX;
237  }
238  }
239 
240  image[static_cast<int>(floor(row)* m_FidSegmentation.GetFrameSize()[0] + floor(col))] = 0;
241  }
242 }
243 
244 //-----------------------------------------------------------------------------
245 
247 {
248  std::vector<PlusFidLine> foundLines = m_FidLabeling.GetFoundLinesVector();
249  DrawDots(image);
250 
251  LOG_TRACE("FidPatternRecognition::DrawLines");
252 
253  for (unsigned int l = 0; l < foundLines.size(); l++)
254  {
255  double origin[2] = { m_FidLabeling.GetDotsVector()[foundLines[l].GetStartPointIndex()].GetX() , m_FidLabeling.GetDotsVector()[foundLines[l].GetStartPointIndex()].GetY()};
256  double directionVector[2] = { foundLines[l].GetDirectionVector()[0], foundLines[l].GetDirectionVector()[1]};
257  if (directionVector[0] > 0)
258  {
259  directionVector[0] = -directionVector[0];
260  directionVector[1] = -directionVector[1];
261  }
262 
263  vtkMath::Normalize2D(directionVector);
264  double r = origin[1] - 0.2 * foundLines[l].GetLength() * directionVector[1];
265  double c = origin[0] - 0.2 * foundLines[l].GetLength() * directionVector[0];
266 
267  if (r >= 0 && r < m_FidSegmentation.GetFrameSize()[1] && c >= 0 && c < m_FidSegmentation.GetFrameSize()[0])
268  {
269  image[int(r * m_FidSegmentation.GetFrameSize()[0] + c)] = UCHAR_MAX;
270  }
271 
272  for (int i = 0 ; i < foundLines[l].GetLength() * 1.4 ; i++)
273  {
274  r += directionVector[1];
275  c += directionVector[0];
276  if (r >= 0 && r < m_FidSegmentation.GetFrameSize()[1] && c >= 0 && c < m_FidSegmentation.GetFrameSize()[0])
277  {
278  image[int(int(r)*m_FidSegmentation.GetFrameSize()[0] + c)] = UCHAR_MAX;
279  }
280  }
281  }
282 }
283 
284 //----------------------------------------------------------------------------
285 
287 {
289  for (unsigned int i = 0 ; i < m_FidLabeling.GetPatterns().size() ; i++)
290  {
291  m_FidLabeling.GetPatterns()[i]->SetDistanceToOriginToleranceElementMm(m_FidLabeling.GetPatterns()[i]->GetWires().size() - 1, m_MaxLineLengthToleranceMm);
292  }
293  for (unsigned int i = 0 ; i < m_FidLineFinder.GetPatterns().size() ; i++)
294  {
295  m_FidLineFinder.GetPatterns()[i]->SetDistanceToOriginToleranceElementMm(m_FidLineFinder.GetPatterns()[i]->GetWires().size() - 1, m_MaxLineLengthToleranceMm);
296  }
297 }
298 
299 //----------------------------------------------------------------------------
300 
302 {
303  LOG_TRACE("FidPatternRecognition::ReadPhantomDefinition");
304 
305  if (config == NULL)
306  {
307  LOG_ERROR("Configuration XML data element is NULL");
308  return PLUS_FAIL;
309  }
310 
311  bool nwireFlag = false;
312 
313  vtkXMLDataElement* phantomDefinition = config->FindNestedElementWithName("PhantomDefinition");
314  if (phantomDefinition == NULL)
315  {
316  LOG_ERROR("No phantom definition is found in the XML tree!");
317  return PLUS_FAIL;
318  }
319  else
320  {
321  std::vector<PlusFidPattern*> tempPatterns;
322 
323  // Load geometry
324  vtkXMLDataElement* geometry = phantomDefinition->FindNestedElementWithName("Geometry");
325  if (geometry == NULL)
326  {
327  LOG_ERROR("Phantom geometry information not found!");
328  return PLUS_FAIL;
329  }
330  else
331  {
332  // Finding of Patterns and extracting the endpoints
333  int numberOfGeometryChildren = geometry->GetNumberOfNestedElements();
334  for (int i = 0; i < numberOfGeometryChildren; ++i)
335  {
336  vtkXMLDataElement* patternElement = geometry->GetNestedElement(i);
337 
338  if ((patternElement == NULL) || (STRCASECMP("Pattern", patternElement->GetName())))
339  {
340  continue;
341  }
342 
343  PlusNWire* nWire = new PlusNWire();
344  PlusCoplanarParallelWires* coplanarParallelWires = new PlusCoplanarParallelWires();
345 
346  int numberOfWires = patternElement->GetNumberOfNestedElements();
347 
348  if ((numberOfWires != 3) && !(STRCASECMP("NWire", patternElement->GetAttribute("Type"))))
349  {
350  LOG_WARNING("NWire contains unexpected number of wires - skipped");
351  continue;
352  }
353 
354  for (int j = 0; j < numberOfWires; ++j)
355  {
356  vtkXMLDataElement* wireElement = patternElement->GetNestedElement(j);
357 
358  if (wireElement == NULL)
359  {
360  LOG_WARNING("Invalid wire description in Pattern - skipped");
361  break;
362  }
363 
364  PlusFidWire wire;
365 
366  const char* wireName = wireElement->GetAttribute("Name");
367  if (wireName != NULL)
368  {
369  wire.SetName(wireName);
370  }
371  if (! wireElement->GetVectorAttribute("EndPointFront", 3, wire.EndPointFront))
372  {
373  LOG_WARNING("Wrong wire end point detected - skipped");
374  continue;
375  }
376  if (! wireElement->GetVectorAttribute("EndPointBack", 3, wire.EndPointBack))
377  {
378  LOG_WARNING("Wrong wire end point detected - skipped");
379  continue;
380  }
381 
382  if (STRCASECMP("CoplanarParallelWires", patternElement->GetAttribute("Type")) == 0)
383  {
384  coplanarParallelWires->AddWire(wire);
385  }
386  else if (STRCASECMP("NWire", patternElement->GetAttribute("Type")) == 0)
387  {
388  nWire->AddWire(wire);
389  }
390  }
391 
392  if (STRCASECMP("CoplanarParallelWires", patternElement->GetAttribute("Type")) == 0)
393  {
394  tempPatterns.push_back(coplanarParallelWires);
395 
396  if (i == 1)
397  {
398  tempPatterns[i]->AddDistanceToOriginElementMm(0);
399  tempPatterns[i]->AddDistanceToOriginToleranceElementMm(0);
400  tempPatterns[i]->AddDistanceToOriginElementMm(10 * std::sqrt(2.0));
401  tempPatterns[i]->AddDistanceToOriginToleranceElementMm(2);
402  tempPatterns[i]->AddDistanceToOriginElementMm(20 * std::sqrt(2.0));
403  tempPatterns[i]->AddDistanceToOriginToleranceElementMm(2);
404  tempPatterns[i]->AddDistanceToOriginElementMm(30 * std::sqrt(2.0));
405  tempPatterns[i]->AddDistanceToOriginToleranceElementMm(2);
406  tempPatterns[i]->AddDistanceToOriginElementMm(40 * std::sqrt(2.0));
407  tempPatterns[i]->AddDistanceToOriginToleranceElementMm(2);
408  }
409  else
410  {
411  tempPatterns[i]->AddDistanceToOriginElementMm(0);
412  tempPatterns[i]->AddDistanceToOriginToleranceElementMm(0);
413  tempPatterns[i]->AddDistanceToOriginElementMm(10);
414  tempPatterns[i]->AddDistanceToOriginToleranceElementMm(2);
415  tempPatterns[i]->AddDistanceToOriginElementMm(20);
416  tempPatterns[i]->AddDistanceToOriginToleranceElementMm(2);
417  tempPatterns[i]->AddDistanceToOriginElementMm(30);
418  tempPatterns[i]->AddDistanceToOriginToleranceElementMm(2);
419  tempPatterns[i]->AddDistanceToOriginElementMm(40);
420  tempPatterns[i]->AddDistanceToOriginToleranceElementMm(2);
421  }
422  }
423  else if (STRCASECMP("NWire", patternElement->GetAttribute("Type")) == 0)
424  {
426  tempPatterns.push_back(nWire);
427 
428  tempPatterns[i]->AddDistanceToOriginElementMm(0);
429  tempPatterns[i]->AddDistanceToOriginToleranceElementMm(0);
430 
431  double originToMiddle[3] = {(tempPatterns[i]->GetWires()[1].EndPointBack[0] + tempPatterns[i]->GetWires()[1].EndPointFront[0]) / 2 - tempPatterns[i]->GetWires()[0].EndPointFront[0],
432  (tempPatterns[i]->GetWires()[1].EndPointBack[1] + tempPatterns[i]->GetWires()[1].EndPointFront[1]) / 2 - tempPatterns[i]->GetWires()[0].EndPointFront[1],
433  (tempPatterns[i]->GetWires()[1].EndPointBack[2] + tempPatterns[i]->GetWires()[1].EndPointFront[2]) / 2 - tempPatterns[i]->GetWires()[0].EndPointFront[2]
434  };
435 
436  double originToEnd[3] = {tempPatterns[i]->GetWires()[2].EndPointFront[0] - tempPatterns[i]->GetWires()[0].EndPointFront[0],
437  tempPatterns[i]->GetWires()[2].EndPointFront[1] - tempPatterns[i]->GetWires()[0].EndPointFront[1],
438  tempPatterns[i]->GetWires()[2].EndPointFront[2] - tempPatterns[i]->GetWires()[0].EndPointFront[2]
439  };
440 
441  vtkMath::Normalize(originToEnd);
442 
443  double dot = vtkMath::Dot(originToMiddle, originToEnd);
444  const double projectedMiddle[3] = {originToEnd[0]* dot, originToEnd[1]* dot, originToEnd[2]* dot};
445  double distMidToOrigin = vtkMath::Norm(projectedMiddle);
446 
447  tempPatterns[i]->AddDistanceToOriginElementMm(distMidToOrigin);
448  tempPatterns[i]->AddDistanceToOriginToleranceElementMm(15);
449 
450  double distEndToOrigin = sqrt((tempPatterns[i]->GetWires()[0].EndPointBack[0] - tempPatterns[i]->GetWires()[2].EndPointBack[0]) * (tempPatterns[i]->GetWires()[0].EndPointBack[0] - tempPatterns[i]->GetWires()[2].EndPointBack[0]) + (tempPatterns[i]->GetWires()[0].EndPointBack[1] - tempPatterns[i]->GetWires()[2].EndPointBack[1]) * (tempPatterns[i]->GetWires()[0].EndPointBack[1] - tempPatterns[i]->GetWires()[2].EndPointBack[1]));
451  tempPatterns[i]->AddDistanceToOriginElementMm(distEndToOrigin);
452  tempPatterns[i]->AddDistanceToOriginToleranceElementMm(m_MaxLineLengthToleranceMm);
453 
454  nwireFlag = true;
455  }
456  }
457  }
458 
459  if (nwireFlag)
460  {
461  // Read input NWires and convert them to vnl vectors to easier processing
462  LOG_DEBUG("Endpoints of wires = ");
463 
464  // List endpoints, check wire ids and NWire geometry correctness (wire order and locations) and compute intersections
465  for (unsigned int k = 0 ; k < tempPatterns.size() ; ++k)
466  {
467  unsigned int layer = k;
468 
469  for (int i = 0; i < 3; ++i)
470  {
471  vnl_vector<double> endPointFront(3);
472  vnl_vector<double> endPointBack(3);
473 
474  for (int j = 0; j < 3; ++j)
475  {
476  endPointFront[j] = tempPatterns[k]->GetWires()[i].EndPointFront[j];
477  endPointBack[j] = tempPatterns[k]->GetWires()[i].EndPointBack[j];
478  }
479 
480  LOG_DEBUG("\t Front endpoint of wire " << i << " on layer " << layer << " = " << endPointFront);
481  LOG_DEBUG("\t Back endpoint of wire " << i << " on layer " << layer << " = " << endPointBack);
482  }
483 
484  /*if (sumLayer != layer * 9 + 6)
485  {
486  LOG_ERROR("Invalid NWire IDs (" << tempPatterns[k]->Wires[0].id << ", " << tempPatterns[k]->Wires[1].id << ", " << tempPatterns[k]->Wires[2].id << ")!");
487  return PLUS_FAIL;
488  }*/
489 
490  // Check if the middle wire is the diagonal (the other two are parallel to each other and the first and the second, and the second and the third intersect)
491  double wire1[3];
492  double wire3[3];
493  double cross[3];
494 
495  vtkMath::Subtract(tempPatterns[k]->GetWires()[0].EndPointFront, tempPatterns[k]->GetWires()[0].EndPointBack, wire1);
496  vtkMath::Subtract(tempPatterns[k]->GetWires()[2].EndPointFront, tempPatterns[k]->GetWires()[2].EndPointBack, wire3);
497  vtkMath::Cross(wire1, wire3, cross);
498  if (vtkMath::Norm(cross) > 0.001)
499  {
500  LOG_ERROR("The first and third wire of layer " << layer << " are not parallel!");
501  return PLUS_FAIL;
502  }
503  double closestTemp[3];
504  double parametricCoord1, parametricCoord2;
505 
506  PlusNWire* tempNWire = (PlusNWire*)(tempPatterns[k]);
507 
508  // const_cast because vtk classes don't have proper const-ness
509  if (vtkLine::DistanceBetweenLines(
510  const_cast<double*>(tempNWire->GetWires()[0].EndPointFront),
511  const_cast<double*>(tempNWire->GetWires()[0].EndPointBack),
512  const_cast<double*>(tempNWire->GetWires()[1].EndPointFront),
513  const_cast<double*>(tempNWire->GetWires()[1].EndPointBack),
514  tempNWire->IntersectPosW12, closestTemp, parametricCoord1, parametricCoord2) > 0.000001)
515  {
516  LOG_ERROR("The first and second wire of layer " << layer << " do not intersect each other!");
517  return PLUS_FAIL;
518  }
519  if (vtkLine::DistanceBetweenLines(
520  const_cast<double*>(tempNWire->GetWires()[2].EndPointFront),
521  const_cast<double*>(tempNWire->GetWires()[2].EndPointBack),
522  const_cast<double*>(tempNWire->GetWires()[1].EndPointFront),
523  const_cast<double*>(tempNWire->GetWires()[1].EndPointBack),
524  tempNWire->IntersectPosW32, closestTemp, parametricCoord1, parametricCoord2) > 0.000001)
525  {
526  LOG_ERROR("The second and third wire of layer " << layer << " do not intersect each other!");
527  return PLUS_FAIL;
528  }
529  }
530 
531  /*// Log the data pipeline if requested.
532  int layer;
533  for (int i=0, layer = 0; i<tempPatterns.size(); ++i, ++layer)
534  {
535  LOG_DEBUG("\t Intersection of wire 1 and 2 in layer " << layer << " \t= (" << it->IntersectPosW12[0] << ", " << it->IntersectPosW12[1] << ", " << it->IntersectPosW12[2] << ")");
536  LOG_DEBUG("\t Intersection of wire 3 and 2 in layer " << layer << " \t= (" << it->IntersectPosW32[0] << ", " << it->IntersectPosW32[1] << ", " << it->IntersectPosW32[2] << ")");
537  }*/
538  }
539 
540  m_Patterns = tempPatterns;
543  }
544 
545  return PLUS_SUCCESS;
546 }
547 
548 //----------------------------------------------------------------------------
549 
551 {
552  int numWires(0);
553  for (std::vector<PlusFidPattern*>::iterator it = m_FidLabeling.GetPatterns().begin(); it != m_FidLabeling.GetPatterns().end(); ++it)
554  {
555  numWires += (*it)->GetWires().size();
556  }
557  if (aValue < numWires)
558  {
559  LOG_WARNING("Number of maximum fiducial point candidates is smaller than the number of wires contained in the pattern.");
560  }
562 }
PlusStatus ReadPhantomDefinition(vtkXMLDataElement *rootConfigElement)
void SetLinesVector(std::vector< std::vector< PlusFidLine > > &value)
std::vector< PlusFidPattern * > & GetPatterns()
void SetNumberOfMaximumFiducialPointCandidates(int aValue)
std::vector< PlusFidPattern * > & GetPatterns()
int
Definition: phidget22.h:3069
double GetPatternIntensity()
void DrawDots(PlusFidSegmentation::PixelType *image)
igsioStatus PlusStatus
Definition: PlusCommon.h:40
void SetNumberOfMaximumFiducialPointCandidates(int aMax)
PlusStatus ReadConfiguration(vtkXMLDataElement *rootConfigElement)
void WritePossibleFiducialOverlayImage(const std::vector< std::vector< double > > &fiducials, PlusFidSegmentation::PixelType *unalteredImage, const char *namePrefix, int frameIndex)
void SetName(const std::string &aName)
for i
PlusFidSegmentation::PixelType * GetUnalteredImage()
#define PLUS_FAIL
Definition: PlusCommon.h:43
void SetFrameSize(const FrameSizeType &frameSize)
void SetPatterns(const std::vector< PlusFidPattern * > &value)
void SetCandidateFidValues(std::vector< PlusFidDot > value)
void SetDotsVector(std::vector< PlusFidDot > &value)
#define PLUS_SUCCESS
Definition: PlusCommon.h:44
void SetFrameSize(const FrameSizeType &frameSize)
void SetCandidateFidValues(const std::vector< PlusFidDot > &value)
std::vector< PlusFidDot > & GetDotsVector()
static const double DOT_RADIUS
void SetDotsVector(const std::vector< PlusFidDot > &value)
std::vector< PlusFidDot > & GetCandidateFidValues()
std::vector< std::vector< double > > GetFoundDotsCoordinateValue()
const std::vector< PlusFidWire > & GetWires() const
bool Cluster(bool &tooManyCandidates)
const char const char * value
Definition: phidget22.h:5111
void SetFoundDotsCoordinateValue(std::vector< std::vector< double > > value)
PlusStatus ReadConfiguration(vtkXMLDataElement *rootConfigElement, double minThetaRad, double maxThetaRad)
std::vector< std::vector< PlusFidLine > > & GetLinesVector()
std::vector< PlusFidPattern * > m_Patterns
void AddWire(const PlusFidWire &wire)
std::vector< PlusFidLine > & GetFoundLinesVector()
void DrawResults(PlusFidSegmentation::PixelType *image)
PlusStatus ReadConfiguration(vtkXMLDataElement *rootConfigElement)
void SetFrameSize(const FrameSizeType &frameSize)
PlusStatus RecognizePattern(vtkIGSIOTrackedFrameList *trackedFrameList, PatternRecognitionError &patternRecognitionError, int *numberOfSuccessfullySegmentedImages=NULL, std::vector< unsigned int > *segmentedFramesIndices=NULL)
static const double DOT_STEPS
void SetPatterns(const std::vector< PlusFidPattern * > &value)
void SetCandidateFidValues(const std::vector< PlusFidDot > &value)
PlusFidSegmentation::PixelType * GetWorking()
for t
Definition: exploreFolders.m:9
void Suppress(PlusFidSegmentation::PixelType *image, double percent_thresh)
std::vector< PlusFidDot > & GetDotsVector()
void SetMaxLineLengthToleranceMm(double value)
FrameSizeType GetFrameSize()
PlusStatus ReadConfiguration(vtkXMLDataElement *rootConfigElement)