Visual Servoing Platform version 3.7.0
Loading...
Searching...
No Matches
test_core.py
2 from visp.core import PixelMeterConversion, CameraParameters
3 import numpy as np
4
5 h, w = 240, 320
6 cam = CameraParameters(px=600, py=600, u0=320, v0=240)
7
8 vs, us = np.meshgrid(range(h), range(w), indexing='ij') # vs and us are 2D arrays
9
10 xs, ys = PixelMeterConversion.convertPoints(cam, us, vs)
11 # xs and ys have the same shape as us and vs
12 assert xs.shape == (h, w) and ys.shape == (h, w)
13
14 # Converting a numpy array to normalized coords has the same effect as calling on a single image point
15 for v in range(h):
16 for u in range(w):
17 x, y = PixelMeterConversion.convertPoint(cam, u, v)
18
19 assert x == xs[v, u] and y == ys[v, u]
20
22 from visp.core import MeterPixelConversion, CameraParameters
23 import numpy as np
24
25 h, w = 240, 320
26 cam = CameraParameters(px=600, py=600, u0=320, v0=240)
27
28 # We use xs and ys as pixel coordinates here, but it's not really true (it's just more convenient)
29 ys, xs = np.meshgrid(range(h), range(w), indexing='ij') # vs and us are 2D arrays
30
31 us, vs = MeterPixelConversion.convertPoints(cam, xs, ys)
32 # xs and ys have the same shape as us and vs
33 assert us.shape == (h, w) and vs.shape == (h, w)
34
35 # Converting a numpy array to normalized coords has the same effect as calling on a single image point
36 for y in range(h):
37 for x in range(w):
38 u, v = MeterPixelConversion.convertPoint(cam, x, y)
39 assert u == us[y, x] and v == vs[y, x]
test_pixel_meter_convert_points()
Definition test_core.py:1
test_meter_pixel_convert_points()
Definition test_core.py:21