camellia 2.7.0-x86-linux

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. data/CamelliaLib-2.7.0.tar.gz +0 -0
  2. data/README +59 -0
  3. data/doc/README +58 -0
  4. data/doc/camellia.dox +205 -0
  5. data/doc/html/annotated.html +52 -0
  6. data/doc/html/camellia_8h-source.html +1618 -0
  7. data/doc/html/camellia_8h.html +4583 -0
  8. data/doc/html/doxygen.css +358 -0
  9. data/doc/html/doxygen.png +0 -0
  10. data/doc/html/files.html +29 -0
  11. data/doc/html/ftv2blank.png +0 -0
  12. data/doc/html/ftv2doc.png +0 -0
  13. data/doc/html/ftv2folderclosed.png +0 -0
  14. data/doc/html/ftv2folderopen.png +0 -0
  15. data/doc/html/ftv2lastnode.png +0 -0
  16. data/doc/html/ftv2link.png +0 -0
  17. data/doc/html/ftv2mlastnode.png +0 -0
  18. data/doc/html/ftv2mnode.png +0 -0
  19. data/doc/html/ftv2node.png +0 -0
  20. data/doc/html/ftv2plastnode.png +0 -0
  21. data/doc/html/ftv2pnode.png +0 -0
  22. data/doc/html/ftv2vertline.png +0 -0
  23. data/doc/html/functions.html +108 -0
  24. data/doc/html/functions_0x62.html +78 -0
  25. data/doc/html/functions_0x63.html +112 -0
  26. data/doc/html/functions_0x64.html +113 -0
  27. data/doc/html/functions_0x65.html +102 -0
  28. data/doc/html/functions_0x66.html +82 -0
  29. data/doc/html/functions_0x67.html +76 -0
  30. data/doc/html/functions_0x68.html +88 -0
  31. data/doc/html/functions_0x69.html +90 -0
  32. data/doc/html/functions_0x6b.html +70 -0
  33. data/doc/html/functions_0x6c.html +88 -0
  34. data/doc/html/functions_0x6d.html +93 -0
  35. data/doc/html/functions_0x6e.html +79 -0
  36. data/doc/html/functions_0x6f.html +74 -0
  37. data/doc/html/functions_0x70.html +72 -0
  38. data/doc/html/functions_0x72.html +73 -0
  39. data/doc/html/functions_0x73.html +130 -0
  40. data/doc/html/functions_0x74.html +82 -0
  41. data/doc/html/functions_0x76.html +74 -0
  42. data/doc/html/functions_0x77.html +75 -0
  43. data/doc/html/functions_0x78.html +72 -0
  44. data/doc/html/functions_0x79.html +77 -0
  45. data/doc/html/functions_0x7e.html +76 -0
  46. data/doc/html/functions_func.html +93 -0
  47. data/doc/html/functions_func_0x62.html +64 -0
  48. data/doc/html/functions_func_0x63.html +83 -0
  49. data/doc/html/functions_func_0x64.html +99 -0
  50. data/doc/html/functions_func_0x65.html +95 -0
  51. data/doc/html/functions_func_0x66.html +74 -0
  52. data/doc/html/functions_func_0x67.html +72 -0
  53. data/doc/html/functions_func_0x68.html +76 -0
  54. data/doc/html/functions_func_0x69.html +70 -0
  55. data/doc/html/functions_func_0x6c.html +76 -0
  56. data/doc/html/functions_func_0x6d.html +78 -0
  57. data/doc/html/functions_func_0x6f.html +65 -0
  58. data/doc/html/functions_func_0x70.html +64 -0
  59. data/doc/html/functions_func_0x72.html +65 -0
  60. data/doc/html/functions_func_0x73.html +113 -0
  61. data/doc/html/functions_func_0x74.html +74 -0
  62. data/doc/html/functions_func_0x76.html +64 -0
  63. data/doc/html/functions_func_0x77.html +64 -0
  64. data/doc/html/functions_func_0x7e.html +72 -0
  65. data/doc/html/functions_vars.html +290 -0
  66. data/doc/html/globals.html +368 -0
  67. data/doc/html/globals_defs.html +41 -0
  68. data/doc/html/globals_func.html +364 -0
  69. data/doc/html/index.html +11 -0
  70. data/doc/html/main.html +22 -0
  71. data/doc/html/pages.html +24 -0
  72. data/doc/html/structCamAffineTransform.html +37 -0
  73. data/doc/html/structCamArithmParams.html +60 -0
  74. data/doc/html/structCamBasin.html +62 -0
  75. data/doc/html/structCamBitmapFont.html +37 -0
  76. data/doc/html/structCamBlobInfo.html +90 -0
  77. data/doc/html/structCamBlobs.html +51 -0
  78. data/doc/html/structCamImage.html +853 -0
  79. data/doc/html/structCamKeypoint.html +79 -0
  80. data/doc/html/structCamKeypoints.html +99 -0
  81. data/doc/html/structCamKeypointsKdTree.html +42 -0
  82. data/doc/html/structCamKeypointsMatches.html +54 -0
  83. data/doc/html/structCamLabelingResults.html +46 -0
  84. data/doc/html/structCamLinearFilterKernel.html +63 -0
  85. data/doc/html/structCamMeasuresResults.html +54 -0
  86. data/doc/html/structCamMorphoMathsKernel.html +81 -0
  87. data/doc/html/structCamPoint.html +46 -0
  88. data/doc/html/structCamRLEImage.html +183 -0
  89. data/doc/html/structCamROI.html +80 -0
  90. data/doc/html/structCamRun.html +56 -0
  91. data/doc/html/structCamSepFilterKernel.html +67 -0
  92. data/doc/html/structCamTable.html +46 -0
  93. data/doc/html/structCamTableOfBasins.html +37 -0
  94. data/doc/html/structCamVolbergFwdParams.html +46 -0
  95. data/doc/html/structCamWarpingParams.html +70 -0
  96. data/doc/html/tab_b.gif +0 -0
  97. data/doc/html/tab_l.gif +0 -0
  98. data/doc/html/tab_r.gif +0 -0
  99. data/doc/html/tabs.css +102 -0
  100. data/doc/html/todo.html +29 -0
  101. data/doc/html/tree.html +106 -0
  102. data/doc/rtf/refman.rtf +7866 -0
  103. data/ext/Makefile +149 -0
  104. data/ext/README +12 -0
  105. data/ext/camellia_ruby.i +493 -0
  106. data/ext/camellia_ruby_wrap.cxx +21103 -0
  107. data/ext/extconf.rb +12 -0
  108. data/ext/install.rb +11 -0
  109. data/ext/swig_ruby.dsp +159 -0
  110. data/ext/swig_ruby.vcproj +290 -0
  111. data/ext/test.rb +31 -0
  112. data/inc/SHLWAPI.H +661 -0
  113. data/inc/cam_capture.h +202 -0
  114. data/inc/camellia.h +2651 -0
  115. data/inc/camellia_internals.h +205 -0
  116. data/inc/config.h +62 -0
  117. data/inc/config.h.in +61 -0
  118. data/inc/stamp-h1 +1 -0
  119. data/lib/camellia-fox.rb +39 -0
  120. data/test/test_arithm.rb +13 -0
  121. data/test/test_capture.rb +15 -0
  122. data/test/test_color_labeling.rb +45 -0
  123. data/test/test_copy.rb +13 -0
  124. data/test/test_draw.rb +15 -0
  125. data/test/test_fixed_filters.rb +23 -0
  126. data/test/test_fox.rb +106 -0
  127. data/test/test_fox2.rb +108 -0
  128. data/test/test_histogram.rb +18 -0
  129. data/test/test_hough.rb +29 -0
  130. data/test/test_keypoints.rb +106 -0
  131. data/test/test_labeling.rb +30 -0
  132. data/test/test_mask.rb +34 -0
  133. data/test/test_warping.rb +46 -0
  134. data/test/test_watershed.rb +35 -0
  135. data/test/ts_camellia.rb +12 -0
  136. metadata +204 -0
