-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvision_test.py
More file actions
31 lines (23 loc) · 842 Bytes
/
vision_test.py
File metadata and controls
31 lines (23 loc) · 842 Bytes
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
import naoqi
from naoqi import ALProxy
import numpy
import math_tools
import matplotlib.pyplot as plt
def main():
vision_proxy = ALProxy("ALVideoDevice", "nao.ini.rub.de", 9559)
gvm_name = "nao vision"
gvm_name = vision_proxy.subscribe(gvm_name, 0, 12, 15)
# switch off auto white balance
vision_proxy.setParam(12, 0)
naoimage = vision_proxy.getImageRemote(gvm_name)
hsv_image = numpy.fromstring(naoimage[6], dtype=numpy.uint8)
hue = hsv_image[::3].reshape(120,160)
print(hue.shape)
sizes = [30,40,15]
hue = math_tools.linear_interpolation_2d_custom(hue, [sizes[0], sizes[1]])
hue = numpy.round(hue * ((sizes[2] - 1)/255.)).astype(numpy.int)
plt.imshow(hue, vmin=0, vmax=14)
plt.show()
gvm_name = vision_proxy.unsubscribe(gvm_name)
if __name__ == "__main__":
main()