-
Notifications
You must be signed in to change notification settings - Fork 23
/
TestServiceSample.py
91 lines (74 loc) · 2.43 KB
/
TestServiceSample.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
88
89
90
91
import requests
import base64
import json
import os
import time
import cv2
import multiprocessing
from configuration import *
from Interface import meterReader
def startServer():
os.system("python FlaskService.py")
def startClient(results):
images = os.listdir("info/20190410/IMAGES/Pic_2")
for im in images:
path = "info/20190410/IMAGES/Pic_2/" + im
data = json.dumps({
"path": path,
"imageID": im.split('.')[0] + "_1"
})
print(path, im)
print(data)
r = requests.post("http://127.0.0.1:5000/", data=data.encode("utf-8"))
print(r.text)
receive = json.loads(r.text)
print(im, receive)
results.append(True)
def codecov(imgPath):
images = os.listdir(imgPath)
config = os.listdir(configPath)
for im in images:
image = cv2.imread(imgPath + "/" + im)
print(im)
pos = im.split(".")[0].split("-")
cfg = im.split(".")[0]+"_1"
# for i in range(1, 6):
# cfg = pos[0] + "-" + pos[1] + "_" + str(i)
# if cfg + ".json" in config:
# receive2 = meterReader(image, [cfg])
# print(cfg, receive2)
receive2 = meterReader(image, [cfg])
print(cfg, receive2)
print("codecov done")
def testVideo():
video_path = "info/20190128/IMAGES/video_"
for file in os.listdir(video_path):
if file.startswith(".DS"):
continue
video = cv2.VideoCapture(os.path.join(video_path, file))
result = meterReader(video, [file[:-4] + "_1"])
print(file, result)
print("codecov done")
if __name__ == "__main__":
# Service Test
# serverProcess = multiprocessing.Process(target=startServer)
# results = multiprocessing.Manager().list()
# clientProcess = multiprocessing.Process(target=startClient, args=(results,))
# serverProcess.start()
# time.sleep(30)
# clientProcess.start()
# clientProcess.join()
# serverProcess.terminate()
# Single Test
# testReadyStatus()
# codecov("info/20190128/IMAGES/image")
# codecov("info/20190128/IMAGES/Pic_0225")
# codecov("info/20190128/IMAGES/Pic_0226")
# codecov("info/20190128/IMAGES/video_")
# codecov("info/20190410/IMAGES/Pic")
# codecov("info/20190410/IMAGES/Pic_2")
codecov("info/20190515/IMAGES/image")
# codecov("info/20190514/image/")
#
# codecov("info/20190416/IMAGES/image")
# testVideo()