@@ -0,0 +1,13 @@
1
+ require 'test/unit'
2
+ require 'lib/camellia'
3
+ include Camellia
4
+ class TestCopy < Test::Unit::TestCase
5
+ def test_copy
6
+ source=CamImage.new
7
+ # load picture alfa156.bmp
8
+ source.load_bmp("resources/alfa156.bmp")
9
+ dest=CamImage.new(source.width,source.height,CAM_DEPTH_8U,CAM_COLORMODEL_RGBA)
10
+ source.copy(dest)
11
+ dest.save_bmp("output/copy_alfa156.bmp")
12
+ end
13
+ end
@@ -0,0 +1,15 @@
1
+ require 'test/unit'
2
+ require 'lib/camellia'
3
+ include Camellia
4
+
5
+ class TestDraw < Test::Unit::TestCase
6
+ def test_draw
7
+ image=CamImage.new(320,240,CAM_DEPTH_8U,CAM_COLORMODEL_RGB)
8
+ font=CamBitmapFont.new('resources/fonts/xenon2.bmp')
9
+ image.set!(0)
10
+ image.draw_line(0,0,320,240,cam_rgb(255,0,0))
11
+ image.fill_color(50,100,cam_rgb(255,0,0))
12
+ image.draw_text_bitmap('Hello World',100,140,font)
13
+ image.save_bmp('output/drawing_ruby.bmp')
14
+ end
15
+ end
@@ -0,0 +1,23 @@
1
+ require 'test/unit'
2
+ require 'lib/camellia'
3
+ include Camellia
4
+ class TestFixedFilters < Test::Unit::TestCase
5
+ def test_fixed_filters
6
+ source=CamImage.new
7
+ result=CamImage.new
8
+ # load picture chess.pgm
9
+ source.load_pgm("resources/chess.pgm")
10
+ # gaussian filtering 3x3
11
+ source.fixed_filter(result,CAM_GAUSSIAN_3x3);
12
+ # save the result
13
+ result.save_pgm("output/ruby_chess_gaussian_3x3.pgm");
14
+ # gaussian filtering 5x5
15
+ source.fixed_filter(result,CAM_GAUSSIAN_5x5);
16
+ # save the result
17
+ result.save_pgm("output/ruby_chess_gaussian_5x5.pgm");
18
+ # gaussian filtering 7x7
19
+ source.fixed_filter(result,CAM_GAUSSIAN_7x7);
20
+ # save the result
21
+ result.save_pgm("output/ruby_chess_gaussian_7x7.pgm");
22
+ end
23
+ end
@@ -0,0 +1,106 @@
1
+ require 'rubygems'
2
+ require_gem 'fxruby'
3
+ include Fox
4
+
5
+ require_gem 'camellia'
6
+ require 'camellia-fox.rb'
7
+ include Camellia
8
+
9
+ class ImageWindow < FXMainWindow
10
+
11
+ def initialize(app)
12
+ # Invoke base class initializer first
13
+ super(app, "Camellia/FXRuby test", nil, nil, DECOR_ALL, 0, 0, 440, 240)
14
+
15
+ contents = FXHorizontalFrame.new(self,
16
+ LAYOUT_SIDE_TOP|LAYOUT_FILL_X|LAYOUT_FILL_Y, 0, 0, 0, 0, 0, 0, 0, 0)
17
+
18
+ # RIGHT pane for the buttons
19
+ buttonFrame = FXVerticalFrame.new(contents, (FRAME_SUNKEN|LAYOUT_FILL_Y|
20
+ LAYOUT_TOP|LAYOUT_LEFT), 0, 0, 0, 0, 10, 10, 10, 10)
21
+
22
+ # Label above the buttons
23
+ FXLabel.new(buttonFrame, "Button Frame", nil,
24
+ JUSTIFY_CENTER_X|LAYOUT_FILL_X);
25
+
26
+ # Horizontal divider line
27
+ FXHorizontalSeparator.new(buttonFrame, SEPARATOR_RIDGE|LAYOUT_FILL_X)
28
+
29
+ # Erode button
30
+ erodeBtn = FXButton.new(buttonFrame,
31
+ "Erode Image...\tGrey scale erosion",
32
+ nil, nil, 0, (FRAME_THICK|FRAME_RAISED|LAYOUT_FILL_X|
33
+ LAYOUT_TOP|LAYOUT_LEFT), 0, 0, 0, 0, 10, 10, 5, 5) { |button|
34
+ button.connect(SEL_COMMAND, method(:onCmdErode))
35
+ }
36
+
37
+ # Save button
38
+ saveBtn = FXButton.new(buttonFrame,
39
+ "Save Image...\tRead back image and save to file",
40
+ nil, nil, 0, (FRAME_THICK|FRAME_RAISED|LAYOUT_FILL_X|
41
+ LAYOUT_TOP|LAYOUT_LEFT), 0, 0, 0, 0, 10, 10, 5, 5)
42
+ saveBtn.connect(SEL_COMMAND, method(:onCmdRestore))
43
+
44
+ # Exit button
45
+ FXButton.new(buttonFrame, "E&xit\tQuit FXRuby test", nil,
46
+ getApp(), FXApp::ID_QUIT, (FRAME_THICK|FRAME_RAISED|LAYOUT_FILL_X|
47
+ LAYOUT_TOP|LAYOUT_LEFT), 0, 0, 0, 0, 10, 10, 5, 5)
48
+
49
+ # Create a FXBMPImage and load a picture from disk
50
+ @picture=FXBMPImage.new(getApp(), nil, IMAGE_KEEP|IMAGE_OWNED, 320, 240);
51
+ FXFileStream.open('resources/alfa156.bmp', FXStreamLoad) { |stream| @picture.loadPixels(stream) }
52
+ @picture.render
53
+ source=@picture.to_camellia
54
+ @image=source.to_yuv
55
+ @image.set_roi(CamROI.new(@image,1)) # Select Y plane (B&W)
56
+
57
+ @imgFrame=FXImageFrame.new(contents,@picture)
58
+
59
+ # Make a tip
60
+ FXToolTip.new(getApp())
61
+ end
62
+
63
+ # Create and initialize
64
+ def create
65
+ # Create the windows
66
+ super
67
+
68
+ # Make the main window appear
69
+ show(PLACEMENT_SCREEN)
70
+ end
71
+
72
+ # Restore image from offscreen pixmap
73
+ def onCmdRestore(sender, sel, ptr)
74
+ saveDialog = FXFileDialog.new(self, "Save as BMP")
75
+ if saveDialog.execute != 0
76
+ @picture.restore
77
+ # Get back a CamImage and save it
78
+ @picture.to_camellia.save_bmp(saveDialog.filename)
79
+ end
80
+ return 1
81
+ end
82
+
83
+ # Erode image
84
+ def onCmdErode(sender, sel, ptr)
85
+ @image.erode_circle5!
86
+ @image.to_fox(getApp(),@picture)
87
+ @picture.render
88
+ @imgFrame.update
89
+ end
90
+
91
+ end
92
+
93
+ if __FILE__ == $0
94
+ # Make application
95
+ application = FXApp.new("Camellia/FXRuby", "Camellia/FXRuby test")
96
+
97
+ # Make the main window
98
+ ImageWindow.new(application)
99
+
100
+ # Create the application window and resources
101
+ application.create
102
+
103
+ # Run the application
104
+ application.run
105
+ end
106
+
@@ -0,0 +1,108 @@
1
+ require 'rubygems'
2
+ require_gem 'fxruby'
3
+ include Fox
4
+
5
+ require_gem 'camellia'
6
+ require 'camellia-fox.rb'
7
+ include Camellia
8
+
9
+ class ImageWindow < FXMainWindow
10
+
11
+ def initialize(app)
12
+ # Invoke base class initializer first
13
+ super(app, "Camellia/FXRuby test", nil, nil, DECOR_ALL, 0, 0, 440, 240)
14
+
15
+ contents = FXHorizontalFrame.new(self,
16
+ LAYOUT_SIDE_TOP|LAYOUT_FILL_X|LAYOUT_FILL_Y, 0, 0, 0, 0, 0, 0, 0, 0)
17
+
18
+ # RIGHT pane for the buttons
19
+ buttonFrame = FXVerticalFrame.new(contents, (FRAME_SUNKEN|LAYOUT_FILL_Y|
20
+ LAYOUT_TOP|LAYOUT_LEFT), 0, 0, 0, 0, 10, 10, 10, 10)
21
+
22
+ # Label above the buttons
23
+ FXLabel.new(buttonFrame, "Button Frame", nil,
24
+ JUSTIFY_CENTER_X|LAYOUT_FILL_X);
25
+
26
+ # Horizontal divider line
27
+ FXHorizontalSeparator.new(buttonFrame, SEPARATOR_RIDGE|LAYOUT_FILL_X)
28
+
29
+ # Erode button
30
+ erodeBtn = FXButton.new(buttonFrame,
31
+ "Erode Image...\tGrey scale erosion",
32
+ nil, nil, 0, (FRAME_THICK|FRAME_RAISED|LAYOUT_FILL_X|
33
+ LAYOUT_TOP|LAYOUT_LEFT), 0, 0, 0, 0, 10, 10, 5, 5) { |button|
34
+ button.connect(SEL_COMMAND, method(:onCmdErode))
35
+ }
36
+
37
+ # Save button
38
+ saveBtn = FXButton.new(buttonFrame,
39
+ "Save Image...\tRead back image and save to file",
40
+ nil, nil, 0, (FRAME_THICK|FRAME_RAISED|LAYOUT_FILL_X|
41
+ LAYOUT_TOP|LAYOUT_LEFT), 0, 0, 0, 0, 10, 10, 5, 5)
42
+ saveBtn.connect(SEL_COMMAND, method(:onCmdRestore))
43
+
44
+ # Exit button
45
+ FXButton.new(buttonFrame, "E&xit\tQuit FXRuby test", nil,
46
+ getApp(), FXApp::ID_QUIT, (FRAME_THICK|FRAME_RAISED|LAYOUT_FILL_X|
47
+ LAYOUT_TOP|LAYOUT_LEFT), 0, 0, 0, 0, 10, 10, 5, 5)
48
+
49
+ # Load image using Camellia
50
+ source=CamImage.new
51
+ source.load_bmp("resources/alfa156.bmp")
52
+ @image=source.to_yuv
53
+ @image.set_roi(CamROI.new(@image,1)) # Select Y plane (B&W)
54
+
55
+ # Create a FXImage from the Camellia image
56
+ @picture=@image.to_fox(getApp())
57
+ @picture.render
58
+
59
+ @imgFrame=FXImageFrame.new(contents,@picture)
60
+
61
+ # Make a tip
62
+ FXToolTip.new(getApp())
63
+ end
64
+
65
+ # Create and initialize
66
+ def create
67
+ # Create the windows
68
+ super
69
+
70
+ # Make the main window appear
71
+ show(PLACEMENT_SCREEN)
72
+ end
73
+
74
+ # Restore image from offscreen pixmap
75
+ def onCmdRestore(sender, sel, ptr)
76
+ saveDialog = FXFileDialog.new(self, "Save as BMP")
77
+ if saveDialog.execute != 0
78
+ @picture.restore
79
+ # Get back a CamImage and save it
80
+ @picture.to_camellia.save_bmp(saveDialog.filename)
81
+ end
82
+ return 1
83
+ end
84
+
85
+ # Erode image
86
+ def onCmdErode(sender, sel, ptr)
87
+ @image.erode_circle5!
88
+ @image.to_fox(getApp(),@picture)
89
+ @picture.render
90
+ @imgFrame.update
91
+ end
92
+
93
+ end
94
+
95
+ if __FILE__ == $0
96
+ # Make application
97
+ application = FXApp.new("Camellia/FXRuby", "Camellia/FXRuby test")
98
+
99
+ # Make the main window
100
+ ImageWindow.new(application)
101
+
102
+ # Create the application window and resources
103
+ application.create
104
+
105
+ # Run the application
106
+ application.run
107
+ end
108
+
@@ -0,0 +1,18 @@
1
+ require 'test/unit'
2
+ require 'lib/camellia'
3
+ include Camellia
4
+ class TestHistogram < Test::Unit::TestCase
5
+ def test_histogram
6
+ source=CamImage.new
7
+ # load picture alfa156.bmp
8
+ source.load_bmp("resources/alfa156.bmp")
9
+ # convert to YUV
10
+ yuv=CamImage.new
11
+ yuv=source.to_yuv
12
+ # compute the histogram
13
+ result=CamImage.new
14
+ yuv.histogram_2_channels(2,3,result)
15
+ # save the result
16
+ result.save_pgm("output/alfa156_histo.pgm")
17
+ end
18
+ end
@@ -0,0 +1,29 @@
1
+ require 'test/unit'
2
+ require 'lib/camellia'
3
+ include Camellia
4
+ class TestHough < Test::Unit::TestCase
5
+ def test_hough
6
+ image=CamImage.new(100,100)
7
+ # Draw a filled circle in mask
8
+ image.set!(0)
9
+ image.draw_circle(40,40,50,128)
10
+ image.fill_color(40,40,128)
11
+ res=image.hough_circle(10,40,60)
12
+ puts "Found a circle at (#{res[1]},#{res[2]}) (radius=#{res[3]}) (confidence=#{res[0]})"
13
+ assert((res[1]-40).abs<=1)
14
+ assert((res[2]-40).abs<=1)
15
+
16
+ for i in 1..3 do
17
+ # Load an image with a road sign
18
+ image.load_bmp("resources/road#{i}.bmp")
19
+ yuv=CamImage.new
20
+ image.to_yuv(yuv)
21
+ yuv.set_roi(CamROI.new(1,8,8,image.width-16,image.height-128))
22
+ yuv.fixed_filter!(CAM_GAUSSIAN_3x3)
23
+ res=yuv.hough_circle(100,6,25)
24
+ image.draw_circle(res[1],res[2],res[3],cam_rgb(255,0,0))
25
+ image.save_bmp("output/road_circle_hough#{i}.bmp")
26
+ puts "Found a circle at (#{res[1]},#{res[2]}) (radius=#{res[3]}) (confidence=#{res[0]})"
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,106 @@
1
+ require 'test/unit'
2
+ require 'lib/camellia'
3
+ include Camellia
4
+ require 'rubygems'
5
+ require 'gnuplot'
6
+
7
+ class TestKeypoints < Test::Unit::TestCase
8
+
9
+ def test_keypoints_scale
10
+
11
+ puts "Keypoints detection :"
12
+ image = CamImage.new(256, 256)
13
+ points = CamKeypoints.new(1000)
14
+
15
+ # Draw 2 rectangles
16
+ image.set!(0)
17
+ image.draw_rectangle(102, 120, 156, 152, 255)
18
+ image.fill_color(103, 121, 255)
19
+ image.draw_rectangle(122, 35, 176, 67, 128)
20
+ image.fill_color(123, 36, 128)
21
+
22
+ # Draw 2 small squares
23
+ xp = [-1, 1, 1, -1]
24
+ yp = [-1, -1, 1, 1]
25
+ angle = [20, 30]
26
+ centerx = [192, 50]
27
+ for j in 0..1 do
28
+ costheta = Math.cos(angle[j] * 2 * Math::PI / 360)
29
+ sintheta = Math.sin(angle[j] * 2 * Math::PI / 360)
30
+ p = []
31
+ for i in 0..3 do
32
+ p[i] = CamPoint.new( ((costheta * xp[i] - sintheta * yp[i]) * 15 + centerx[j]).to_i,
33
+ ((sintheta * xp[i] + costheta * yp[i]) * 15 + 192).to_i )
34
+ end
35
+ for i in 0..3 do
36
+ image.draw_line(p[i].x, p[i].y, p[(i+1) % 4].x, p[(i+1) % 4].y, 255)
37
+ end
38
+ image.fill_color(centerx[j], 192, 255)
39
+ end
40
+
41
+ image.fast_hessian_detector(points, 2000);
42
+ points.each do |point|
43
+ puts "x=#{point.x} y=#{point.y} value=#{point.value} scale=#{point.scale} size=#{point.size} angle=#{point.angle}"
44
+ end
45
+ image.draw_keypoints!(points, 128);
46
+ image.save_pgm("output/features_reference.pgm");
47
+
48
+ end
49
+
50
+ def test_keypoints_yale_faces
51
+
52
+ # Parameters
53
+ threshold = 100
54
+
55
+ # Load model images
56
+ models = []
57
+ (1..15).each do |i|
58
+ filename = "resources/yalefaces/subject#{'%02d' % i}.normal.pgm"
59
+ puts "Keypoint detection on #{filename} ..."
60
+ image = CamImage.new
61
+ image.load_pgm(filename)
62
+ points = CamKeypoints.new(10000)
63
+ points.id = i
64
+ image.fast_hessian_detector(points, threshold, CAM_UPRIGHT)
65
+ image.draw_keypoints!(points, 128)
66
+ image.save_pgm("output/yalefaces#{'%02d' % i}.pgm")
67
+ models << points
68
+ end
69
+
70
+ # Compile a kdTree
71
+ kdTree = CamKeypointsKdTree.new(models)
72
+
73
+ # Test all 150 images
74
+ feature = ["centerlight", "glasses", "happy", "leftlight", "noglasses", "rightlight", "sad", "sleepy", "surprised", "wink"]
75
+ nb_features = 0
76
+ rate = 0
77
+ nb_good_matches = 0
78
+ matches = CamKeypointsMatches.new
79
+
80
+ (1..15).each do |i|
81
+ (1..10).each do |j|
82
+ filename = "resources/yalefaces/subject#{'%02d' % i}.#{feature[j-1]}.pgm"
83
+ puts "Keypoint detection on #{filename} ..."
84
+ image = CamImage.new
85
+ image.load_pgm(filename)
86
+ points = CamKeypoints.new(10000)
87
+ image.fast_hessian_detector(points, threshold, CAM_UPRIGHT)
88
+ puts "# features = #{points.nb_points}"
89
+ nb_features += points.nb_points
90
+ #best_match = points.matching(models, matches)
91
+ best_match = points.matchingKdTree(kdTree, matches, 100)
92
+ puts "Best match is : #{best_match} (#{matches.nb_matches})"
93
+ if best_match == i then
94
+ rate += 1
95
+ nb_good_matches += matches.nb_matches
96
+ end
97
+ end
98
+ end
99
+
100
+ puts "Recognition rate is #{rate * 100.0 / (15*10)}"
101
+ puts "Good matches = #{nb_good_matches}"
102
+ puts "Nb features = #{nb_features} (% matching = #{nb_good_matches * 100.0 / nb_features}%)"
103
+
104
+ end
105
+
106
+ end
@@ -0,0 +1,30 @@
1
+ require 'test/unit'
2
+ require 'lib/camellia'
3
+ include Camellia
4
+ class TestLabeling < Test::Unit::TestCase
5
+ def test_labeling
6
+ image=CamImage.new
7
+ # load picture alfa156.bmp
8
+ image.load_bmp("resources/alfa156.bmp")
9
+ yuv=image.to_yuv
10
+ # consider only the V plane (red)
11
+ yuv.set_roi(CamROI.new(yuv,3))
12
+ # threshold and encode
13
+ thr=yuv.encode_threshold(150)
14
+ # labeling
15
+ blobs=thr.labeling!
16
+ puts "#{blobs.nb_blobs} blobs detected"
17
+ # draw rectangle on all detected blobs
18
+ blobs.each {|b| image.draw_rectangle(b.left,b.top,b.left+b.width-1,b.top+b.height-1,cam_rgb(255,0,0))}
19
+ # save the resulting picture
20
+ image.save_bmp("output/ruby_alfa156_labeling.bmp")
21
+ # find out the biggest blob
22
+ sorted=blobs.sort {|a,b| b.surface<=>a.surface}
23
+ puts "The bigger blob is at position (#{sorted[0].cx},#{sorted[0].cy}) and its surface is #{sorted[0].surface}"
24
+ # assertions
25
+ assert_equal(blobs.nb_blobs,12)
26
+ assert_equal(sorted[0].cx,170)
27
+ assert_equal(sorted[0].cy,128)
28
+ assert_equal(sorted[0].surface,601)
29
+ end
30
+ end