-
Notifications
You must be signed in to change notification settings - Fork 288
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
266 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,6 @@ stubs/visp | |
stubs/build | ||
*.eggs | ||
doc/_build | ||
doc/_autosummary | ||
doc/_autosummary/* | ||
doc/generated | ||
doc/api.rst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,4 +13,3 @@ Welcome to the ViSP Python binding documentation! | |
|
||
todos.rst | ||
conversions.rst | ||
api.rst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
def test_pixel_meter_convert_points(): | ||
from visp.core import PixelMeterConversion, CameraParameters | ||
import numpy as np | ||
|
||
h, w = 240, 320 | ||
cam = CameraParameters(px=600, py=600, u0=320, v0=240) | ||
|
||
vs, us = np.meshgrid(range(h), range(w), indexing='ij') # vs and us are 2D arrays | ||
|
||
xs, ys = PixelMeterConversion.convertPoints(cam, us, vs) | ||
# xs and ys have the same shape as us and vs | ||
assert xs.shape == (h, w) and ys.shape == (h, w) | ||
|
||
# Converting a numpy array to normalized coords has the same effect as calling on a single image point | ||
for v in range(h): | ||
for u in range(w): | ||
x, y = PixelMeterConversion.convertPoint(cam, u, v) | ||
|
||
assert x == xs[v, u] and y == ys[v, u] | ||
|
||
def test_meter_pixel_convert_points(): | ||
from visp.core import MeterPixelConversion, CameraParameters | ||
import numpy as np | ||
|
||
h, w = 240, 320 | ||
cam = CameraParameters(px=600, py=600, u0=320, v0=240) | ||
|
||
# We use xs and ys as pixel coordinates here, but it's not really true (it's just more convenient) | ||
ys, xs = np.meshgrid(range(h), range(w), indexing='ij') # vs and us are 2D arrays | ||
|
||
us, vs = MeterPixelConversion.convertPoints(cam, xs, ys) | ||
# xs and ys have the same shape as us and vs | ||
assert us.shape == (h, w) and vs.shape == (h, w) | ||
|
||
# Converting a numpy array to normalized coords has the same effect as calling on a single image point | ||
for y in range(h): | ||
for x in range(w): | ||
u, v = MeterPixelConversion.convertPoint(cam, x, y) | ||
assert u == us[y, x] and v == vs[y, x] |