void TrainBase::view(std::string img_url, int num_pts) { // load image IplImage *img = cvLoadImage(img_url.c_str(), 0); IplImage *img_color = cvLoadImage(img_url.c_str(), 1); if (!img) STDOUT_ERROR("Cannot open file: " + img_url); printf("w=%d, h=%d; cw=%d, ch=%d\n", img->width, img->height,img_color->width, img_color->height); // detect keypoints std::vector<Keypoint> det_kpts; StarDetector det(cvSize(img->width, img->height),8,10); std::insert_iterator< std::vector<Keypoint> > inserter(det_kpts,det_kpts.begin()); printf("Detecting points\n"); det.DetectPoints(img, inserter); printf("[OK] %i keypoints detected.\n", det_kpts.size()); // sort descending on response magnitude and pick num_pts std::sort(det_kpts.begin(), det_kpts.end()); // show detected points std::vector<features::BaseKeypoint> base_kpts; features::BaseKeypoint helper(0,0,img); int count = 0; BOOST_FOREACH(Keypoint k, det_kpts) { cvCircle(img_color, cvPoint(k.x,k.y), 3+(1<<k.s), CV_RGB(0,255,0)); helper.x = k.x; helper.y = k.y; base_kpts.push_back(helper); if (++count >= num_pts) break; }
static void sample(T* tests, int cnt, int patch_sz, int type) { switch (type) { case 0: // uniform random, i.i.d. sampleUniform(tests, patch_sz, cnt); break; case 1: // Gaussian random, i.i.d. sampleGaussian(tests, patch_sz, cnt); break; default: STDOUT_ERROR("Bad sample type"); } }