Skip to content

Commit

Permalink
added new --discard-estimating-constant option, and a new car model
Browse files Browse the repository at this point in the history
  • Loading branch information
liuliu committed Oct 2, 2012
1 parent df5025e commit e53a7df
Show file tree
Hide file tree
Showing 6 changed files with 163 additions and 22 deletions.
44 changes: 26 additions & 18 deletions bin/dpmcreate.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ void exit_with_help()
" --negative-cache-size : the cache size for negative examples it should be smaller than negative-count and larger than 100 [DEFAULT TO 2000]\n"
" --include-overlap : the percentage of overlap between expected bounding box and the bounding box from detection. Beyond this threshold, it is ensured to be the same object [DEFAULT TO 0.7]\n"
" --grayscale : 0 or 1, whether to exploit color in a given image [DEFAULT TO 0]\n"
" --discard-estimating-constant : 0 or 1, when estimating bounding boxes, discarding constant (which may be accumulated error) [DEFAULT TO 1]\n"
" --percentile-breakdown : 0.00 - 1.00, the percentile use for breakdown threshold [DEFAULT TO 0.05]\n\n"
);
exit(-1);
Expand Down Expand Up @@ -60,6 +61,7 @@ int main(int argc, char** argv)
{"percentile-breakdown", 1, 0, 0},
{"include-overlap", 1, 0, 0},
{"grayscale", 1, 0, 0},
{"discard-estimating-constant", 1, 0, 0},
{0, 0, 0, 0}
};
char* positive_list = 0;
Expand All @@ -68,24 +70,27 @@ int main(int argc, char** argv)
char* base_dir = 0;
int negative_count = 0;
ccv_dpm_param_t detector = { .interval = 8, .min_neighbors = 0, .flags = 0, .threshold = 0.0 };
ccv_dpm_new_param_t params = { .components = 0,
.detector = detector,
.parts = 0,
.min_area = 3000,
.max_area = 5000,
.symmetric = 1,
.alpha = 0.01,
.balance = 1.5,
.alpha_ratio = 0.995,
.iterations = 1000,
.data_minings = 50,
.root_relabels = 20,
.relabels = 10,
.negative_cache_size = 2000,
.C = 0.002,
.percentile_breakdown = 0.05,
.include_overlap = 0.7,
.grayscale = 0 };
ccv_dpm_new_param_t params = {
.components = 0,
.detector = detector,
.parts = 0,
.min_area = 3000,
.max_area = 5000,
.symmetric = 1,
.alpha = 0.01,
.balance = 1.5,
.alpha_ratio = 0.995,
.iterations = 1000,
.data_minings = 50,
.root_relabels = 20,
.relabels = 10,
.negative_cache_size = 2000,
.C = 0.002,
.percentile_breakdown = 0.05,
.include_overlap = 0.7,
.grayscale = 0,
.discard_estimating_constant = 1,
};
int i, k;
while (getopt_long_only(argc, argv, "", dpm_options, &k) != -1)
{
Expand Down Expand Up @@ -152,6 +157,9 @@ int main(int argc, char** argv)
case 20:
params.grayscale = !!atoi(optarg);
break;
case 21:
params.discard_estimating_constant = !!atoi(optarg);
break;
}
}
assert(positive_list != 0);
Expand Down
2 changes: 1 addition & 1 deletion bin/dpmdetect.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ int main(int argc, char** argv)
.interval = 8,
.min_neighbors = 1,
.flags = 0,
.threshold = 0.8
.threshold = 0.6
};
if (image != 0)
{
Expand Down
1 change: 1 addition & 0 deletions bin/dpmvldtr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
File.new(ARGV[0]).each_line do |line|
args = line.split " "
name, x, y, width, height = args[0].to_s, args[1].to_i, args[2].to_i, args[3].to_i, args[4].to_i
# next if width < 44 or height < 28
truth[name] = Array.new unless truth.has_key? name
truth[name] << { :found => false, :x => x, :y => y, :width => width, :height => height }
end
Expand Down
1 change: 1 addition & 0 deletions lib/ccv.h
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,7 @@ typedef struct {
int data_minings;
int root_relabels;
int relabels;
int discard_estimating_constant; // 1
int negative_cache_size; // 1000
double include_overlap; // 0.7
double alpha;
Expand Down
8 changes: 5 additions & 3 deletions lib/ccv_dpm.c
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,8 @@ static ccv_array_t* _ccv_dpm_collect_all(gsl_rng* rng, ccv_dense_matrix_t* image
ccv_dpm_feature_vector_t* v = (ccv_dpm_feature_vector_t*)ccmalloc(sizeof(ccv_dpm_feature_vector_t));
_ccv_dpm_initialize_feature_vector_on_pattern(v, root_classifier, order[i]);
_ccv_dpm_collect_feature_vector(v, f_ptr[x] + root_classifier->beta, x, y, pyr[j], pyr[j - next], dx, dy);
v->scale_x = scale_x;
v->scale_y = scale_y;
ccv_array_push(av, &v);
if (av->rnum >= enough * (i + 1))
break;
Expand Down Expand Up @@ -1048,7 +1050,7 @@ static void _ccv_dpm_initialize_root_rectangle_estimator(ccv_dpm_mixture_model_t
ccv_rect_t bbox = bboxes[j];
gsl_vector_set(y[0], c, (bbox.x + bbox.width * 0.5) / (v->scale_x * CCV_DPM_WINDOW_SIZE) - v->x);
gsl_vector_set(y[1], c, (bbox.y + bbox.height * 0.5) / (v->scale_y * CCV_DPM_WINDOW_SIZE) - v->y);
gsl_vector_set(y[2], c, (bbox.width + bbox.height) / (root_classifier->root.w->rows * CCV_DPM_WINDOW_SIZE * v->scale_y + root_classifier->root.w->cols * CCV_DPM_WINDOW_SIZE * v->scale_x) - 1.0);
gsl_vector_set(y[2], c, sqrt((bbox.width * bbox.height) / (root_classifier->root.w->rows * v->scale_x * CCV_DPM_WINDOW_SIZE * root_classifier->root.w->cols * v->scale_y * CCV_DPM_WINDOW_SIZE)) - 1.0);
++c;
}
}
Expand All @@ -1057,7 +1059,7 @@ static void _ccv_dpm_initialize_root_rectangle_estimator(ccv_dpm_mixture_model_t
for (j = 0; j < 3; j++)
{
gsl_multifit_linear(X, y[j], z, cov, &chisq, workspace);
root_classifier->alpha[j] = gsl_vector_get(z, 0);
root_classifier->alpha[j] = params.discard_estimating_constant ? 0 : gsl_vector_get(z, 0);
for (k = 0; k < root_classifier->count; k++)
{
ccv_dpm_part_classifier_t* part_classifier = root_classifier->part + k;
Expand Down Expand Up @@ -2102,7 +2104,7 @@ ccv_array_t* ccv_dpm_detect_objects(ccv_dense_matrix_t* a, ccv_dpm_mixture_model
comp.part[k].rect = ccv_rect((int)((rx - pww) * CCV_DPM_WINDOW_SIZE / 2 * scale_x + 0.5), (int)((ry - pwh) * CCV_DPM_WINDOW_SIZE / 2 * scale_y + 0.5), (int)(part->w->cols * CCV_DPM_WINDOW_SIZE / 2 * scale_x + 0.5), (int)(part->w->rows * CCV_DPM_WINDOW_SIZE / 2 * scale_y + 0.5));
comp.part[k].confidence = -ccv_get_dense_matrix_cell_value_by(CCV_32F | CCV_C1, part_feature[k], iy, ix, 0);
}
comp.rect = ccv_rect((int)((x + drift_x) * CCV_DPM_WINDOW_SIZE * scale_x - rww * CCV_DPM_WINDOW_SIZE * (scale_x + drift_scale) + 0.5), (int)((y + drift_y) * CCV_DPM_WINDOW_SIZE * scale_y - rwh * CCV_DPM_WINDOW_SIZE * (scale_y + drift_scale) + 0.5), (int)(root->root.w->cols * CCV_DPM_WINDOW_SIZE * (scale_x + drift_scale) + 0.5), (int)(root->root.w->rows * CCV_DPM_WINDOW_SIZE * (scale_y + drift_scale) + 0.5));
comp.rect = ccv_rect((int)((x + drift_x) * CCV_DPM_WINDOW_SIZE * scale_x - rww * CCV_DPM_WINDOW_SIZE * scale_x * (1.0 + drift_scale) + 0.5), (int)((y + drift_y) * CCV_DPM_WINDOW_SIZE * scale_y - rwh * CCV_DPM_WINDOW_SIZE * scale_y * (1.0 + drift_scale) + 0.5), (int)(root->root.w->cols * CCV_DPM_WINDOW_SIZE * scale_x * (1.0 + drift_scale) + 0.5), (int)(root->root.w->rows * CCV_DPM_WINDOW_SIZE * scale_y * (1.0 + drift_scale) + 0.5));
ccv_array_push(seq, &comp);
}
f_ptr += root_feature->cols;
Expand Down
Loading

0 comments on commit e53a7df

Please sign in to comment.