inline
void place_cell_generator::setFiringRate()
{
    // rate is in Hz, dt in ms, so we have to convert from s to ms
    double sim_dt = Time::get_resolution().get_ms();
    poisson_dev_.set_lambda(sim_dt * P_.rate * 1e-3 * gaussianFunction());
}
std::vector<BoundingBox> PedestrianDetector::detectWCandidates(std::vector<BoundingBox> &candidates, 
                                        const std::vector<cv::Mat> &pyramid_images,
                                        const std::vector<float> &pyramid_scales,
                                        const float hit_threshold) {

    std::vector<BoundingBox> detections;

    // for all the levels of the pyramid ...
    for (int l=0; l<pyramid_images.size(); ++l) {
        // ... search for candidates at this level and put them on search locations.
        std::cout << "LEVEL: " << l;
        std::cout << "  pyramid_scales[l]: " << pyramid_scales[l] << std::endl;
        // TODO: obviously I could order them by scale and reduce the complexity of this.
        std::vector<cv::Point> search_locations;
        for (int i=0; i<candidates.size(); ++i) { 
            
            if (l == candidates[i].pyramid_level) {
                // see if the bounding box of at this level will correspond to a
                // good approximation of the bounding box in the candidate
                float det_size_scale = det_size.height/pyramid_scales[l];
                // std::cout << "level in pyramid " << l << std::endl;
                // std::cout << "det at this scale representation height: " << det_size_scale << std::endl;
                // std::cout << "bb height " << candidates[i].bb.height << std::endl;

                // add candidate to search_location (top-left point)
                cv::Point pt = candidates[i].bb.tl()*pyramid_scales[l];
                search_locations.push_back(pt);
            }
        }

        std::cout << "search_locations size" << search_locations.size() << std::endl;

        if (search_locations.size() > 0) {
            // detect in this level.
            std::vector<cv::Point> found;
            std::vector<double> weights;
            hog.detect(pyramid_images[l], found, weights, hit_threshold, cv::Size(), cv::Size(), search_locations);

            // std::cout << std::endl << "Search: ";
            // for (int i=0; i<search_locations.size(); ++i) {
            //     std::cout << search_locations[i] << " ";
            // }
            // std::cout << std::endl << "Found: ";
            cv::Size det_size_l(det_size); // size of detector in this level
            det_size_l.width /= pyramid_scales[l];
            det_size_l.height /= pyramid_scales[l];
            for (int i = 0; i < found.size(); ++i) {
                BoundingBox bb;

                // find candidate to compute the score using gaussian weighthing
                for (int j=0; j<candidates.size(); ++j) {
                    if (found[i] == candidates[j].bb.tl()*pyramid_scales[l]) {
                        // add weight for non max suppression.
                        double new_score = weights[i]*gaussianFunction(1.800, 0.300, candidates[j].world_height);
                        bb.score = new_score;
                        //std::cout << "det " << i << "score "<< new_score << std::endl;
                    }
                }

                // bb.score = weights[i];
                cv::Point f = found[i];
                f.x /= pyramid_scales[l];
                f.y /= pyramid_scales[l];
                bb.bb = cv::Rect(f, det_size_l);

                detections.push_back(bb);

            }    
        }
        
    }

    return detections;
}