gphoto4ruby 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +5 -0
- data/README.rdoc +24 -37
- data/example.rb +17 -29
- data/ext/gphoto4ruby.c +27 -11
- metadata +3 -3
data/CHANGELOG.rdoc
CHANGED
data/README.rdoc
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
== Summary
|
4
4
|
|
5
|
-
GPhoto4Ruby is Ruby wrapping around
|
5
|
+
GPhoto4Ruby is Ruby wrapping around gphoto2 C library
|
6
6
|
(See http://gphoto.org for more information on libgphoto2 and gphoto2).
|
7
7
|
It maps a digital camera to Ruby object and allows operating it by
|
8
8
|
calling object methods.
|
@@ -19,7 +19,7 @@ calling object methods.
|
|
19
19
|
|
20
20
|
* On Ubuntu 8.04 it is:
|
21
21
|
|
22
|
-
sudo apt-get install gphoto2
|
22
|
+
sudo apt-get install gphoto2 libgphoto2-2-dev
|
23
23
|
|
24
24
|
* On Mac OS X gphoto2 is installed through DarwinPorts
|
25
25
|
|
@@ -54,50 +54,38 @@ connected through usb in PTP mode.
|
|
54
54
|
|
55
55
|
require "rubygems"
|
56
56
|
require "gphoto4ruby"
|
57
|
-
|
57
|
+
|
58
58
|
ports = GPhoto2::Camera.ports
|
59
|
-
if ports.
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
puts "values available are: " + c[cfg_key, :all].inspect
|
59
|
+
if ports.any?
|
60
|
+
puts ports.length.to_s + "cameras connected"
|
61
|
+
cams = []
|
62
|
+
ports.each do |port|
|
63
|
+
c = GPhoto2::Camera.new(port)
|
64
|
+
puts "camera in port: " + port
|
65
|
+
c.config.each do |key, value|
|
66
|
+
puts key + " value is: " + value.to_s
|
67
|
+
puts "values available are: " + c[key, :all].inspect
|
68
|
+
end
|
69
|
+
cams.push c
|
71
70
|
end
|
72
71
|
|
73
72
|
# capture image
|
74
|
-
|
75
|
-
|
73
|
+
cams.first.capture
|
74
|
+
|
76
75
|
# now camera virtual path is in the folder with images
|
77
76
|
# list image file names
|
78
|
-
puts "files on camera: " +
|
79
|
-
|
77
|
+
puts "files on camera: " + cams.first.files.inspect
|
78
|
+
|
80
79
|
# just an example of camera browsing
|
81
|
-
puts "some folder stuff: " +
|
82
|
-
|
80
|
+
puts "some folder stuff: " + cams.first.folder_up.subfolders.inspect
|
81
|
+
|
83
82
|
# save preview of captured image in the current directory on hard drive
|
84
|
-
|
85
|
-
|
83
|
+
cams.first.capture.save :type => :preview, :new_name => "PREVIEW.JPG"
|
84
|
+
|
86
85
|
# save captured file in the current directory on hard drive and delete
|
87
86
|
# it from camera
|
88
|
-
|
89
|
-
|
90
|
-
puts ports.length.to_s + "cameras connected"
|
91
|
-
cams = []
|
92
|
-
ports.each do |port|
|
93
|
-
c = GPhoto2::Camera.new(port)
|
94
|
-
puts "camera in port: " + port
|
95
|
-
c.config.each_key do |cfg_key|
|
96
|
-
puts cfg_key + " value is: " + c[cfg_key].to_s
|
97
|
-
puts "values available are: " + c[cfg_key, :all].inspect
|
98
|
-
end
|
99
|
-
cams.push c
|
100
|
-
end
|
87
|
+
cams.first.capture.save.delete
|
88
|
+
|
101
89
|
# to capture image with all attached cameras simultaneously use:
|
102
90
|
cams.each_index do |index|
|
103
91
|
if index < cams.length - 1
|
@@ -107,7 +95,6 @@ connected through usb in PTP mode.
|
|
107
95
|
end
|
108
96
|
end
|
109
97
|
end
|
110
|
-
|
111
98
|
== Contact
|
112
99
|
|
113
100
|
neq4 company:: http://neq4.com
|
data/example.rb
CHANGED
@@ -2,48 +2,36 @@ require "rubygems"
|
|
2
2
|
require "gphoto4ruby"
|
3
3
|
|
4
4
|
ports = GPhoto2::Camera.ports
|
5
|
-
if ports.
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
puts "values available are: " + c[cfg_key, :all].inspect
|
5
|
+
if ports.any?
|
6
|
+
puts ports.length.to_s + "cameras connected"
|
7
|
+
cams = []
|
8
|
+
ports.each do |port|
|
9
|
+
c = GPhoto2::Camera.new(port)
|
10
|
+
puts "camera in port: " + port
|
11
|
+
c.config.each do |key, value|
|
12
|
+
puts key + " value is: " + value.to_s
|
13
|
+
puts "values available are: " + c[key, :all].inspect
|
14
|
+
end
|
15
|
+
cams.push c
|
17
16
|
end
|
18
17
|
|
19
18
|
# capture image
|
20
|
-
|
19
|
+
cams.first.capture
|
21
20
|
|
22
21
|
# now camera virtual path is in the folder with images
|
23
22
|
# list image file names
|
24
|
-
puts "files on camera: " +
|
23
|
+
puts "files on camera: " + cams.first.files.inspect
|
25
24
|
|
26
25
|
# just an example of camera browsing
|
27
|
-
puts "some folder stuff: " +
|
26
|
+
puts "some folder stuff: " + cams.first.folder_up.subfolders.inspect
|
28
27
|
|
29
28
|
# save preview of captured image in the current directory on hard drive
|
30
|
-
|
29
|
+
cams.first.capture.save :type => :preview, :new_name => "PREVIEW.JPG"
|
31
30
|
|
32
31
|
# save captured file in the current directory on hard drive and delete
|
33
32
|
# it from camera
|
34
|
-
|
35
|
-
|
36
|
-
puts ports.length.to_s + "cameras connected"
|
37
|
-
cams = []
|
38
|
-
ports.each do |port|
|
39
|
-
c = GPhoto2::Camera.new(port)
|
40
|
-
puts "camera in port: " + port
|
41
|
-
c.config.each_key do |cfg_key|
|
42
|
-
puts cfg_key + " value is: " + c[cfg_key].to_s
|
43
|
-
puts "values available are: " + c[cfg_key, :all].inspect
|
44
|
-
end
|
45
|
-
cams.push c
|
46
|
-
end
|
33
|
+
cams.first.capture.save.delete
|
34
|
+
|
47
35
|
# to capture image with all attached cameras simultaneously use:
|
48
36
|
cams.each_index do |index|
|
49
37
|
if index < cams.length - 1
|
data/ext/gphoto4ruby.c
CHANGED
@@ -238,34 +238,50 @@ static VALUE camera_initialize(int argc, VALUE *argv, VALUE self) {
|
|
238
238
|
* call-seq:
|
239
239
|
* GPhoto2::Camera.ports => array
|
240
240
|
*
|
241
|
-
* Returns an array of usb port paths with cameras.
|
242
|
-
*
|
241
|
+
* Returns an array of usb port paths with cameras. Port paths are the same
|
242
|
+
* as in <b>gphoto2 --auto-detect</b> output. Assuming that if there are
|
243
|
+
* cameras detected with long port paths, then the one with short port path
|
244
|
+
* is a duplicate of one of the others.
|
243
245
|
*
|
244
246
|
* Examples:
|
245
247
|
*
|
246
248
|
* # with one camera connected
|
247
|
-
* GPhoto2::Camera.ports #=> []
|
249
|
+
* GPhoto2::Camera.ports #=> ["usb:"]
|
248
250
|
* # with two cameras connected
|
249
251
|
* GPhoto2::Camera.ports #=> ["usb:005,004", "usb:005,006"]
|
250
252
|
*
|
251
253
|
*/
|
252
254
|
static VALUE camera_class_ports(VALUE klass) {
|
253
|
-
int i,
|
255
|
+
int i, camsTotal;
|
256
|
+
GPContext *context;
|
257
|
+
CameraAbilitiesList *abilList;
|
254
258
|
GPPortInfoList *portInfoList;
|
255
|
-
|
259
|
+
CameraList *camList;
|
260
|
+
const char *pName = NULL;
|
261
|
+
char *e = "";
|
256
262
|
VALUE arr;
|
257
|
-
|
263
|
+
|
264
|
+
context = gp_context_new();
|
258
265
|
gp_result_check(gp_port_info_list_new(&portInfoList));
|
259
266
|
gp_result_check(gp_port_info_list_load(portInfoList));
|
260
|
-
|
267
|
+
gp_result_check(gp_abilities_list_new(&abilList));
|
268
|
+
gp_result_check(gp_abilities_list_load(abilList, context));
|
269
|
+
gp_result_check(gp_list_new(&camList));
|
270
|
+
|
271
|
+
gp_result_check(gp_abilities_list_detect(abilList, portInfoList, camList, context));
|
272
|
+
|
273
|
+
camsTotal = gp_result_check(gp_list_count(camList));
|
261
274
|
arr = rb_ary_new();
|
262
|
-
for(i = 0; i <
|
263
|
-
gp_result_check(
|
264
|
-
if ((
|
265
|
-
rb_ary_push(arr, rb_str_new2(
|
275
|
+
for(i = 0; i < camsTotal; i++) {
|
276
|
+
gp_result_check(gp_list_get_value(camList, i, &pName));
|
277
|
+
if ((camsTotal == 1) || (strlen(pName) > 4)) {
|
278
|
+
rb_ary_push(arr, rb_str_new2(pName));
|
266
279
|
}
|
267
280
|
}
|
281
|
+
gp_result_check(gp_list_free(camList));
|
268
282
|
gp_result_check(gp_port_info_list_free(portInfoList));
|
283
|
+
gp_result_check(gp_abilities_list_free(abilList));
|
284
|
+
free(context);
|
269
285
|
return arr;
|
270
286
|
}
|
271
287
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gphoto4ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- heq4 company
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2008-
|
13
|
+
date: 2008-09-05 00:00:00 +04:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|
@@ -70,6 +70,6 @@ rubyforge_project: gphoto4ruby
|
|
70
70
|
rubygems_version: 1.1.1
|
71
71
|
signing_key:
|
72
72
|
specification_version: 2
|
73
|
-
summary: GPhoto4Ruby is Ruby wrapping around
|
73
|
+
summary: GPhoto4Ruby is Ruby wrapping around gphoto2 C library
|
74
74
|
test_files: []
|
75
75
|
|