gphoto4ruby 0.1.1 → 0.1.2
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/CHANGELOG.rdoc +10 -0
- data/README.rdoc +79 -6
- data/Rakefile +1 -1
- data/docs/{COPIYNG.LESSER → COPYING.LESSER} +0 -0
- data/example.rb +19 -4
- data/ext/gphoto4ruby.c +201 -39
- data/ext/gphoto4ruby.h +4 -0
- metadata +13 -9
- data/docs/gphoto4ruby_api_ru.txt +0 -49
data/CHANGELOG.rdoc
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
== master
|
2
2
|
|
3
|
+
* Added "delete file from camera" function
|
4
|
+
|
5
|
+
== 0.1.2
|
6
|
+
|
7
|
+
* Had to change version number to make gem build
|
8
|
+
* 'Save' function can accept options. See rdoc
|
9
|
+
* Gemspec made safer
|
10
|
+
|
11
|
+
== 0.1.1
|
12
|
+
|
3
13
|
* Added rdoc comments
|
4
14
|
* Added saving captured image to specified folder
|
5
15
|
* Added folders browsing
|
data/README.rdoc
CHANGED
@@ -17,19 +17,92 @@ calling object methods.
|
|
17
17
|
* First of all you'll need the original gphoto2 C library installed. For
|
18
18
|
installation instructions goto http://gphoto.org.
|
19
19
|
|
20
|
-
*
|
21
|
-
So you can download it from http://rubyforge.org/projects/gphoto4ruby/
|
22
|
-
and install it with:
|
20
|
+
* On Ubuntu 8.04 it is:
|
23
21
|
|
24
|
-
sudo
|
22
|
+
sudo apt-get install gphoto2
|
23
|
+
|
24
|
+
* On Mac OS X gphoto2 is installed through DarwinPorts
|
25
|
+
|
26
|
+
* You can install GPhoto4Ruby gem from GitHub or from RubyForge. Use one of
|
27
|
+
the following lines depending on your preferences:
|
28
|
+
|
29
|
+
sudo gem install lonelyelk-gphoto4ruby --source http://gems.github.com
|
30
|
+
|
31
|
+
<b>or</b>
|
32
|
+
|
33
|
+
sudo gem install gphoto4ruby
|
25
34
|
|
26
|
-
*
|
35
|
+
* Connect your digital camera through usb, locate example.rb file and run:
|
27
36
|
|
28
37
|
ruby example.rb
|
38
|
+
|
39
|
+
* <b>NOTE!<b> On Mac OS X there is a process you need to kill before using
|
40
|
+
gphoto2. You can find more information on this at http://gphoto.org
|
29
41
|
|
30
42
|
== Usage
|
31
43
|
|
32
|
-
|
44
|
+
After installation of this gem rdocs are generated for you. Ruby file
|
45
|
+
<b>example.rb</b> is installed along with this gem. All examples are tested
|
46
|
+
on Kubuntu 8.04 and Mac OS X 10.4.11 with digital camera Nikon DSC D80
|
47
|
+
connected through usb in PTP mode.
|
48
|
+
|
49
|
+
<b>example.rb:</b>
|
50
|
+
|
51
|
+
require "rubygems"
|
52
|
+
require "gphoto4ruby"
|
53
|
+
|
54
|
+
ports = GPhoto2::Camera.ports
|
55
|
+
if ports.empty?
|
56
|
+
|
57
|
+
# ports array can be empty if there is only one camera plugged in
|
58
|
+
# or there are no cameras connected to the computer
|
59
|
+
# assuming there is one
|
60
|
+
c = GPhoto2::Camera.new()
|
61
|
+
|
62
|
+
# list available configuration items with current values and lists
|
63
|
+
# of allowed values
|
64
|
+
c.configs.each do |cfg|
|
65
|
+
puts cfg + " value is: " + c[cfg].to_s
|
66
|
+
puts "values available are: " + c[cfg, :all].inspect
|
67
|
+
end
|
68
|
+
|
69
|
+
# capture image
|
70
|
+
c.capture
|
71
|
+
|
72
|
+
# now camera virtual path is in the folder with images
|
73
|
+
# list image file names
|
74
|
+
puts "files on camera: " + c.files.inspect
|
75
|
+
|
76
|
+
# just an example of camera browsing
|
77
|
+
puts "some folder stuff: " + c.folder_up.subfolders.inspect
|
78
|
+
|
79
|
+
# save preview of captured image in the current directory on hard drive
|
80
|
+
c.capture.save :type => :preview, :new_name => "PREVIEW.JPG"
|
81
|
+
|
82
|
+
# save captured file in the current directory on hard drive and delete
|
83
|
+
# it from camera
|
84
|
+
c.capture.save.delete
|
85
|
+
else
|
86
|
+
puts ports.length.to_s + "cameras connected"
|
87
|
+
cams = []
|
88
|
+
ports.each do |port|
|
89
|
+
c = GPhoto2::Camera.new(port)
|
90
|
+
puts "camera in port: " + port
|
91
|
+
c.configs.each do |cfg|
|
92
|
+
puts cfg + " value is: " + c[cfg].to_s
|
93
|
+
puts "values available are: " + c[cfg, :all].inspect
|
94
|
+
end
|
95
|
+
cams.push c
|
96
|
+
end
|
97
|
+
# to capture image with all attached cameras simultaneously use:
|
98
|
+
cams.each_index do |index|
|
99
|
+
if index < cams.length - 1
|
100
|
+
fork {cams[index].capture; exit!}
|
101
|
+
else
|
102
|
+
cams[index].capture
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
33
106
|
|
34
107
|
== Contact
|
35
108
|
|
data/Rakefile
CHANGED
@@ -10,7 +10,7 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
|
|
10
10
|
include("ext/gphoto4ruby.c")
|
11
11
|
rdoc.main = "README.rdoc"
|
12
12
|
rdoc.title = "GPhoto4Ruby documentation"
|
13
|
-
rdoc.rdoc_dir = "
|
13
|
+
rdoc.rdoc_dir = "rdoc"
|
14
14
|
rdoc.options << "--charset=UTF-8"
|
15
15
|
rdoc.options << "--webcvs=http://github.com/lonelyelk/gphoto4ruby/tree/master"
|
16
16
|
end
|
File without changes
|
data/example.rb
CHANGED
@@ -3,17 +3,35 @@ require "gphoto4ruby"
|
|
3
3
|
|
4
4
|
ports = GPhoto2::Camera.ports
|
5
5
|
if ports.empty?
|
6
|
+
|
6
7
|
# ports array can be empty if there is only one camera plugged in
|
7
8
|
# or there are no cameras connected to the computer
|
8
9
|
# assuming there is one
|
9
10
|
c = GPhoto2::Camera.new()
|
11
|
+
|
12
|
+
# list available configuration items with current values and lists
|
13
|
+
# of allowed values
|
10
14
|
c.configs.each do |cfg|
|
11
15
|
puts cfg + " value is: " + c[cfg].to_s
|
12
16
|
puts "values available are: " + c[cfg, :all].inspect
|
13
17
|
end
|
18
|
+
|
19
|
+
# capture image
|
14
20
|
c.capture
|
21
|
+
|
22
|
+
# now camera virtual path is in the folder with images
|
23
|
+
# list image file names
|
15
24
|
puts "files on camera: " + c.files.inspect
|
25
|
+
|
26
|
+
# just an example of camera browsing
|
16
27
|
puts "some folder stuff: " + c.folder_up.subfolders.inspect
|
28
|
+
|
29
|
+
# save preview of captured image in the current directory on hard drive
|
30
|
+
c.capture.save :type => :preview, :new_name => "PREVIEW.JPG"
|
31
|
+
|
32
|
+
# save captured file in the current directory on hard drive and delete
|
33
|
+
# it from camera
|
34
|
+
c.capture.save.delete
|
17
35
|
else
|
18
36
|
puts ports.length.to_s + "cameras connected"
|
19
37
|
cams = []
|
@@ -24,12 +42,9 @@ else
|
|
24
42
|
puts cfg + " value is: " + c[cfg].to_s
|
25
43
|
puts "values available are: " + c[cfg, :all].inspect
|
26
44
|
end
|
27
|
-
c.capture
|
28
|
-
puts "files on camera: " + c.files.inspect
|
29
|
-
puts "some folder stuff: " + c.folder_up.subfolders.inspect
|
30
45
|
cams.push c
|
31
46
|
end
|
32
|
-
# to capture image with all attached cameras
|
47
|
+
# to capture image with all attached cameras simultaneously use:
|
33
48
|
cams.each_index do |index|
|
34
49
|
if index < cams.length - 1
|
35
50
|
fork {cams[index].capture; exit!}
|
data/ext/gphoto4ruby.c
CHANGED
@@ -215,8 +215,7 @@ static VALUE camera_allocate(VALUE klass) {
|
|
215
215
|
GPhoto2Camera *c;
|
216
216
|
c = (GPhoto2Camera*) malloc(sizeof(GPhoto2Camera));
|
217
217
|
c->virtFolder = (char*) malloc(sizeof(char)*100);
|
218
|
-
strcpy(c->virtFolder, "/")
|
219
|
-
// c->path = "/store_00010001";
|
218
|
+
strcpy(c->virtFolder, "/");
|
220
219
|
c->context = gp_context_new();
|
221
220
|
retval = gp_camera_new(&(c->camera));
|
222
221
|
if (retval == GP_OK) {
|
@@ -244,6 +243,8 @@ static VALUE camera_allocate(VALUE klass) {
|
|
244
243
|
* port parameter can be passed to specify which camera is addressed with
|
245
244
|
* object.
|
246
245
|
*
|
246
|
+
* Examples:
|
247
|
+
*
|
247
248
|
* GPhoto2::Camera.new
|
248
249
|
* GPhoto2::Capera.new(GPhoto2::Camera.ports[0])
|
249
250
|
*
|
@@ -296,6 +297,8 @@ static VALUE camera_initialize(int argc, VALUE *argv, VALUE self) {
|
|
296
297
|
* Returns an array of usb port paths with cameras. If only one camera
|
297
298
|
* is connected, returned array is empty.
|
298
299
|
*
|
300
|
+
* Examples:
|
301
|
+
*
|
299
302
|
* # with one camera connected
|
300
303
|
* GPhoto2::Camera.ports #=> []
|
301
304
|
* # with two cameras connected
|
@@ -336,6 +339,8 @@ static VALUE camera_class_ports(VALUE klass) {
|
|
336
339
|
*
|
337
340
|
* Sends command to camera to capture image with current configuration
|
338
341
|
*
|
342
|
+
* Examples:
|
343
|
+
*
|
339
344
|
* c = GPhoto2::Camera.new
|
340
345
|
* c.capture
|
341
346
|
*
|
@@ -359,61 +364,201 @@ static VALUE camera_capture(VALUE self) {
|
|
359
364
|
|
360
365
|
/*
|
361
366
|
* call-seq:
|
362
|
-
*
|
367
|
+
* save(options={}) => camera
|
363
368
|
*
|
364
|
-
*
|
365
|
-
*
|
366
|
-
*
|
369
|
+
* Downloads file from camera to hard drive.
|
370
|
+
* Available options are:
|
371
|
+
* * :file - Name of the file to download from camera. File is expected
|
372
|
+
* to be found in current path. If this option is not specified, last
|
373
|
+
* captured image is downloaded.
|
374
|
+
* * :new_name - New file name to be used when saving file on hard drive.
|
375
|
+
* If this option is not specified, camera file system filename is used.
|
376
|
+
* * :to_folder - Folder path on hard drive to save downloaded image to.
|
377
|
+
* * :type - Type of file to download from camera. Available types are
|
378
|
+
* <b>:normal</b> (default) and <b>:preview</b>
|
379
|
+
*
|
380
|
+
* Examples:
|
367
381
|
*
|
368
382
|
* c = GPhoto2::Camera.new
|
369
|
-
* c.
|
383
|
+
* c.capture.save :type => :preview, => Downloads preview of
|
384
|
+
* :new_name => "PREVIEW.JPG" captured image
|
385
|
+
* c.save :file => "DSC_0144.JPG", => Downloads specified file
|
386
|
+
* :to_folder => "/home/user", to /home/user/xyz.gf.JPG
|
387
|
+
* :new_name => "xyz.gf",
|
370
388
|
*
|
371
389
|
*/
|
372
|
-
static VALUE
|
373
|
-
int retval;
|
390
|
+
static VALUE camera_save(int argc, VALUE *argv, VALUE self) {
|
391
|
+
int retval, i;
|
392
|
+
int newName = -1;
|
393
|
+
CameraFileType fileType = GP_FILE_TYPE_NORMAL;
|
374
394
|
GPhoto2Camera *c;
|
375
|
-
const char *fData;
|
376
|
-
char *fPath;
|
377
|
-
char fName[100];
|
395
|
+
const char *fData, *key, *val;
|
396
|
+
char *fPath, *newNameStr, *pchNew, *pchSrc;
|
397
|
+
char fName[100], cFileName[100], cFolderName[100];
|
378
398
|
unsigned long int fSize;
|
379
399
|
int fd;
|
380
|
-
|
381
|
-
if (argc > 1) {
|
382
|
-
rb_raise(rb_eArgError, "Wrong number of arguments (%d for 0 or 1)", argc);
|
383
|
-
return Qnil;
|
384
|
-
}
|
400
|
+
VALUE arr, hVal;
|
385
401
|
|
386
402
|
Data_Get_Struct(self, GPhoto2Camera, c);
|
403
|
+
|
404
|
+
strcpy(fName, "");
|
405
|
+
strcpy(cFileName, c->path.name);
|
406
|
+
strcpy(cFolderName, c->path.folder);
|
387
407
|
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
408
|
+
switch(argc) {
|
409
|
+
case 0:
|
410
|
+
break;
|
411
|
+
case 1:
|
412
|
+
Check_Type(argv[0], T_HASH);
|
413
|
+
arr = rb_funcall(argv[0], rb_intern("keys"), 0);
|
414
|
+
for (i = 0; i < RARRAY(arr)->len; i++) {
|
415
|
+
switch(TYPE(RARRAY(arr)->ptr[i])) {
|
416
|
+
case T_STRING:
|
417
|
+
key = RSTRING(RARRAY(arr)->ptr[i])->ptr;
|
418
|
+
break;
|
419
|
+
case T_SYMBOL:
|
420
|
+
key = rb_id2name(rb_to_id(RARRAY(arr)->ptr[i]));
|
421
|
+
break;
|
422
|
+
default:
|
423
|
+
rb_raise(rb_eTypeError, "Not valid key type");
|
424
|
+
return Qnil;
|
425
|
+
}
|
426
|
+
if (strcmp(key, "to_folder") == 0) {
|
427
|
+
fPath = RSTRING(rb_hash_aref(argv[0], RARRAY(arr)->ptr[i]))->ptr;
|
428
|
+
if (strlen(fPath) > 0) {
|
429
|
+
if (fPath[strlen(fPath)] == '/') {
|
401
430
|
strcpy(fName, fPath);
|
402
|
-
strcat(fName, c->path.name);
|
403
431
|
} else {
|
404
432
|
strcpy(fName, fPath);
|
405
433
|
strcat(fName, "/");
|
406
|
-
strcat(fName, c->path.name);
|
407
434
|
}
|
408
|
-
}
|
409
|
-
|
435
|
+
}
|
436
|
+
} else if (strcmp(key, "new_name") == 0) {
|
437
|
+
newNameStr = RSTRING(rb_hash_aref(argv[0], RARRAY(arr)->ptr[i]))->ptr;
|
438
|
+
if (strlen(newNameStr) > 0) {
|
439
|
+
newName = 0;
|
440
|
+
}
|
441
|
+
} else if (strcmp(key, "type") == 0) {
|
442
|
+
hVal = rb_hash_aref(argv[0], RARRAY(arr)->ptr[i]);
|
443
|
+
switch(TYPE(hVal)) {
|
444
|
+
case T_STRING:
|
445
|
+
val = RSTRING(hVal)->ptr;
|
446
|
+
break;
|
447
|
+
case T_SYMBOL:
|
448
|
+
val = rb_id2name(rb_to_id(hVal));
|
449
|
+
break;
|
450
|
+
default:
|
451
|
+
rb_raise(rb_eTypeError, "Not valid value type");
|
452
|
+
return Qnil;
|
453
|
+
}
|
454
|
+
if (strcmp(val, "normal") == 0) {
|
455
|
+
fileType = GP_FILE_TYPE_NORMAL;
|
456
|
+
} else if (strcmp(val, "preview") == 0) {
|
457
|
+
fileType = GP_FILE_TYPE_PREVIEW;
|
410
458
|
}
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
return self;
|
459
|
+
} else if (strcmp(key, "file") == 0) {
|
460
|
+
strcpy(cFolderName, c->virtFolder);
|
461
|
+
strcpy(cFileName, RSTRING(rb_hash_aref(argv[0], RARRAY(arr)->ptr[i]))->ptr);
|
415
462
|
}
|
416
463
|
}
|
464
|
+
break;
|
465
|
+
default:
|
466
|
+
rb_raise(rb_eArgError, "Wrong number of arguments (%d for 0 or 1)", argc);
|
467
|
+
return Qnil;
|
468
|
+
}
|
469
|
+
|
470
|
+
retval = gp_filesystem_reset(c->camera->fs);
|
471
|
+
if (retval == GP_OK) {
|
472
|
+
retval = gp_camera_file_get(c->camera, cFolderName, cFileName, fileType, c->file, c->context);
|
473
|
+
if (retval == GP_OK) {
|
474
|
+
retval = gp_file_get_data_and_size(c->file, &fData, &fSize);
|
475
|
+
if (retval == GP_OK) {
|
476
|
+
if (newName == 0) {
|
477
|
+
strcat(fName, newNameStr);
|
478
|
+
pchNew = strrchr(newNameStr, '.');
|
479
|
+
pchSrc = strrchr(cFileName, '.');
|
480
|
+
if (pchNew == NULL) {
|
481
|
+
strcat(fName, pchSrc);
|
482
|
+
} else if (strcmp(pchNew, pchSrc) != 0) {
|
483
|
+
strcat(fName, pchSrc);
|
484
|
+
}
|
485
|
+
} else {
|
486
|
+
strcat(fName, cFileName);
|
487
|
+
}
|
488
|
+
fd = open(fName, O_CREAT | O_WRONLY, 0644);
|
489
|
+
write(fd, fData, fSize);
|
490
|
+
close(fd);
|
491
|
+
return self;
|
492
|
+
}
|
493
|
+
}
|
494
|
+
}
|
495
|
+
rb_raise_gp_result(retval);
|
496
|
+
return Qnil;
|
497
|
+
}
|
498
|
+
|
499
|
+
/*
|
500
|
+
* call-seq:
|
501
|
+
* delete(options={}) => camera
|
502
|
+
*
|
503
|
+
* Deletes file from camera.
|
504
|
+
* Available options are:
|
505
|
+
* * :file - Name of the file to delete from camera. File is expected
|
506
|
+
* to be found in current path. If this option is not specified, last
|
507
|
+
* captured image is deleted.
|
508
|
+
*
|
509
|
+
* Examples:
|
510
|
+
*
|
511
|
+
* c = GPhoto2::Camera.new
|
512
|
+
* c.capture.save.delete
|
513
|
+
* c.delete :file => "DSC_0144.JPG"
|
514
|
+
*
|
515
|
+
*/
|
516
|
+
static VALUE camera_delete(int argc, VALUE *argv, VALUE self) {
|
517
|
+
int retval, i;
|
518
|
+
GPhoto2Camera *c;
|
519
|
+
const char *key;
|
520
|
+
char cFileName[100], cFolderName[100];
|
521
|
+
VALUE arr;
|
522
|
+
|
523
|
+
Data_Get_Struct(self, GPhoto2Camera, c);
|
524
|
+
|
525
|
+
strcpy(cFileName, c->path.name);
|
526
|
+
strcpy(cFolderName, c->path.folder);
|
527
|
+
|
528
|
+
switch(argc) {
|
529
|
+
case 0:
|
530
|
+
break;
|
531
|
+
case 1:
|
532
|
+
Check_Type(argv[0], T_HASH);
|
533
|
+
arr = rb_funcall(argv[0], rb_intern("keys"), 0);
|
534
|
+
for (i = 0; i < RARRAY(arr)->len; i++) {
|
535
|
+
switch(TYPE(RARRAY(arr)->ptr[i])) {
|
536
|
+
case T_STRING:
|
537
|
+
key = RSTRING(RARRAY(arr)->ptr[i])->ptr;
|
538
|
+
break;
|
539
|
+
case T_SYMBOL:
|
540
|
+
key = rb_id2name(rb_to_id(RARRAY(arr)->ptr[i]));
|
541
|
+
break;
|
542
|
+
default:
|
543
|
+
rb_raise(rb_eTypeError, "Not valid key type");
|
544
|
+
return Qnil;
|
545
|
+
}
|
546
|
+
if (strcmp(key, "file") == 0) {
|
547
|
+
strcpy(cFolderName, c->virtFolder);
|
548
|
+
strcpy(cFileName, RSTRING(rb_hash_aref(argv[0], RARRAY(arr)->ptr[i]))->ptr);
|
549
|
+
}
|
550
|
+
}
|
551
|
+
break;
|
552
|
+
default:
|
553
|
+
rb_raise(rb_eArgError, "Wrong number of arguments (%d for 0 or 1)", argc);
|
554
|
+
return Qnil;
|
555
|
+
}
|
556
|
+
|
557
|
+
retval = gp_filesystem_reset(c->camera->fs);
|
558
|
+
if (retval == GP_OK) {
|
559
|
+
retval = gp_camera_file_delete(c->camera, cFolderName, cFileName, c->context);
|
560
|
+
if (retval == GP_OK) {
|
561
|
+
return self;
|
417
562
|
}
|
418
563
|
}
|
419
564
|
rb_raise_gp_result(retval);
|
@@ -426,6 +571,8 @@ static VALUE camera_capture_save(int argc, VALUE *argv, VALUE self) {
|
|
426
571
|
*
|
427
572
|
* Returns an array of adjustable camera configurations.
|
428
573
|
*
|
574
|
+
* Examples:
|
575
|
+
*
|
429
576
|
* c = GPhoto2::Camera.new
|
430
577
|
* # with Nikon DSC D80
|
431
578
|
* c.configs #=> ["capturetarget", "imgquality",
|
@@ -460,6 +607,8 @@ static VALUE camera_get_configs(VALUE self) {
|
|
460
607
|
* (cfg) can be string or symbol and must be in configs method returned array.
|
461
608
|
* When called with directive <b>:all</b> returns an array of allowed values
|
462
609
|
*
|
610
|
+
* Examples:
|
611
|
+
*
|
463
612
|
* c = GPhoto2::Camera.new
|
464
613
|
* # with Nikon DSC D80
|
465
614
|
* c["f-number"] #=> "f/4.5"
|
@@ -546,6 +695,8 @@ static VALUE camera_get_value(int argc, VALUE *argv, VALUE self) {
|
|
546
695
|
*
|
547
696
|
* Sets specified camera configuration to specified value if value is allowed.
|
548
697
|
*
|
698
|
+
* Examples:
|
699
|
+
*
|
549
700
|
* c = GPhoto2::Camera.new
|
550
701
|
* # with Nikon DSC D80
|
551
702
|
* c["f-number"] = "f/4.5" #=> "f/4.5"
|
@@ -604,6 +755,8 @@ static VALUE camera_set_value(VALUE self, VALUE str, VALUE newVal) {
|
|
604
755
|
* Returns current camera path. When image is captured, folder changes to
|
605
756
|
* path where files are saved on camera.
|
606
757
|
*
|
758
|
+
* Examples:
|
759
|
+
*
|
607
760
|
* c = GPhoto2::Camera.new
|
608
761
|
* # with Nikon DSC D80
|
609
762
|
* c.folder #=> "/"
|
@@ -625,6 +778,8 @@ static VALUE camera_folder(VALUE self) {
|
|
625
778
|
*
|
626
779
|
* Returns an array of subfolder names in current camera path.
|
627
780
|
*
|
781
|
+
* Examples:
|
782
|
+
*
|
628
783
|
* c = GPhoto2::Camera.new
|
629
784
|
* # with Nikon DSC D80
|
630
785
|
* c.folder #=> "/"
|
@@ -665,6 +820,8 @@ static VALUE camera_subfolders(VALUE self) {
|
|
665
820
|
*
|
666
821
|
* Returns an array of file names in current camera path.
|
667
822
|
*
|
823
|
+
* Examples:
|
824
|
+
*
|
668
825
|
* c = GPhoto2::Camera.new
|
669
826
|
* # with Nikon DSC D80
|
670
827
|
* c.folder #=> "/"
|
@@ -711,6 +868,8 @@ static VALUE camera_files(VALUE self) {
|
|
711
868
|
*
|
712
869
|
* Changes current camera path one level up.
|
713
870
|
*
|
871
|
+
* Examples:
|
872
|
+
*
|
714
873
|
* c = GPhoto2::Camera.new
|
715
874
|
* # with Nikon DSC D80
|
716
875
|
* c.folder #=> "/"
|
@@ -744,6 +903,8 @@ static VALUE camera_folder_up(VALUE self) {
|
|
744
903
|
* Changes current camera path one level down into subfolder with
|
745
904
|
* specified name.
|
746
905
|
*
|
906
|
+
* Examples:
|
907
|
+
*
|
747
908
|
* c = GPhoto2::Camera.new
|
748
909
|
* # with Nikon DSC D80
|
749
910
|
* c.folder #=> "/"
|
@@ -808,7 +969,8 @@ void Init_gphoto4ruby() {
|
|
808
969
|
rb_define_method(rb_cGPhoto2Camera, "[]", camera_get_value, -1);
|
809
970
|
rb_define_method(rb_cGPhoto2Camera, "[]=", camera_set_value, 2);
|
810
971
|
rb_define_method(rb_cGPhoto2Camera, "capture", camera_capture, 0);
|
811
|
-
rb_define_method(rb_cGPhoto2Camera, "
|
972
|
+
rb_define_method(rb_cGPhoto2Camera, "save", camera_save, -1);
|
973
|
+
rb_define_method(rb_cGPhoto2Camera, "delete", camera_delete, -1);
|
812
974
|
rb_define_method(rb_cGPhoto2Camera, "folder", camera_folder, 0);
|
813
975
|
rb_define_method(rb_cGPhoto2Camera, "subfolders", camera_subfolders, 0);
|
814
976
|
rb_define_method(rb_cGPhoto2Camera, "files", camera_files, 0);
|
data/ext/gphoto4ruby.h
CHANGED
@@ -56,7 +56,11 @@ static VALUE camera_allocate(VALUE klass);
|
|
56
56
|
|
57
57
|
static VALUE camera_initialize(int argc, VALUE *argv, VALUE self);
|
58
58
|
static VALUE camera_class_ports(VALUE klass);
|
59
|
+
|
59
60
|
static VALUE camera_capture(VALUE self);
|
61
|
+
|
62
|
+
static VALUE camera_save(int argc, VALUE *argv, VALUE self);
|
63
|
+
|
60
64
|
static VALUE camera_get_configs(VALUE self);
|
61
65
|
static VALUE camera_get_value(int argc, VALUE *argv, VALUE self);
|
62
66
|
static VALUE camera_set_value(VALUE self, VALUE str, VALUE newVal);
|
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.2
|
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-08-
|
13
|
+
date: 2008-08-19 00:00:00 +04:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|
@@ -21,21 +21,25 @@ executables: []
|
|
21
21
|
extensions:
|
22
22
|
- ext/extconf.rb
|
23
23
|
extra_rdoc_files:
|
24
|
+
- ext/gphoto4ruby.c
|
24
25
|
- README.rdoc
|
25
26
|
- LICENSE
|
26
27
|
- CHANGELOG.rdoc
|
27
|
-
- ext/gphoto4ruby.c
|
28
|
-
files:
|
29
|
-
- ext/gphoto4ruby.c
|
30
|
-
- ext/gphoto4ruby.h
|
31
28
|
- docs/COPYING
|
32
|
-
- docs/
|
33
|
-
|
34
|
-
- LICENSE
|
29
|
+
- docs/COPYING.LESSER
|
30
|
+
files:
|
35
31
|
- CHANGELOG.rdoc
|
32
|
+
- LICENSE
|
36
33
|
- README.rdoc
|
37
34
|
- Rakefile
|
35
|
+
- docs
|
36
|
+
- docs/COPYING
|
37
|
+
- docs/COPYING.LESSER
|
38
38
|
- example.rb
|
39
|
+
- ext
|
40
|
+
- ext/extconf.rb
|
41
|
+
- ext/gphoto4ruby.c
|
42
|
+
- ext/gphoto4ruby.h
|
39
43
|
has_rdoc: true
|
40
44
|
homepage: http://github.com/lonelyelk/gphoto4ruby
|
41
45
|
post_install_message:
|
data/docs/gphoto4ruby_api_ru.txt
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
GPhoto2::Camera
|
2
|
-
Класс для управления камерами, подключенными через usb-порты к компьютеру.
|
3
|
-
Следует написать require "gphoto4ruby"
|
4
|
-
|
5
|
-
GPhoto2::Camera.ports() -> Array
|
6
|
-
Метод класса. Возвращает массив, содержащий пути (path) usb-портов, к которым подключены камеры, если камер более одной.
|
7
|
-
|
8
|
-
GPhoto2::Camera.new() -> GPhoto2::Camera
|
9
|
-
Конструктор класса. Создает объект для управления первой авто-определенной камерой (обычно это камера, которая была подключена последней).
|
10
|
-
|
11
|
-
GPhoto2::Camera.new(port) -> GPhoto2::Camera
|
12
|
-
Конструктор класса. Создает объект для управления камерой, подключенной к заданному порту. Актуально при подключении более одной камеры.
|
13
|
-
port (String) -- путь (path) порта с камерой. Следует использовать элементы массива, возвращаемого методом класса GPhoto2::Camera.ports
|
14
|
-
Пример:
|
15
|
-
cams = Array.new
|
16
|
-
GPhoto2::Camera.ports.each do |port|
|
17
|
-
cams.push(GPhoto2::Camera.new(port))
|
18
|
-
end
|
19
|
-
|
20
|
-
configs() -> Array
|
21
|
-
Метод объекта. Возвращает массив с именами (name) доступных для изменения настроек камеры.
|
22
|
-
|
23
|
-
[config_name] -> String или Float
|
24
|
-
Метод объекта. Возвращает значение настройки с именем config_name.
|
25
|
-
config_name (String или Symbol) -- имя (name) настройки камеры. Следует использовать элементы массива, возвращаемые методом configs().
|
26
|
-
Пример:
|
27
|
-
cam[:focallength] -> 10.5
|
28
|
-
cam["f-number"] -> "f/4"
|
29
|
-
cam[cam.configs[0]]
|
30
|
-
|
31
|
-
[config_name, directive] -> Array
|
32
|
-
Метод объекта. Возвращает информацию о настройке в зависимости от директивы directive.
|
33
|
-
config_name (String или Symbol) -- имя (name) настройки камеры. Следует использовать элементы массива, возвращаемые методом configs().
|
34
|
-
directive (Symbol) -- указывает на информацию, которую следует выдать
|
35
|
-
:all -- возвращается массив с допустимыми значениями настройки.
|
36
|
-
Пример:
|
37
|
-
cam["exptime", :all] -> ["0.002", "0.003", ...]
|
38
|
-
|
39
|
-
[config_name] = value -> String или Float
|
40
|
-
Метод объекта. Изменяет значение указанной настройки на новое.
|
41
|
-
config_name (String или Symbol) -- имя (name) настройки камеры. Следует использовать элементы массива, возвращаемые методом configs().
|
42
|
-
value (String или Float) -- новое значение настройки. Следует использовать элементы массива, возвращаемые методом [] с директивой :all.
|
43
|
-
Пример:
|
44
|
-
cam[:exptime] = "0.010" -> "0.010"
|
45
|
-
cam["f-number"] = cam["f-number", :all][3]
|
46
|
-
|
47
|
-
capture() -> GPhoto2::Camera
|
48
|
-
Метод объекта. Посылает сигнал на камеру для съемки изображения.
|
49
|
-
|