/*
* Find Playground in image and calc its Extrinsics
*/
bool PlaygroundDetector::detect(const cv::Mat &image, Playground &playground, Contours &candidateContours, aruco::CameraParameters &cameraParameters)
{
  // pg not valid
  playground.id = -1;

  // get all contours from color thres image
  Contours contours;
  findContours(image, contours);
  
  // search for L shaped contours
  filterContours(contours, candidateContours);
  
    if(candidateContours.size() < 4) return false;
  
  // combine exatly 4 L-contours to one rectangle with 4 corners
  std::vector<cv::Point2f> corners; // max length: 4
  extractPlayGroundCorners(candidateContours, corners);
  
    if(corners.size() != 4) return false;
  
  playground.resize(4); 
  std::copy(corners.begin(), corners.end(), playground.begin());
  
  // playground valid
  playground.id = 0;
  
  // calc translation and rotation
  playground.calculateExtrinsics(cameraParameters);
  
  return true;
}