OSDN Git Service

setting
[spec-recorder/spec-recorder.git] / make_csv.py
1 # -*- coding: utf-8 -*-
2 from PIL import Image
3 #import datetime
4 import sys
5 import libhro
6 import time
7 import csv
8 import libhro
9 import ConfigParser
10 #global img
11
12 argvs = sys.argv
13 #if len(argvs) != 2:
14 #       print "Error this program require two argment"
15 #       exit()
16         
17 conf = ConfigParser.SafeConfigParser()
18 conf.read("./sr.conf")
19 echo_threshold = int(conf.get("analyze", "echo_threshold"))
20 unite_echo_threshold = int(conf.get("analyze", "unite_echo_threshold"))
21 compared_with_pixels = conf.get("analyze", "compared_with_pixels")
22
23 filetime = ""
24 filename = ""
25 filetime = argvs[2]
26 #filetime = "1306140505"
27 #argvs = ["-a", filetime]
28 #filename = filetime + ".png"
29 #pos = (2500,35)
30 #open_image(filename)
31 #img = Image.open(filename)
32 strength_list = []
33 analyze_return = ()
34 #8,16,25,33,41,49,58,66,74,82,90,99,107,115,123,132,140,148,156,165,173,181,189,197,206,214,222,230,239,247
35 """
36 def make_csv_a(filetime, strength_list, echo_threshold, unite_echo_threshold):
37         filetime = argvs[2]
38         libhro.read_csv(strength_list, filetime)
39         analyze_return = libhro.analyze(strength_list, echo_threshold, unite_echo_threshold)
40         writetxt = open("./echo/" + filetime + '.echo', 'w')
41         writetxt.write(str(analyze_return)[1:-1])
42         writetxt.close() 
43
44 def make_csv_c(filetime, strength_list, echo_threshold, unite_echo_threshold):
45         filename = argvs[2] + ".png"
46         filetime = argvs[2]
47         img = Image.open("./monoPNG/" + filename[:])
48         strength_list = libhro.make_list(img)
49         libhro.write_csv(strength_list, filetime)
50         
51 def make_csv_ac(filetime, strength_list, echo_threshold, unite_echo_threshold):
52         filetime = argvs[2]
53         filename = argvs[2] + ".png"
54         img = Image.open("./monoPNG/" + filename[:])
55         strength_list = libhro.make_list(img)
56         libhro.write_csv(strength_list, filetime)
57         analyze_return = libhro.analyze(strength_list, echo_threshold, unite_echo_threshold)
58         writetxt = open("./echo/" + filetime + '.echo', 'w')
59         writetxt.write(str(analyze_return)[1:-1])
60         writetxt.close() 
61 """
62
63 if argvs[1] == "-a":#エコーカウントのみ
64         libhro.make_csv("a", filetime, echo_threshold, unite_echo_threshold, compared_with_pixels)
65 """
66         filetime = argvs[2]
67         libhro.read_csv(strength_list, filetime)
68         analyze_return = libhro.analyze(strength_list, echo_threshold, unite_echo_threshold)
69         writetxt = open("./echo/" + filetime + '.echo', 'w')
70         writetxt.write(str(analyze_return)[1:-1])
71         writetxt.close() 
72 """     
73 if argvs[1] == "-c":#CSVファイル作成のみ
74         libhro.make_csv("c", filetime, echo_threshold, unite_echo_threshold)
75         """
76         filename = argvs[2] + ".png"
77         filetime = argvs[2]
78         img = Image.open("./monoPNG/" + filename[:])
79         strength_list = libhro.make_list(img)
80         libhro.write_csv(strength_list, filetime)
81         """
82         
83 if argvs[1] == "-ac":#両方
84         libhro.make_csv("ac", filetime, echo_threshold, unite_echo_threshold, compared_with_pixels)
85         """
86         filetime = argvs[2]
87         filename = argvs[2] + ".png"
88         img = Image.open("./monoPNG/" + filename[:])
89         strength_list = libhro.make_list(img)
90         libhro.write_csv(strength_list, filetime)
91         analyze_return = libhro.analyze(strength_list, echo_threshold, unite_echo_threshold)
92         writetxt = open("./echo/" + filetime + '.echo', 'w')
93         writetxt.write(str(analyze_return)[1:-1])
94         writetxt.close() 
95         """
96         
97 #strength_list = make_list()
98 #read_csv(strength_list, filetime)
99 #print strength_list
100 #print len(strength_list)
101 #write_csv(strength_list, filetime)
102 #analyze_return = analyze(strength_list)
103 exit()