camellia 2.7.0-i386-mswin32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. data/README +59 -0
  2. data/doc/README +58 -0
  3. data/doc/camellia.dox +205 -0
  4. data/ext/Debug/BuildLog.htm +0 -0
  5. data/ext/Debug/camellia.dll.embed.manifest +1 -0
  6. data/ext/Debug/vc80.idb +0 -0
  7. data/ext/Debug/vc80.pdb +0 -0
  8. data/ext/README +12 -0
  9. data/ext/Release/BuildLog.htm +0 -0
  10. data/ext/Release/camellia.exp +0 -0
  11. data/ext/Release/swig_ruby.pch +0 -0
  12. data/ext/Release/vc60.idb +0 -0
  13. data/ext/Release/vc80.idb +0 -0
  14. data/ext/camellia_ruby.i +493 -0
  15. data/ext/camellia_ruby_wrap.cpp +21103 -0
  16. data/ext/camellia_ruby_wrap.cxx +21103 -0
  17. data/ext/extconf.rb +12 -0
  18. data/ext/install.rb +11 -0
  19. data/ext/swig_ruby.dsp +159 -0
  20. data/ext/swig_ruby.plg +53 -0
  21. data/ext/swig_ruby.vcproj +290 -0
  22. data/ext/swig_ruby.vcproj.HAMBURG.Bruno STEUX.user +65 -0
  23. data/ext/test.rb +31 -0
  24. data/inc/SHLWAPI.H +661 -0
  25. data/inc/cam_capture.h +202 -0
  26. data/inc/camellia.h +2651 -0
  27. data/inc/camellia_internals.h +205 -0
  28. data/inc/config.h +59 -0
  29. data/inc/config.h.in +58 -0
  30. data/inc/stamp-h1 +1 -0
  31. data/lib/camellia-fox.rb +39 -0
  32. data/lib/camellia.dll +0 -0
  33. data/test/test_arithm.rb +13 -0
  34. data/test/test_capture.rb +15 -0
  35. data/test/test_color_labeling.rb +45 -0
  36. data/test/test_copy.rb +13 -0
  37. data/test/test_draw.rb +15 -0
  38. data/test/test_fixed_filters.rb +23 -0
  39. data/test/test_fox.rb +106 -0
  40. data/test/test_fox2.rb +108 -0
  41. data/test/test_histogram.rb +18 -0
  42. data/test/test_hough.rb +29 -0
  43. data/test/test_keypoints.rb +106 -0
  44. data/test/test_labeling.rb +30 -0
  45. data/test/test_mask.rb +34 -0
  46. data/test/test_warping.rb +46 -0
  47. data/test/test_watershed.rb +35 -0
  48. data/test/ts_camellia.rb +12 -0
  49. metadata +110 -0
