camcapture 0.2.0-i686-linux → 0.3.0-i686-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.
data/README CHANGED
@@ -10,10 +10,7 @@ in combination with TCPServer, sockets, serial port communication (Ruby/Serialpo
10
10
 
11
11
  -- Installation --
12
12
 
13
- $ cd ext
14
- $ ruby extconf.rb
15
- $ make
16
- $ sudo make install
13
+ $ sudo ./setup.rb
17
14
 
18
15
  -- Testing --
19
16
 
@@ -49,7 +49,7 @@ static void put16(unsigned int value, FILE* outf)
49
49
  static VALUE cam_capture_save_bmp(VALUE self, VALUE filename)
50
50
  {
51
51
  VALUE image,image2;
52
- char *imageData=RSTRING(image)->ptr;
52
+ char *imageData;
53
53
  char *fnx=RSTRING(filename)->ptr;
54
54
  int width,height;
55
55
  int h,w,r,g,b;
@@ -209,10 +209,10 @@ static VALUE cam_capture_to_bgr(VALUE self)
209
209
  int width,height;
210
210
  VALUE rwidth, rheight;
211
211
 
212
- rwidth=rb_iv_get(self, "@width");
213
- width=NUM2INT(rwidth);
214
- rheight=rb_iv_get(self, "@height");
215
- height=NUM2INT(rheight);
212
+ rwidth = rb_iv_get(self, "@width");
213
+ width = NUM2INT(rwidth);
214
+ rheight = rb_iv_get(self, "@height");
215
+ height = NUM2INT(rheight);
216
216
 
217
217
  image=rb_iv_get(self, "@image");
218
218
  image2=StringValue(image);
@@ -231,11 +231,20 @@ static VALUE cam_capture_to_bgr(VALUE self)
231
231
  return self;
232
232
  }
233
233
 
234
+ static VALUE cam_address(VALUE self)
235
+ {
236
+ char *ptr;
237
+ VALUE str = rb_iv_get(self, "@image");
238
+ ptr = RSTRING(str)->ptr;
239
+ return INT2FIX((int)ptr);
240
+ }
241
+
234
242
  void Init_camcapture() {
235
243
  cCamCapture = rb_define_class("CamCapture", rb_cIO);
236
244
  rb_define_singleton_method(cCamCapture, "create", cam_capture_create, 4);
237
245
  rb_define_method(cCamCapture, "save_bmp", cam_capture_save_bmp, 1);
238
246
  rb_define_method(cCamCapture, "to_bgr", cam_capture_to_bgr, 0);
247
+ rb_define_method(cCamCapture, "address", cam_address, 0);
239
248
 
240
249
  #define VIDEO_PALETTE_GREY 1 /* Linear greyscale */
241
250
  #define VIDEO_PALETTE_HI240 2 /* High 240 cube (BT848) */
@@ -259,32 +268,4 @@ void Init_camcapture() {
259
268
  rb_define_const(cCamCapture, "YUV422", INT2FIX(VIDEO_PALETTE_YUV422));
260
269
  rb_define_const(cCamCapture, "PAL", INT2FIX(0));
261
270
  rb_define_const(cCamCapture, "NTSC", INT2FIX(32));
262
-
263
- /* The following definitions are more easily carried out in Ruby */
264
- rb_eval_string(
265
- "class CamCapture\n"
266
-
267
- "attr_reader :width, :height, :image\n"
268
-
269
- "def CamCapture.new(device_number=0, w=0, h=0, palette=0)\n"
270
- "cap = create(device_number, w, h, palette)\n"
271
- "return cap\n"
272
- "end\n"
273
-
274
- "def capture\n"
275
- "sysread(@width*@height*3, @image)\n"
276
- "end\n"
277
-
278
- "end\n"
279
- );
280
271
  }
281
-
282
- /* For CamelliaLib interfacing :
283
- *
284
- "def capture(image)\n"
285
- "image.alloc_bgr(@width, @height) if image.width != @width or image.height != @height or not image.allocated?\n"
286
- "if image.widthStep != @width*3 then image=nil; return; end\n"
287
- "image.set_pixels(sysread(@width*@height*3,@image))\n"
288
- "end\n"
289
- */
290
-
data/lib/camcapture.rb CHANGED
@@ -8,9 +8,22 @@ class CamCapture
8
8
  return cap
9
9
  end
10
10
 
11
- def capture
12
- sysread(@width*@height*3, @image)
11
+ if Module.constants.include?("Camellia") then
12
+ def capture
13
+ @camimage ||= Camellia::CamImage.new
14
+ if not @camimage.allocated? or @camimage.width != @width or @camimage.height != @height
15
+ @camimage.fill_header(@width, @height, Camellia::CAM_DEPTH_8U, Camellia::CAM_CHANNELSEQ_RGB)
16
+ if @camimage.widthStep != @width*3 then @camimage = nil; return; end
17
+ end
18
+ sysread(@width*@height*3,@image)
19
+ @camimage.set_image_data(@image)
20
+ end
21
+ else
22
+ def capture
23
+ sysread(@width*@height*3, @image)
24
+ end
13
25
  end
26
+
14
27
  end
15
28
 
16
29
 
@@ -0,0 +1,17 @@
1
+ require 'camellia'
2
+ begin
3
+ require 'camcapture'
4
+ puts "Successfully loaded module camcapture"
5
+ rescue LoadError
6
+ require 'rubygems'
7
+ require 'camcapture'
8
+ puts "Successfully loaded gem camcapture"
9
+ end
10
+
11
+ camera=CamCapture.new 0, 320, 240
12
+ puts "Image size is #{camera.width}x#{camera.height}"
13
+ for i in 1..10 do
14
+ image=camera.capture
15
+ puts "image #{i} : #{image.imageSize} bytes grabbed"
16
+ image.save_bmp("grab#{i}.bmp")
17
+ end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: camcapture
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.2.0
7
- date: 2007-10-08 00:00:00 +02:00
6
+ version: 0.3.0
7
+ date: 2007-11-27 00:00:00 +01:00
8
8
  summary: Camera/Webcam capture using Video4Linux interface. Compatible with Ruby Threads.
9
9
  require_paths:
10
10
  - lib
@@ -35,6 +35,7 @@ files:
35
35
  - README
36
36
  test_files:
37
37
  - test/test.rb
38
+ - test/test_camellia.rb
38
39
  rdoc_options: []
39
40
 
40
41
  extra_rdoc_files: