Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- import numpy as np
- import cv2
- URL = 'https://api.arstand-lab.ru'
- token = 'Token 581314b5dc6db4dd928dc249bf390affbec4df75'
- HEADERS = {'Authorization': token,
- 'Content-Type': 'application/json'}
- def get_markers():
- res = requests.get(f'{URL}/api/0/marker/get_markers/', headers=HEADERS)
- if res.ok:
- with open('file.npz', 'wb') as f:
- f.write(res.content)
- return True
- else:
- return False
- def post_rotation():
- global Points
- content = {'markers': str(Points)}
- res = requests.post(f'{URL}/api/0/marker/check_markers/rotation/',
- headers=HEADERS,
- json=content)
- print(res.content)
- if res.ok:
- return True
- else:
- return False
- if __name__ == '__main__':
- print('GET successful: ', get_markers())
- Points = list()
- a = np.load("file.npz")
- for t in range(len(a['markers'])):
- im_bw = cv2.medianBlur(a['markers'][t], 5)
- rows = im_bw.shape[0]
- circles = cv2.HoughCircles(im_bw, cv2.HOUGH_GRADIENT, 1, rows / 8,
- param1=100, param2=30,
- minRadius=1, maxRadius=40)
- if circles is not None:
- circles = np.uint16(np.around(circles))
- for i in circles[0, :]:
- center = (i[0], i[1])
- # circle center
- cv2.circle(im_bw, center, 1, (0, 100, 100), 3)
- # circle outline
- radius = i[2]
- cv2.circle(im_bw, center, radius, (255, 0, 255), 3)
- if center[0] > 150 and center[1] > 150:
- r = 180
- elif center[0] < 150 and center[1] > 150:
- r = 270
- elif center[0] < 150 and center[1] < 150:
- r = 0
- else:
- r = 90
- Points.append(list((a['coords'][t][0], a['coords'][t][1], r)))
- content = {'markers': str(Points)}
- res = requests.post(f'{URL}/api/0/marker/check_markers/rotation/',
- headers=HEADERS,
- json=content)
- print(Points)
- print(res.content)
- if res.ok:
- print(True)
- else:
- print(False)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement