Skip to content

Commit

Permalink
trying to add color support to it
Browse files Browse the repository at this point in the history
  • Loading branch information
liuliu committed May 13, 2013
1 parent cd17607 commit 322a41f
Show file tree
Hide file tree
Showing 12 changed files with 305,969 additions and 143 deletions.
7 changes: 3 additions & 4 deletions bin/icfcreate.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,14 @@ int main(int argc, char** argv)
fclose(r1);
free(file);
params.interval = 5;
params.grayscale = 0;
params.size.width = 20;
params.size.height = 60;
params.deform_shift = 0.01;
params.deform_angle = 1;
params.deform_angle = 0;
params.deform_scale = 0.07;
params.feature_size = 30000;
params.weak_classifier = 2000;
params.sample_rate = 0.1;
params.weight_trimming = 0.95;
params.weak_classifier = 1500;
params.acceptance = acceptance;
params.bootstrap_criteria = 0.005;
params.bootstrap = 4;
Expand Down
4 changes: 2 additions & 2 deletions bin/bbfdraw.rb → bin/icfdraw.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
y = args[1].to_i
width = args[2].to_i
height = args[3].to_i
rect += sprintf("-draw \"ellipse %d,%d %d,%d 0,360\" ", x + width / 2, y + height / 2, width / 2, height / 2)
rect += sprintf("-draw \"rectangle %d,%d %d,%d\" ", x, y, x + width, y + height)
end

%x[#{sprintf("convert %s -fill none -stroke green -strokewidth 2 %s%s", ARGV[0], rect, ARGV[1])}]
%x[#{sprintf("convert %s -fill none -stroke red -strokewidth 2 %s%s", ARGV[0], rect, ARGV[1])}]
61 changes: 61 additions & 0 deletions bin/icfvldtr.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/usr/bin/env ruby

exit unless ARGV.length == 2

truth = Hash.new
total = 0

files = Dir.glob(ARGV[0] + '/*.txt')

files.each do |file|
name = nil;
boxes = Array.new
File.new(file).each_line do |line|
next if line[0] == '#'
name = line[line.rindex('/') + 1, line.rindex('"') - (line.rindex('/') + 1)] if line[0, 14].downcase == "image filename"
if line[0, 16].downcase == "bounding box for"
i = line.scan(/object\s*(\d+)/)[0][0].to_i
coord = line.scan(/\((\d+),\s*(\d+)\)\s*-\s*\((\d+),\s*(\d+)\)/)[0]
boxes[i - 1] = { :found => false, :x => coord[0].to_i, :y => coord[1].to_i, :width => coord[2].to_i - coord[0].to_i, :height => coord[3].to_i - coord[1].to_i }
end
end
truth[name] = boxes;
total += boxes.length;
end

fa = 0
tp = 0

File.new(ARGV[1]).each_line do |line|
args = line.split " "
name = args[0].to_s
name = args[0][args[0].rindex('/') + 1, args[0].length - (args[0].rindex('/') + 1)]
if !truth[name]
fa += 1
else
x = args[1].to_i
y = args[2].to_i
width = args[3].to_i
height = args[4].to_i
outlier = -1
truth[name].each do |obj|
opx_min = [obj[:x], x].max
opy_min = [obj[:y], y].max
opx_max = [obj[:x] + obj[:width], x + width].min
opy_max = [obj[:y] + obj[:height], y + height].min
r0 = [opx_max - opx_min, 0].max * [opy_max - opy_min, 0].max
r1 = [obj[:width] * obj[:height], width * height].max * 0.5
if r0 > r1
outlier = obj[:found] ? 0 : 1
obj[:found] = true
break
end
end
case outlier
when -1 then fa += 1
when 1 then tp += 1
end
end
end

print ((tp.to_f / total.to_f * 10000).round / 100.0).to_s + "% ("+ fa.to_s + ")\n"
5 changes: 3 additions & 2 deletions lib/ccv.h
Original file line number Diff line number Diff line change
Expand Up @@ -994,19 +994,22 @@ typedef struct {

typedef struct {
int interval;
int grayscale;
ccv_icf_classifier_cascade_t* cascade;
} ccv_icf_multiscale_classifier_cascade_t;

typedef struct {
int min_neighbors;
int flags;
int step_through;
float threshold;
} ccv_icf_param_t;

extern const ccv_icf_param_t ccv_icf_default_params;

typedef struct {
ccv_icf_param_t detector;
int grayscale;
int interval;
ccv_size_t size;
int feature_size;
Expand All @@ -1016,8 +1019,6 @@ typedef struct {
float deform_angle;
float deform_scale;
float deform_shift;
double weight_trimming;
double sample_rate;
double acceptance;
} ccv_icf_new_param_t;

Expand Down
Loading

0 comments on commit 322a41f

Please sign in to comment.