Beispiel #1
0
void LatentSvmDetector::detect( const Mat& image,
                                std::vector<ObjectDetection>& objectDetections,
                                float overlapThreshold,
                                int numThreads )
{
    objectDetections.clear();
    if( numThreads <= 0 )
        numThreads = 1;

    for( size_t classID = 0; classID < detectors.size(); classID++ )
    {
        IplImage image_ipl = image;
        CvMemStorage* storage = cvCreateMemStorage(0);
        CvSeq* detections = cvLatentSvmDetectObjects( &image_ipl, detectors[classID], storage, overlapThreshold, numThreads );

        // convert results
        objectDetections.reserve( objectDetections.size() + detections->total );
        for( int detectionIdx = 0; detectionIdx < detections->total; detectionIdx++ )
        {
            CvObjectDetection detection = *(CvObjectDetection*)cvGetSeqElem( detections, detectionIdx );
            objectDetections.push_back( ObjectDetection(Rect(detection.rect), detection.score, (int)classID) );
        }

        cvReleaseMemStorage( &storage );
    }
}
        int64 start = 0, finish = 0;
#ifdef HAVE_TBB
        tbb::task_scheduler_init init(tbb::task_scheduler_init::deferred);
        if (numThreads > 0)
        {
            init.initialize(numThreads);
            printf("Number of threads %i\n", numThreads);
        }
        else
        {
            printf("Number of threads is not correct for TBB version");<<std::endl;
            return;
        }
#endif
        start = cvGetTickCount();
        detections = cvLatentSvmDetectObjects(image, this->detector, storage, 0.3f, numThreads);
        finish = cvGetTickCount();
        printf("++++++++++\ndetection time = %.3f\n", (float)(finish - start) / (float)(cvGetTickFrequency() * 1000000.0));
#ifdef HAVE_TBB
        init.terminate();
#endif
        preHists=currHists;
        currHists.clear();

        for(int i = 0; i<tracked.size(); i++)
        {
            tracked[i].fresh = false;
        }

        if(depth_ptr!=NULL)
        {