True.
This commit is contained in:
parent
417538d768
commit
f2a2534c34
35
adapter.py
35
adapter.py
|
@ -10,24 +10,23 @@ from runner import find_homography, warp_board
|
||||||
# Load base64 encoded image from stdin
|
# Load base64 encoded image from stdin
|
||||||
from tensor_classifier import predict_board
|
from tensor_classifier import predict_board
|
||||||
|
|
||||||
stdin = sys.stdin.readline()
|
while True:
|
||||||
stdin_decoded = base64.b64decode(stdin)
|
stdin = sys.stdin.readline()
|
||||||
img_array = np.frombuffer(stdin_decoded, dtype=np.uint8)
|
stdin_decoded = base64.b64decode(stdin)
|
||||||
camera_img = cv2.imdecode(img_array, flags=cv2.COLOR_BGR2RGB)
|
img_array = np.frombuffer(stdin_decoded, dtype=np.uint8)
|
||||||
camera_img = cv2.cvtColor(camera_img, cv2.COLOR_BGR2RGB)
|
camera_img = cv2.imdecode(img_array, flags=cv2.COLOR_BGR2RGB)
|
||||||
|
camera_img = cv2.cvtColor(camera_img, cv2.COLOR_BGR2RGB)
|
||||||
|
|
||||||
|
# def do_everything:
|
||||||
|
homography = find_homography(camera_img)
|
||||||
|
warped_board = warp_board(camera_img, homography)
|
||||||
|
occupied_squares = find_occupied_squares(warped_board)
|
||||||
|
board = predict_board(occupied_squares)
|
||||||
|
|
||||||
# def do_everything:
|
# Finally, output to stdout for unity to read
|
||||||
homography = find_homography(camera_img)
|
result = {
|
||||||
warped_board = warp_board(camera_img, homography)
|
"homography": homography.tolist(),
|
||||||
occupied_squares = find_occupied_squares(warped_board)
|
"board": board.to_array,
|
||||||
board = predict_board(occupied_squares)
|
}
|
||||||
|
|
||||||
|
print(json.dumps(result))
|
||||||
# Finally, output to stdout for unity to read
|
|
||||||
result = {
|
|
||||||
"homography": homography.tolist(),
|
|
||||||
"board": board.to_array,
|
|
||||||
}
|
|
||||||
|
|
||||||
print(json.dumps(result))
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user