@@ -0,0 +1,205 @@
1
+ /** \file camellia_internals.h
2
+ * \brief Camellia Image Processing Library header file
3
+ * \author Bruno STEUX (ENSMP)
4
+ *
5
+ * Camellia Image Processing Library
6
+ *
7
+
8
+ The Camellia Image Processing Library is an open source low-level image processing library.
9
+ As it uses the IplImage structure to describe images, it is a good replacement to the IPL (Intel) library
10
+ and a good complement to the OpenCV library. It includes a lot of functions for image processing
11
+ (filtering, morphological mathematics, labeling, warping, loading/saving images, etc.),
12
+ some of them being highly optimized; It is also cross-platform and robust. It is doxygen-documented
13
+ and examples of use are provided.
14
+
15
+ This software library is an outcome of the Camellia european project (IST-2001-34410).
16
+ It was developped by the Ecole des Mines de Paris (ENSMP), in coordination with
17
+ the other partners of the project.
18
+
19
+ ==========================================================================
20
+
21
+ Copyright (c) 2002-2007, Ecole des Mines de Paris - Centre de Robotique
22
+ All rights reserved.
23
+
24
+ Redistribution and use in source and binary forms, with or without
25
+ modification, are permitted provided that the following conditions are met:
26
+
27
+ * Redistributions of source code must retain the above copyright
28
+ notice, this list of conditions and the following disclaimer.
29
+ * Redistributions in binary form must reproduce the above copyright
30
+ notice, this list of conditions and the following disclaimer
31
+ in the documentation and/or other materials provided with the distribution.
32
+ * Neither the name of the Ecole des Mines de Paris nor the names of
33
+ its contributors may be used to endorse or promote products
34
+ derived from this software without specific prior written permission.
35
+
36
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
37
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
38
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
39
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
40
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
41
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
42
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
43
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
44
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
45
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
46
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
47
+
48
+ ==========================================================================
49
+
50
+ */
51
+
52
+ #ifndef _CAMELLIA_INTERNALS_H_
53
+ #define _CAMELLIA_INTERNALS_H_
54
+
55
+ #ifdef __cplusplus
56
+ extern "C" {
57
+ #endif
58
+
59
+ // Binary images management
60
+ #ifdef CAM_64BITS
61
+ #ifdef _WIN32
62
+ #define CAM_BIT_BLOCK unsigned __int64
63
+ #else
64
+ #define CAM_BIT_BLOCK unsigned long long int
65
+ #endif
66
+ #define CAM_BIT_BLOCK_SIZE_SHIFT 6
67
+ #ifndef CAM_BIG_ENDIAN
68
+ #ifdef _WIN32
69
+ #define CAM_BIT_BLOCK_SWAP(x) ( \
70
+ (((x)&0x00000000000000ffi64)<<56)| \
71
+ (((x)&0x000000000000ff00i64)<<40)| \
72
+ (((x)&0x0000000000ff0000i64)<<24)| \
73
+ (((x)&0x00000000ff000000i64)<< 8)| \
74
+ (((x)&0x000000ff00000000i64)>> 8)| \
75
+ (((x)&0x0000ff0000000000i64)>>24)| \
76
+ (((x)&0x00ff000000000000i64)>>40)| \
77
+ (((x)&0xff00000000000000i64)>>56))
78
+ #else
79
+ #define CAM_BIT_BLOCK_SWAP(x) ( \
80
+ (((x)&0x00000000000000ffull)<<56)| \
81
+ (((x)&0x000000000000ff00ull)<<40)| \
82
+ (((x)&0x0000000000ff0000ull)<<24)| \
83
+ (((x)&0x00000000ff000000ull)<< 8)| \
84
+ (((x)&0x000000ff00000000ull)>> 8)| \
85
+ (((x)&0x0000ff0000000000ull)>>24)| \
86
+ (((x)&0x00ff000000000000ull)>>40)| \
87
+ (((x)&0xff00000000000000ull)>>56))
88
+ #endif //_WIN32
89
+ #else
90
+ #define CAM_BIT_BLOCK_SWAP(x) (x)
91
+ #endif
92
+ #else
93
+ #define CAM_BIT_BLOCK unsigned int
94
+ #define CAM_BIT_BLOCK_SIZE_SHIFT 5
95
+ #ifndef CAM_BIG_ENDIAN
96
+ #define CAM_BIT_BLOCK_SWAP(x) ((((x)&0x000000ff)<<24)|(((x)&0x0000ff00)<<8)|(((x)&0x00ff0000)>>8)|(((x)&0xff000000)>>24))
97
+ #else
98
+ #define CAM_BIT_BLOCK_SWAP(x) (x)
99
+ #endif
100
+ #endif
101
+ #define CAM_BIT_BLOCK_SIZE (sizeof(CAM_BIT_BLOCK)*8)
102
+
103
+ // Internal functions
104
+ typedef struct {
105
+ unsigned char *srcptr;
106
+ unsigned char *dstptr;
107
+ CamROI srcroi; // Source ROI after clipping
108
+ CamROI dstroi; // Dest ROI after clipping
109
+ int srcchoffset; // Channel offset for the source
110
+ int dstchoffset; // Channel offset for the destination image
111
+ int nChannels; // Number of effective channels (considering ROIs)
112
+ int srcinc; // Pixel to pixel increment
113
+ int dstinc; // Pixel to pixel increment
114
+ int srclinc; // Line to line increment
115
+ int dstlinc; // Line to line increment
116
+ int srcpinc; // Plane to plane increment
117
+ int dstpinc; // Plane to plane increment
118
+
119
+ int mask_xOffset;// Offset when mask doesn't fit within image boundaries
120
+ int mask_yOffset;// Offset when mask doesn't fit within image boundaries
121
+ CamRLEImage *mask; // Mask to be applied to the operation
122
+ CamRLEImage auto_mask; // Automatically allocated if provided mask is not RLE
123
+ } CamInternalROIPolicyStruct;
124
+
125
+ #define CAM_MASK_SUPPORT 1
126
+ #define CAM_IGNORE_COI_MISMATCH 2
127
+ #define CAM_NO_ROI_INTERSECTION 4
128
+
129
+ int camInternalROIPolicy(CamImage* src, CamImage *dst, CamInternalROIPolicyStruct *res, int options);
130
+ void camInternalROIPolicyExit(CamInternalROIPolicyStruct *res); // Call to this function is necessary only when the caller manages image bit-masking
131
+
132
+ const char *camGetErrorStr();
133
+ void camSetErrorStr(const char *s);
134
+
135
+ // Check arguments
136
+ #ifndef CAM_OPTIMIZE
137
+ #define CAM_CHECK_ARGS(function, condition) \
138
+ if (!(condition)) {camError(#function, "Bad argument : " #condition);return 0;}
139
+ #else
140
+ #define CAM_CHECK_ARGS(function, condition)
141
+ #endif
142
+
143
+ #ifndef CAM_OPTIMIZE
144
+ #define CAM_CHECK_ARGS2(function, condition, text) \
145
+ if (!(condition)) {camError(#function, "Bad argument : " #text);return 0;}
146
+ #else
147
+ #define CAM_CHECK_ARGS2(function, condition, text)
148
+ #endif
149
+
150
+ #ifndef CAM_OPTIMIZE
151
+ #define CAM_CHECK(function, condition) \
152
+ if (!(condition)) {camError(#function, NULL);return 0;}
153
+ #else
154
+ #define CAM_CHECK(function, condition)
155
+ #endif
156
+
157
+ // Mask management macros
158
+
159
+ #define DECLARE_MASK_MANAGEMENT \
160
+ CamRun *run; \
161
+ int startx,endx
162
+
163
+ #define INIT_MASK_MANAGEMENT \
164
+ if (iROI.mask) { \
165
+ run=iROI.mask->runs+1; \
166
+ while (run->line!=iROI.mask_yOffset) run++; \
167
+ } else { \
168
+ run=NULL; \
169
+ }
170
+
171
+ #define BEGIN_MASK_MANAGEMENT(code) \
172
+ startx=-iROI.mask_xOffset; \
173
+ do { \
174
+ if (!iROI.mask) { \
175
+ endx=width; \
176
+ } else { \
177
+ do { \
178
+ while ((run->value==0)&&(run->line==y+iROI.mask_yOffset)) { \
179
+ startx+=run->length; \
180
+ run++; \
181
+ } \
182
+ if (run->line!=y+iROI.mask_yOffset) break; \
183
+ endx=startx+run->length; \
184
+ } while ((endx<=0)&&(run++)); \
185
+ if (run->line!=y+iROI.mask_yOffset) break; \
186
+ if (startx<0) startx=0; \
187
+ if (startx>width) startx=width; \
188
+ if (endx>width) endx=width; \
189
+ code \
190
+ }
191
+
192
+ #define END_MASK_MANAGEMENT \
193
+ if (iROI.mask) { \
194
+ startx=endx; \
195
+ run++; \
196
+ } \
197
+ } while ((run)&&(run->line==y+iROI.mask_yOffset));
198
+
199
+ #ifdef __cplusplus
200
+ }
201
+ #endif
202
+
203
+
204
+ #endif
205
+
data/inc/config.h ADDED
@@ -0,0 +1,59 @@
1
+ /* inc/config.h. Generated from config.h.in by configure. */
2
+ /* inc/config.h.in. Generated from configure.in by autoheader. */
3
+
4
+ /* Define to 1 if you have the <dlfcn.h> header file. */
5
+ #define HAVE_DLFCN_H 1
6
+
7
+ /* Define to 1 if you have the <inttypes.h> header file. */
8
+ #define HAVE_INTTYPES_H 1
9
+
10
+ /* Define to 1 if you have the <linux/videodev.h> header file. */
11
+ /* #undef HAVE_LINUX_VIDEODEV_H */
12
+
13
+ /* Define to 1 if you have the <memory.h> header file. */
14
+ #define HAVE_MEMORY_H 1
15
+
16
+ /* Define to 1 if you have the <stdint.h> header file. */
17
+ #define HAVE_STDINT_H 1
18
+
19
+ /* Define to 1 if you have the <stdlib.h> header file. */
20
+ #define HAVE_STDLIB_H 1
21
+
22
+ /* Define to 1 if you have the <strings.h> header file. */
23
+ #define HAVE_STRINGS_H 1
24
+
25
+ /* Define to 1 if you have the <string.h> header file. */
26
+ #define HAVE_STRING_H 1
27
+
28
+ /* Define to 1 if you have the <sys/stat.h> header file. */
29
+ #define HAVE_SYS_STAT_H 1
30
+
31
+ /* Define to 1 if you have the <sys/types.h> header file. */
32
+ #define HAVE_SYS_TYPES_H 1
33
+
34
+ /* Define to 1 if you have the <unistd.h> header file. */
35
+ #define HAVE_UNISTD_H 1
36
+
37
+ /* Name of package */
38
+ #define PACKAGE "CamelliaLib"
39
+
40
+ /* Define to the address where bug reports for this package should be sent. */
41
+ #define PACKAGE_BUGREPORT ""
42
+
43
+ /* Define to the full name of this package. */
44
+ #define PACKAGE_NAME ""
45
+
46
+ /* Define to the full name and version of this package. */
47
+ #define PACKAGE_STRING ""
48
+
49
+ /* Define to the one symbol short name of this package. */
50
+ #define PACKAGE_TARNAME ""
51
+
52
+ /* Define to the version of this package. */
53
+ #define PACKAGE_VERSION ""
54
+
55
+ /* Define to 1 if you have the ANSI C header files. */
56
+ #define STDC_HEADERS 1
57
+
58
+ /* Version number of package */
59
+ #define VERSION "2.6.2"
data/inc/config.h.in ADDED
@@ -0,0 +1,58 @@
1
+ /* inc/config.h.in. Generated from configure.in by autoheader. */
2
+
3
+ /* Define to 1 if you have the <dlfcn.h> header file. */
4
+ #undef HAVE_DLFCN_H
5
+
6
+ /* Define to 1 if you have the <inttypes.h> header file. */
7
+ #undef HAVE_INTTYPES_H
8
+
9
+ /* Define to 1 if you have the <linux/videodev.h> header file. */
10
+ #undef HAVE_LINUX_VIDEODEV_H
11
+
12
+ /* Define to 1 if you have the <memory.h> header file. */
13
+ #undef HAVE_MEMORY_H
14
+
15
+ /* Define to 1 if you have the <stdint.h> header file. */
16
+ #undef HAVE_STDINT_H
17
+
18
+ /* Define to 1 if you have the <stdlib.h> header file. */
19
+ #undef HAVE_STDLIB_H
20
+
21
+ /* Define to 1 if you have the <strings.h> header file. */
22
+ #undef HAVE_STRINGS_H
23
+
24
+ /* Define to 1 if you have the <string.h> header file. */
25
+ #undef HAVE_STRING_H
26
+
27
+ /* Define to 1 if you have the <sys/stat.h> header file. */
28
+ #undef HAVE_SYS_STAT_H
29
+
30
+ /* Define to 1 if you have the <sys/types.h> header file. */
31
+ #undef HAVE_SYS_TYPES_H
32
+
33
+ /* Define to 1 if you have the <unistd.h> header file. */
34
+ #undef HAVE_UNISTD_H
35
+
36
+ /* Name of package */
37
+ #undef PACKAGE
38
+
39
+ /* Define to the address where bug reports for this package should be sent. */
40
+ #undef PACKAGE_BUGREPORT
41
+
42
+ /* Define to the full name of this package. */
43
+ #undef PACKAGE_NAME
44
+
45
+ /* Define to the full name and version of this package. */
46
+ #undef PACKAGE_STRING
47
+
48
+ /* Define to the one symbol short name of this package. */
49
+ #undef PACKAGE_TARNAME
50
+
51
+ /* Define to the version of this package. */
52
+ #undef PACKAGE_VERSION
53
+
54
+ /* Define to 1 if you have the ANSI C header files. */
55
+ #undef STDC_HEADERS
56
+
57
+ /* Version number of package */
58
+ #undef VERSION
data/inc/stamp-h1 ADDED
@@ -0,0 +1 @@
1
+ timestamp for inc/config.h
@@ -0,0 +1,39 @@
1
+ require 'rubygems'
2
+ require_gem 'fxruby'
3
+
4
+ require 'camellia'
5
+ include Camellia
6
+
7
+ class Fox::FXImage
8
+ def to_camellia
9
+ s=FXStream.new
10
+ mem=" "*(width*height*4)
11
+ s.open(FXStreamSave, width*height*4, mem)
12
+ unbound_savePixels=FXImage.instance_method(:savePixels)
13
+ bound_savePixels=unbound_savePixels.bind(self)
14
+ bound_savePixels.call(s)
15
+ image=CamImage.new(width, height, CAM_DEPTH_8U, CAM_COLORMODEL_RGBA)
16
+ image.set_pixels(mem)
17
+ return image
18
+ end
19
+ end
20
+
21
+ class Camellia::CamImage
22
+ def to_fox(app, picture=nil)
23
+ if picture==nil
24
+ pict=FXImage.new(app, nil, IMAGE_OWNED|IMAGE_KEEP, width, height)
25
+ else
26
+ pict=picture
27
+ end if
28
+ image=CamImage.new(width, height, CAM_DEPTH_8U, CAM_COLORMODEL_RGBA)
29
+ copy(image)
30
+ FXStream.new { |stream|
31
+ stream.open(FXStreamLoad, image.imageSize, image.to_s)
32
+ unbound_loadPixels=FXImage.instance_method(:loadPixels)
33
+ bound_loadPixels=unbound_loadPixels.bind(pict)
34
+ bound_loadPixels.call(stream)
35
+ }
36
+ return pict
37
+ end
38
+ end
39
+
data/lib/camellia.dll ADDED
Binary file
@@ -0,0 +1,13 @@
1
+ require 'test/unit'
2
+ require 'lib/camellia'
3
+ include Camellia
4
+ class TestArithm < Test::Unit::TestCase
5
+ def test_arithm
6
+ source=CamImage.new
7
+ # load picture chess.pgm
8
+ source.load_pgm("resources/chess.pgm")
9
+ n=source.arithm(source,source,CAM_SUB)
10
+ # resulting pixel sum should be 0
11
+ assert_equal(n,0)
12
+ end
13
+ end
@@ -0,0 +1,15 @@
1
+ require 'test/unit'
2
+ require 'lib/camellia'
3
+ include Camellia
4
+
5
+ class TestCapture < Test::Unit::TestCase
6
+ def test_capture
7
+ image=CamImage.new
8
+ camera=CamCapture2.new
9
+ for i in 1..30 do
10
+ camera.capture(image)
11
+ puts "Grabbed image #{i}"
12
+ end
13
+ image.save_bmp('output/capture.bmp')
14
+ end
15
+ end
@@ -0,0 +1,45 @@
1
+ require 'test/unit'
2
+ require 'lib/camellia'
3
+ include Camellia
4
+ class TestLabeling < Test::Unit::TestCase
5
+ def test_labeling
6
+
7
+ # load picture alfa156.bmp
8
+ image=CamImage.new
9
+ image.load_bmp("resources/alfa156.bmp")
10
+ yuv=image.to_yuv
11
+
12
+ # set color clusters
13
+ clusters=CamTable.new
14
+ clusters.set([
15
+ # Ymin Ymax Umin Umax Vmin Vmax
16
+ 0, 60, 0, 255, 0, 255, # Black
17
+ 230, 255, 0, 255, 0, 255, # White
18
+ 0, 255, 0, 255, 140, 255 # Red
19
+ ])
20
+ cluster_colors=[cam_rgb(0,0,0),cam_rgb(255,255,255),cam_rgb(255,0,0)]
21
+
22
+ # threshold and encode
23
+ encoded=yuv.encode_color(clusters)
24
+ puts "Number of runs : #{encoded.nb_runs}"
25
+
26
+ # labeling
27
+ blobs=encoded.labeling!
28
+ puts "#{blobs.nb_blobs} blobs detected"
29
+
30
+ # print and deaw the results
31
+ i=0
32
+ blobs.each {|b|
33
+ puts "Blob #{i} : Val=#{b.value} (#{b.top},#{b.left},#{b.width},#{b.height}) Surface=#{b.surface}"
34
+ image.draw_rectangle(b.left,b.top,b.left+b.width-1,b.top+b.height-1,cluster_colors[b.value-1])
35
+ i=i+1
36
+ }
37
+
38
+ # save the result
39
+ image.save_bmp("output/ruby_alfa156_labeling.bmp")
40
+
41
+ # assertions
42
+ assert_equal(encoded.nb_runs,3026)
43
+ assert_equal(blobs.nb_blobs,190)
44
+ end
45
+ end
data/test/test_copy.rb ADDED
@@ -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
data/test/test_draw.rb ADDED
@@ -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
data/test/test_fox.rb ADDED
@@ -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
+