-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathget_object.rb
More file actions
33 lines (27 loc) · 1.25 KB
/
get_object.rb
File metadata and controls
33 lines (27 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
require './lib/theta_initiator.rb'
ThetaInitiator.open do |initiator|
# オブジェクトの列挙
# 1つ目のパラメータはストレージID. 0xFFFFFFFFのときは全てのストレージから列挙
# 2つめのパラメータはフォーマットID. 0xFFFFFFFFの時は全てのフォーマット.
# 3つめのパラメータはオプション.場合によって異なるが、今回の全列挙の場合は0.
response = initiator.operation(:GetObjectHandles, [0xFFFFFFFF, 0xFFFFFFFF, 0])
offset = 0
@object_handles, offset = PTP_parse_long_array(offset, response[:data])
p @object_handles #オブジェクトハンドルのダンプ
print "GetThumb...\n"
# 最後に撮ったサムネイルの取得
# 一番目のパラメータにObjectHandleを格納
response = initiator.operation(:GetThumb, [@object_handles[-1]])
File.open("./theta_thumb.jpg", "wb") do |f|
f.write(response[:data].pack("C*"))
print "Saved!\n"
end
print "GetObject...\n"
# 最後に撮った写真の取得
# 一番目のパラメータにObjectHandleを格納
response = initiator.operation(:GetObject, [@object_handles[-1]])
File.open("./theta_pic.jpg", "wb") do |f|
f.write(response[:data].pack("C*"))
print "Saved!\n"
end
end