-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
31 lines (28 loc) · 1006 Bytes
/
test.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
import cv2
import sys
import json
import util
import requests
import numpy
def main():
if len(sys.argv) < 3:
raise Exception("Inputs:\n\tparameter 1: Test image to use for processing."
"\n\tparameter 2: file for image metrics json.")
input_image = sys.argv[1]
print("Image: %s" % input_image)
metrics_file = sys.argv[2]
metrics_file = open(metrics_file, "r")
training_metrics = json.loads(metrics_file.read())
puzzle_image = None
media_url = input_image
http_headers = {'content-type': 'image/jpg'}
response = requests.get(media_url, headers=http_headers)
if response.status_code == 200:
results = response.content
image_bytearray = numpy.asarray(bytearray(results), dtype="uint8")
image = cv2.imdecode(image_bytearray, cv2.IMREAD_GRAYSCALE)
# util.show_image(image)
matrix = util.extract_matrix_from_image(image, training_metrics)
print(matrix)
if __name__ == '__main__':
main()