double calcAccuracy(std::string line, cv::Rect bb_rect, cv::Rect &groundtruth_rect)
{
std::vector<float> numbers;
- std::istringstream s( line );
+ std::istringstream s(line);
float x;
char ch;
- while (s >> x){
+ while (s >> x) {
numbers.push_back(x);
s >> ch;
}
double y1 = std::min(numbers[1], std::min(numbers[3], std::min(numbers[5], numbers[7])));
double y2 = std::max(numbers[1], std::max(numbers[3], std::max(numbers[5], numbers[7])));
- groundtruth_rect = cv::Rect(x1, y1, x2-x1, y2-y1);
+ groundtruth_rect = cv::Rect(x1, y1, x2 - x1, y2 - y1);
double rects_intersection = (groundtruth_rect & bb_rect).area();
double rects_union = (groundtruth_rect | bb_rect).area();
- double accuracy = rects_intersection/rects_union;
+ double accuracy = rects_intersection / rects_union;
return accuracy;
}
{0, 0, 0, 0 }
};
- int c = getopt_long(argc, argv, "dhv::f::o:",
- long_options, &option_index);
+ int c = getopt_long(argc, argv, "dhv::f::o:", long_options, &option_index);
if (c == -1)
break;
visualize_delay = optarg ? atol(optarg) : 1;
break;
case 'f':
- std::string sizes = optarg ? optarg : "128x128";
- std::string delimiter = "x";
- size_t pos = sizes.find(delimiter);
- std::string first_argument = sizes.substr(0, pos);
- sizes.erase(0, pos + delimiter.length());
-
- fit_size_x = stol(first_argument);
- fit_size_y = stol(sizes);
+ if (!optarg) {
+ fit_size_x = fit_size_y = 128;
+ } else {
+ char tail;
+ if (sscanf(optarg, "%d%c", &fit_size_x, &tail) == 1) {
+ fit_size_y = fit_size_x;
+ } else if (sscanf(optarg, "%dx%d%c", &fit_size_x, &fit_size_y, &tail) != 2) {
+ fprintf(stderr, "Cannot parse -f argument: %s\n", optarg);
+ return 1;
+ }
+ }
+ int min_size = 2 * tracker.p_cell_size;
+ if (fit_size_x < min_size || fit_size_x < min_size) {
+ fprintf(stderr, "Fit size %dx%d too small. Minimum is %dx%d.\n",
+ fit_size_x, fit_size_y, min_size, min_size);
+ return 1;
+ }
break;
}
}