Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ros2 camera calibration, tests are strangely failing #376

Closed
wants to merge 11 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions camera_calibration/CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Forthcoming
-----------
* Initial ROS2 commit.
* Contributors: Michael Carroll

1.12.23 (2018-05-10)
--------------------
* camera_checker: Ensure cols + rows are in correct order (`#319 <https://github.com/ros-perception/image_pipeline/issues/319>`_)
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class CalibrationException(Exception):
pass

# TODO: Make pattern per-board?
class ChessboardInfo(object):
class ChessboardInfo():
def __init__(self, n_cols = 0, n_rows = 0, dim = 0.0):
self.n_cols = n_cols
self.n_rows = n_rows
Expand Down Expand Up @@ -214,7 +214,7 @@ def _get_circles(img, board, pattern):


# TODO self.size needs to come from CameraInfo, full resolution
class Calibrator(object):
class Calibrator():
"""
Base class for calibration system
"""
Expand Down Expand Up @@ -435,10 +435,11 @@ def lrmsg(self, d, k, r, p):
msg.distortion_model = "rational_polynomial"
else:
msg.distortion_model = "plumb_bob"
msg.D = numpy.ravel(d).copy().tolist()
msg.K = numpy.ravel(k).copy().tolist()
msg.R = numpy.ravel(r).copy().tolist()
msg.P = numpy.ravel(p).copy().tolist()

msg.d = numpy.ravel(d).copy().tolist()
msg.k = numpy.ravel(k).copy().tolist()
msg.r = numpy.ravel(r).copy().tolist()
msg.p = numpy.ravel(p).copy().tolist()
return msg

def lrreport(self, d, k, r, p):
Expand Down Expand Up @@ -522,11 +523,11 @@ def image_from_archive(archive, name):
Used for tarfile loading and unit test.
"""
member = archive.getmember(name)
imagefiledata = numpy.fromstring(archive.extractfile(member).read(), numpy.uint8)
imagefiledata = numpy.frombuffer(archive.extractfile(member).read(), numpy.uint8)
imagefiledata.resize((1, imagefiledata.size))
return cv2.imdecode(imagefiledata, cv2.IMREAD_COLOR)

class ImageDrawable(object):
class ImageDrawable():
"""
Passed to CalibrationNode after image handled. Allows plotting of images
with detected corner points
Expand Down Expand Up @@ -668,10 +669,10 @@ def from_message(self, msg, alpha = 0.0):
""" Initialize the camera calibration from a CameraInfo message """

self.size = (msg.width, msg.height)
self.intrinsics = numpy.array(msg.K, dtype=numpy.float64, copy=True).reshape((3, 3))
self.distortion = numpy.array(msg.D, dtype=numpy.float64, copy=True).reshape((len(msg.D), 1))
self.R = numpy.array(msg.R, dtype=numpy.float64, copy=True).reshape((3, 3))
self.P = numpy.array(msg.P, dtype=numpy.float64, copy=True).reshape((3, 4))
self.intrinsics = numpy.array(msg.k, dtype=numpy.float64, copy=True).reshape((3, 3))
self.distortion = numpy.array(msg.d, dtype=numpy.float64, copy=True).reshape((len(msg.d), 1))
self.R = numpy.array(msg.r, dtype=numpy.float64, copy=True).reshape((3, 3))
self.P = numpy.array(msg.p, dtype=numpy.float64, copy=True).reshape((3, 4))

self.set_alpha(0.0)

Expand Down Expand Up @@ -798,8 +799,8 @@ def do_tarfile_save(self, tf):
""" Write images and calibration solution to a tarfile object """

def taradd(name, buf):
if isinstance(buf, basestring):
s = StringIO(buf)
if isinstance(buf, str):
s = BytesIO(buf.encode('utf-8'))
else:
s = BytesIO(buf)
ti = tarfile.TarInfo(name)
Expand Down Expand Up @@ -1121,8 +1122,9 @@ def do_tarfile_save(self, tf):
[("right-%04d.png" % i, im) for i,(_, _, im) in enumerate(self.db)])

def taradd(name, buf):
if isinstance(buf, basestring):
s = StringIO(buf)
if isinstance(buf, str):
buf = bytes(buf, encoding="utf-8")
s = BytesIO(buf)
else:
s = BytesIO(buf)
ti = tarfile.TarInfo(name)
Expand Down
Loading