예제 #1
0
파일: main.cpp 프로젝트: proydakov/cppzone
void drawPolyline(pointList list)
{
    if(list.size() < 2)
        return;

    glBegin(GL_LINE_STRIP);
    {
        pointList::const_iterator endIt = list.end();
        for(pointList::const_iterator it = list.begin(); it != endIt; ++it) {
            glVertex2d(it->first, it->second);
        }
    }
    glEnd();
}
예제 #2
0
파일: main.cpp 프로젝트: proydakov/cppzone
void mouse(int button, int state, int x, int y)
{
    (void)x;
    (void)y;

    if(state != GLUT_DOWN)
        return;

    if(button == GLUT_LEFT_BUTTON) {
        g_pointList.push_back(point((GLfloat) x, (GLfloat) y));
        std::cout << "X : " << x << " | Y : " << y << std::endl;
    }

    if(button == GLUT_RIGHT_BUTTON)
        g_pointList.clear();

    std::cout << "DATA SIZE : " << g_pointList.size() << std::endl;

#ifdef __GNUC__
     display();
#endif // __GNUC__
}
  /*
   * find corners with maximal cornerness
   */
  bool harrisCorners::findCornerMaxima(const channel& cornerness,
                                             channel& cornersOnly,
                                             pointList& cornerMax) const {
    if (cornerness.empty()) {
      cornersOnly.clear();
      cornerMax.clear();
      return true;
    }

    const parameters& par = getParameters();

    const float corner = par.cornerValue/255.0f;
    const float noCorner = par.noCornerValue/255.0f;

    localMaxima<float> lmax;
    localMaxima<float>::parameters lmaxPar(par.localMaximaParameters);
    lmaxPar.noMaxValue = noCorner;
    lmaxPar.maxNumber = par.maximumCorners;
    lmax.setParameters(lmaxPar);

    if (lmax.apply(cornerness,cornersOnly,cornerMax)) {
      pointList::iterator it;
      int i;
      for (it=cornerMax.begin(),i=0;
           (it!=cornerMax.end());
           ++it) {
        cornersOnly.at(*it) = corner;
      }

      for (;it!=cornerMax.end();++it) {
        cornersOnly.at(*it) = noCorner;
      }

      return true;
    }
    return false;
  }
  /*
   * operates on a copy of the given %parameters.
   * @param src channel with the source data.
   * @param dest list of corners
   * @return true if apply successful or false otherwise.
   */
  bool harrisCorners::apply(const channel& src,pointList& dest) const {
    const parameters& param = getParameters();

    channel gx,gy,fxy,tmp,d;
    float maxCornerness;

    if (!gradient.apply(src,gx,gy)) {
      appendStatusString(gradient);
      dest.clear();
      return false;
    }
    getSecondOrder(gx,gy,fxy);
    getCornerness(gx,fxy,gy,param.scale,tmp,maxCornerness);
    return findCornerMaxima(tmp,d,dest);
  };