/*!
  Detect using the cascade classifier.

  \param I: Grayscale image.
  \param func: Function pointer to eliminate detections according to specific criterion
  \param scaleFactor: Parameter specifying how much the image size is reduced at each image scale.
  \param minNeighbors: Parameter specifying how many neighbors each candidate rectangle should have to retain it.
  \param minSize: Minimum possible object size. Objects smaller than that are ignored.
  \param maxSize: Maximum possible object size. Objects larger than that are ignored.
*/
void vpCascadeClassifier::detect(const vpImage<unsigned char> &I,
    bool (*func)(const vpImage<unsigned char> &I, const vpRect &boundingBox),
    const double scaleFactor, const int minNeighbors, const cv::Size &minSize, const cv::Size &maxSize) {

  if (m_classifierDetector.empty()) {
    clear();
    throw vpException(vpException::fatalError, "Empty classifier !");
  }

  if(m_prevI.getWidth() == 0 || m_prevI.getHeight() == 0) {
    m_prevI = I;
  }

  computeDetection(I, scaleFactor, minNeighbors, minSize, maxSize);

  //Custom supplied filtering
  if(func != NULL) {
    for(std::vector<vpRect>::iterator it = m_objectBoundingBoxes.begin(); it != m_objectBoundingBoxes.end();) {
      if(!func(I, *it)) {
        m_vectorOfDetectedObjects.push_back(vpObjectDetection(*it, vpObjectDetection::FILTERED_STATUS));
        it = m_objectBoundingBoxes.erase(it);
      } else {
        ++it;
      }
    }
  }

  computeMatching(I);

  m_prevI = I;
}
Beispiel #2
0
int main(int argc, char *argv[])
{
    // Read command line files 
    
    // Init cuda
    CUcontext cuContext;
    initCuda(cuContext); 

    // Image buffer allocation
    unsigned int depth =4;
    unsigned int width=960;
    unsigned int height=1080;
    size_t bufferSize = sizeof(unsigned char)*width*height*depth;
    unsigned char *imgRight = (unsigned char*)malloc(bufferSize);
    unsigned char *imgLeft= (unsigned char*)malloc(bufferSize);

    // Read the list of test files
    std::vector<std::string> testsFiles;
    readTestsFiles(testsFiles, "./tests.txt");
   
    // Launch tests 
    for(int i=0; i<testsFiles.size(); i++)
    {
        std::stringstream testImage1;
        testImage1 << "./" << testsFiles[i] << "_1.dat";
        std::stringstream testImage2;
        testImage2 << "./" << testsFiles[i] << "_2.dat";
        
        readTestImage( testImage1.str(), imgRight, bufferSize);
        readTestImage( testImage2.str(), imgLeft, bufferSize);
        
        VertexBufferObject rightPoints;
        VertexBufferObject leftPoints;
        DescriptorData  rightDescriptors;
        DescriptorData  leftDescriptors;
        computeDescriptorsLane(imgRight, depth, width, height, rightPoints, rightDescriptors);
        computeDescriptorsLane(imgLeft, depth, width, height, leftPoints, leftDescriptors);
        
        UInt2 imgSize(1920,1080);

        vector<CvPoint2D32f> leftMatchedPts;
        vector<CvPoint2D32f> rightMatchedPts;
        leftMatchedPts.reserve(10000);
        rightMatchedPts.reserve(10000);
        computeMatching( leftDescriptors, rightDescriptors, leftMatchedPts, rightMatchedPts, imgSize);
    }
    
    // finalize cuda
    CUresult cerr = cuCtxDestroy(cuContext);
    checkError(cerr);
    return 0;    
}