canonball 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.
- checksums.yaml +7 -0
- data/.DS_Store +0 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +49 -0
- data/Rakefile +1 -0
- data/canonball.gemspec +27 -0
- data/lib/.DS_Store +0 -0
- data/lib/canonball/canonball.so +0 -0
- data/lib/canonball/version.rb +3 -0
- data/lib/canonball.rb +9 -0
- data/spec/.DS_Store +0 -0
- data/spec/lib/.DS_Store +0 -0
- data/spec/lib/canonball/.DS_Store +0 -0
- data/spec/lib/canonball_spec.rb +7 -0
- data/spec/spec_helper.rb +1 -0
- data/src/.DS_Store +0 -0
- data/src/Makefile +2 -0
- data/src/canonball.cpp +106 -0
- data/src/canonball.so +0 -0
- data/src/headers/EDSDK.h +1364 -0
- data/src/headers/EDSDKErrors.h +207 -0
- data/src/headers/EDSDKTypes.h +1342 -0
- data/src/headers/canonball.h +20 -0
- metadata +129 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a3f7b016fb7b602bd28796ab35c0c092d0786c6d
|
4
|
+
data.tar.gz: 509500ebf2faff043edeccfc93c7faca02441d80
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: edbf7f044af6b08f160150c89fc244e6b65ba713fbe138620cc0d2ad28f9536cf49559b9fab91323db9b6c7952684a005c0728bff963389a9976cba5d11a3d46
|
7
|
+
data.tar.gz: 47dff232ae119f171609e190f59893c64e371669a7237d8ab3dfaa8db8a22830abaab7224290dfa7aac303f86d1af4c3d23f73f84d33cafbd6870e1ab526d2e1
|
data/.DS_Store
ADDED
Binary file
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Jon Christopher
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Canonball
|
2
|
+
|
3
|
+
Magic sauce ruby wrapper for canon EOS EDSDK. This is a wrapper for a C library that take photos and download and delete them from the camera.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'canonball'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install canonball
|
18
|
+
|
19
|
+
## Applying for SDK access
|
20
|
+
Before you can use this library you need to obtain the EDSDK native library from Canon. You can do so via their developers program:
|
21
|
+
|
22
|
+
- [Canon Europe](http://www.didp.canon-europa.com/)
|
23
|
+
- [Canon USA](http://www.usa.canon.com/cusa/consumer/standard_display/sdk_homepage)
|
24
|
+
- [Canon Asia](http://www.canon-asia.com/personal/web/developerresource)
|
25
|
+
- [Canon Oceania](https://www.canon.co.nz/en-NZ/Personal/Support-Help/Support-News/Canon-SDK)
|
26
|
+
|
27
|
+
Once you were granted access - this may take a few days - download the latest version of their library and follow the usage instructions.
|
28
|
+
|
29
|
+
This currently only works with OSX. You will need drop "EDSDK.framework" into "/System/Library/Frameworks/".
|
30
|
+
|
31
|
+
## Usage
|
32
|
+
|
33
|
+
Take a photo:
|
34
|
+
|
35
|
+
camera_index = 0
|
36
|
+
Canonball.take_picture(camera_index)
|
37
|
+
|
38
|
+
Download photo(s):
|
39
|
+
|
40
|
+
camera_index = 0
|
41
|
+
Canonball.download_files(camera_index,"./photo_folder/")
|
42
|
+
|
43
|
+
## Contributing
|
44
|
+
|
45
|
+
1. Fork it ( http://github.com<my-github-username>/canonball/fork )
|
46
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
47
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
48
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
49
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/canonball.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'canonball/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "canonball"
|
8
|
+
spec.version = Canonball::VERSION
|
9
|
+
spec.authors = ["Jon Christopher"]
|
10
|
+
spec.email = ["joncirca@icloud.com"]
|
11
|
+
spec.summary = %q{canon camera sdk.}
|
12
|
+
spec.description = %q{Magic sauce ruby wrapper for canon EOS EDSDK.}
|
13
|
+
spec.homepage = "https://github.com/hooty/canonball"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.5'
|
22
|
+
spec.add_development_dependency 'rake', '~> 10.3.2'
|
23
|
+
spec.add_development_dependency 'rspec', '~> 3.1.0'
|
24
|
+
|
25
|
+
spec.add_dependency 'ffi', '~> 1.9.4'
|
26
|
+
|
27
|
+
end
|
data/lib/.DS_Store
ADDED
Binary file
|
Binary file
|
data/lib/canonball.rb
ADDED
data/spec/.DS_Store
ADDED
Binary file
|
data/spec/lib/.DS_Store
ADDED
Binary file
|
Binary file
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "canonball"
|
data/src/.DS_Store
ADDED
Binary file
|
data/src/Makefile
ADDED
data/src/canonball.cpp
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
//
|
2
|
+
// canonball.cpp
|
3
|
+
//
|
4
|
+
// Created by Jon Christopher on 9/23/14.
|
5
|
+
// Copyright (c) 2014 hoot. All rights reserved.
|
6
|
+
//
|
7
|
+
|
8
|
+
#include "headers/canonball.h"
|
9
|
+
|
10
|
+
EdsError _error = EDS_ERR_OK;
|
11
|
+
EdsCameraRef _camera = NULL;
|
12
|
+
EdsCameraListRef _camera_list = NULL;
|
13
|
+
|
14
|
+
void inialize_sdk() {
|
15
|
+
_error = EdsInitializeSDK();
|
16
|
+
if (_error != EDS_ERR_OK) printf("No framework detected\n");
|
17
|
+
}
|
18
|
+
|
19
|
+
void terminate_sdk() {
|
20
|
+
_error = EdsTerminateSDK();
|
21
|
+
if (_error != EDS_ERR_OK) printf("Failed terminating framework\n");
|
22
|
+
}
|
23
|
+
|
24
|
+
void open_camera_session(int camera_index) {
|
25
|
+
if (_error == EDS_ERR_OK) _error = EdsGetCameraList(&_camera_list);
|
26
|
+
if (_error == EDS_ERR_OK) _error = EdsGetChildAtIndex(_camera_list, camera_index, &_camera);
|
27
|
+
if (_error == EDS_ERR_OK) _error = EdsOpenSession(_camera);
|
28
|
+
if (_error != EDS_ERR_OK) printf("No camera detected\n");
|
29
|
+
}
|
30
|
+
|
31
|
+
void close_camera_session() {
|
32
|
+
if (_error == EDS_ERR_OK) _error = EdsCloseSession(_camera);
|
33
|
+
if (_error == EDS_ERR_OK) _error = EdsRelease(_camera);
|
34
|
+
if (_error == EDS_ERR_OK) _error = EdsRelease(_camera_list);
|
35
|
+
if (_error != EDS_ERR_OK && _camera != NULL) printf("Error releasing camera\n");
|
36
|
+
}
|
37
|
+
|
38
|
+
int take_picture(int camera_index) {
|
39
|
+
inialize_sdk();
|
40
|
+
open_camera_session(camera_index);
|
41
|
+
EdsSendCommand(_camera , kEdsCameraCommand_TakePicture, 0);
|
42
|
+
close_camera_session();
|
43
|
+
terminate_sdk();
|
44
|
+
return _error;
|
45
|
+
}
|
46
|
+
|
47
|
+
EdsDirectoryItemRef DCIM_folder() {
|
48
|
+
EdsUInt32 folder_count = 0;
|
49
|
+
EdsVolumeRef sd_card = NULL;
|
50
|
+
EdsDirectoryItemRef dcim_folder = NULL;
|
51
|
+
EdsDirectoryItemInfo folder_info;
|
52
|
+
if (_error == EDS_ERR_OK) _error = EdsGetChildAtIndex( _camera, 0, &sd_card);
|
53
|
+
if (_error == EDS_ERR_OK) _error = EdsGetChildCount( sd_card, &folder_count);
|
54
|
+
for(int i = 0; i < folder_count; i++){
|
55
|
+
if (_error == EDS_ERR_OK) _error = EdsGetChildAtIndex( sd_card, i, &dcim_folder ) ;
|
56
|
+
if (_error == EDS_ERR_OK) _error = EdsGetDirectoryItemInfo( dcim_folder, &folder_info );
|
57
|
+
std::string folderName = folder_info.szFileName;
|
58
|
+
if( folderName == "DCIM" ) break;
|
59
|
+
if (_error == EDS_ERR_OK) _error = EdsRelease(dcim_folder);
|
60
|
+
}
|
61
|
+
if (_error == EDS_ERR_OK) _error = EdsRelease(sd_card);
|
62
|
+
return dcim_folder;
|
63
|
+
}
|
64
|
+
|
65
|
+
void download_file(EdsDirectoryItemRef file_pointer, std::string folder){
|
66
|
+
EdsStreamRef stream = NULL;
|
67
|
+
EdsDirectoryItemInfo file;
|
68
|
+
if (_error == EDS_ERR_OK) _error = EdsGetDirectoryItemInfo(file_pointer, &file);
|
69
|
+
if (_error == EDS_ERR_OK) _error = EdsCreateFileStream( ( folder + file.szFileName ).c_str(), kEdsFileCreateDisposition_CreateAlways, kEdsAccess_ReadWrite, &stream);
|
70
|
+
if (_error == EDS_ERR_OK) _error = EdsDownload( file_pointer, file.size, stream);
|
71
|
+
if (_error == EDS_ERR_OK) _error = EdsDownloadComplete(file_pointer);
|
72
|
+
if (_error == EDS_ERR_OK) _error = EdsDeleteDirectoryItem(file_pointer);
|
73
|
+
if (_error == EDS_ERR_OK) _error = EdsRelease(stream);
|
74
|
+
if (_error != EDS_ERR_OK) printf("Error downloading file\n");
|
75
|
+
}
|
76
|
+
|
77
|
+
int download_files(int camera_index, const char* folder) {
|
78
|
+
inialize_sdk();
|
79
|
+
open_camera_session(camera_index);
|
80
|
+
|
81
|
+
EdsDirectoryItemRef images_folder = NULL;
|
82
|
+
EdsDirectoryItemRef file = NULL;
|
83
|
+
EdsUInt32 sub_folder_count = 0;
|
84
|
+
EdsDirectoryItemRef dcim_folder = DCIM_folder();
|
85
|
+
|
86
|
+
EdsGetChildCount(dcim_folder, &sub_folder_count);
|
87
|
+
int lastIndex = sub_folder_count-1;
|
88
|
+
EdsDirectoryItemInfo dirItemInfo_Sub;
|
89
|
+
_error = EdsGetChildAtIndex(dcim_folder, lastIndex, &images_folder ) ;
|
90
|
+
_error = EdsGetDirectoryItemInfo( images_folder, &dirItemInfo_Sub);
|
91
|
+
EdsUInt32 jpgCount = 0;
|
92
|
+
_error = EdsGetChildCount(images_folder, &jpgCount );
|
93
|
+
for(int i = 0; i < jpgCount; i++){
|
94
|
+
EdsGetChildAtIndex(images_folder, i, &file ) ;
|
95
|
+
download_file(file , folder);
|
96
|
+
}
|
97
|
+
|
98
|
+
EdsRelease(dcim_folder);
|
99
|
+
EdsRelease(images_folder);
|
100
|
+
EdsRelease(file);
|
101
|
+
|
102
|
+
close_camera_session();
|
103
|
+
terminate_sdk();
|
104
|
+
|
105
|
+
return _error;
|
106
|
+
}
|
data/src/canonball.so
ADDED
Binary file
|