forked from behnam/python-lfp-reader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlfp_picture_info.py
executable file
·88 lines (71 loc) · 2.74 KB
/
lfp_picture_info.py
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/env python
#
# lfp-reader
# LFP (Light Field Photography) File Reader.
#
# http://behnam.github.com/python-lfp-reader/
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Copyright (C) 2012 Behnam Esfahbod
"""Show information about LFP Picture file
"""
import os.path
import sys
from lfp_reader import LfpPictureFile
def usage(errcode=0, of=sys.stderr):
print ("Usage: %s picture-file.lfp" %
os.path.basename(sys.argv[0]))
sys.exit(errcode)
if __name__=='__main__':
if len(sys.argv) < 2 or len(sys.argv) > 2:
usage()
lfp_path = sys.argv[1]
try:
lfp = LfpPictureFile(lfp_path).load()
print
print "Frame:"
if lfp.frame:
print "\t%-20s\t%12d" % ("metadata:", lfp.frame.metadata.size)
print "\t%-20s\t%12d" % ("image:", lfp.frame.image.size)
print "\t%-20s\t%12d" % ("private_metadata:", lfp.frame.private_metadata.size)
else:
print "\tNone"
print
print "Refocus-Stack:"
if lfp.refocus_stack:
print "\t%-20s\t%12d" % ("images:", len(lfp.refocus_stack.images))
print "\t%-20s\t%12s" % ("depth_lut:", "%dx%d" %
(lfp.refocus_stack.depth_lut.width, lfp.refocus_stack.depth_lut.height))
print "\t%-20s\t%12d" % ("default_lambda:", lfp.refocus_stack.default_lambda)
print "\t%-20s\t%12d" % ("default_width:", lfp.refocus_stack.default_width)
print "\t%-20s\t%12d" % ("default_height:", lfp.refocus_stack.default_height)
print
print "\tAvailable Focus Depth:"
print "\t\t",
for image in lfp.refocus_stack.images:
print "%5.2f" % image.lambda_,
print
print
print "\tDepth Table:"
for i in xrange(lfp.refocus_stack.depth_lut.width):
print "\t\t",
for j in xrange(lfp.refocus_stack.depth_lut.height):
print "%5.2f" % lfp.refocus_stack.depth_lut.table[j][i],
print
else:
print "\tNone"
except Exception as err:
print >>sys.stderr, "Error:", err
exit(1)