diff --git a/image_geometry/image_geometry/cameramodels.py b/image_geometry/image_geometry/cameramodels.py
index 139c95c38..75a0b8037 100644
--- a/image_geometry/image_geometry/cameramodels.py
+++ b/image_geometry/image_geometry/cameramodels.py
@@ -39,15 +39,15 @@ def fromCameraInfo(self, msg):
Set the camera parameters from the :class:`sensor_msgs.msg.CameraInfo` message.
"""
- self.K = mkmat(3, 3, msg.K)
- if msg.D:
- self.D = mkmat(len(msg.D), 1, msg.D)
+ self.K = mkmat(3, 3, msg.k)
+ if msg.d:
+ self.D = mkmat(len(msg.d), 1, msg.d)
else:
self.D = None
- self.R = mkmat(3, 3, msg.R)
- self.P = mkmat(3, 4, msg.P)
- self.full_K = mkmat(3, 3, msg.K)
- self.full_P = mkmat(3, 4, msg.P)
+ self.R = mkmat(3, 3, msg.r)
+ self.P = mkmat(3, 4, msg.p)
+ self.full_K = mkmat(3, 3, msg.k)
+ self.full_P = mkmat(3, 4, msg.p)
self.width = msg.width
self.height = msg.height
self.binning_x = max(1, msg.binning_x)
diff --git a/image_geometry/package.xml b/image_geometry/package.xml
index d9868ba73..d31bc18ef 100644
--- a/image_geometry/package.xml
+++ b/image_geometry/package.xml
@@ -27,6 +27,9 @@
ament_cmake_gtest
ament_cmake_pytest
+ ament_copyright
+ ament_flake8
+ ament_pep257
dvipng
texlive-latex-extra
diff --git a/image_geometry/ros2_image_geometry_migration_readme.md b/image_geometry/ros2_image_geometry_migration_readme.md
new file mode 100644
index 000000000..44fecd171
--- /dev/null
+++ b/image_geometry/ros2_image_geometry_migration_readme.md
@@ -0,0 +1,55 @@
+
+**This file describes work done and steps to perform test on the image_geometry package for ROS2 (Bouncy & Crystal).**
+
+**Overview:**
+
+ image_geometry is a package for interpreting images geometrically.
+
+**List of changes from ROS1 to ROS2:**
+
+ The changes has been done by following the Migration guide for ROS2( https://index.ros.org/doc/ros2/Migration-Guide/ ).
+
+ 1. Migrated directed.py python tests to ROS2
+ 2. Enabled pytests in image_geometry package.
+ 3. Migrated cameramodels.py, directed.py, CMakelists.txt & package.xml files for ROS2.
+ 4. Merged Approved changes from PR #257.
+ 5. Followed cosmetics rules and updated the files with copyright, pep257 and flake8 rules.
+
+**Pre-requisites:**
+
+ 1. System should have installed Crystal/Bouncy distro. Check out installation instructions and tutorials https://index.ros.org/doc/ros2/.
+ 2. System should have checkout ros2 vision_opencv pkg & build (Refer Steps below).
+
+ Steps to checkout vision_opencv package:
+ 1. Open the new terminal and run below commands.
+ 2. mkdir -p vision_opencv_ws/src
+ 3. cd ~/vision_opencv_ws/src
+ 4. git clone git@github.com:akhileshmoghe/vision_opencv.git
+ #git branch -ra //This command will show different branches of main git on #kinetic
+ 5. cd vision_opencv/
+ 6. git checkout -b ros2-devel remotes/origin/ros2-devel
+
+ Steps to Build vision_opencv package:
+ 1. cd ~/vision_opencv_ws/
+ 2. for Crystal:
+ source /opt/ros/crystal/setup.bash
+ for Bouncy:
+ source /opt/ros/bouncy/setup.bash
+ 3. cd ~/vision_opencv_ws/src/vision_opencv
+ 4. colcon build
+
+ 4. System should have both ROS1 & ROS2. Note: We have verified on ROS1(i.e. melodic) & ROS2 (i.e. Bouncy & Crystal).
+
+
+**Future Work:-**
+
+ 1. Make Cpp code for image_geometry package to be completely cosmetic rules compliant.
+
+
+**TESTING:-**
+
+ Run the test cases as follows:-
+ cd ~/vision_opencv_ws_crystal/src/vision_opencv/
+ colcon test
+
+
diff --git a/image_geometry/test/CMakeLists.txt b/image_geometry/test/CMakeLists.txt
index 006ff76f9..cbe1586e8 100644
--- a/image_geometry/test/CMakeLists.txt
+++ b/image_geometry/test/CMakeLists.txt
@@ -1,8 +1,14 @@
find_package(ament_cmake_gtest REQUIRED)
# TODO(mikaelarguedas) Reenable this when tests are ported to ROS 2
-# find_package(ament_cmake_pytest REQUIRED)
+find_package(ament_cmake_pytest REQUIRED)
+find_package(ament_cmake_flake8 REQUIRED)
+find_package(ament_cmake_pep257 REQUIRED)
+find_package(ament_cmake_copyright REQUIRED)
-# ament_add_pytest_test(directed.py "directed.py")
+ament_add_pytest_test(directed.py "directed.py")
+ament_copyright()
+ament_pep257()
+ament_flake8()
ament_add_gtest(${PROJECT_NAME}-utest utest.cpp APPEND_LIBRARY_DIRS "${image_geometry_lib_dir}")
target_link_libraries(${PROJECT_NAME}-utest ${PROJECT_NAME} ${OpenCV_LIBS})
diff --git a/image_geometry/test/directed.py b/image_geometry/test/directed.py
index 27e0c5330..06bf37f8c 100644
--- a/image_geometry/test/directed.py
+++ b/image_geometry/test/directed.py
@@ -1,10 +1,26 @@
+# Copyright 2018 Open Source Robotics Foundation, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
from __future__ import print_function
import unittest
-import sensor_msgs.msg
from image_geometry import PinholeCameraModel, StereoCameraModel
+import sensor_msgs.msg
+
+
class TestDirected(unittest.TestCase):
def setUp(self):
@@ -19,7 +35,7 @@ def test_monocular(self):
cam.fromCameraInfo(ci)
print(cam.rectifyPoint((0, 0)))
- print(cam.project3dToPixel((0,0,0)))
+ print(cam.project3dToPixel((0, 0, 0)))
def test_stereo(self):
lmsg = sensor_msgs.msg.CameraInfo()
@@ -29,15 +45,25 @@ def test_stereo(self):
m.height = 480
# These parameters taken from a real camera calibration
- lmsg.D = [-0.363528858080088, 0.16117037733986861, -8.1109585007538829e-05, -0.00044776712298447841, 0.0]
- lmsg.K = [430.15433020105519, 0.0, 311.71339830549732, 0.0, 430.60920415473657, 221.06824942698509, 0.0, 0.0, 1.0]
- lmsg.R = [0.99806560714807102, 0.0068562422224214027, 0.061790256276695904, -0.0067522959054715113, 0.99997541519165112, -0.0018909025066874664, -0.061801701660692349, 0.0014700186639396652, 0.99808736527268516]
- lmsg.P = [295.53402059708782, 0.0, 285.55760765075684, 0.0, 0.0, 295.53402059708782, 223.29617881774902, 0.0, 0.0, 0.0, 1.0, 0.0]
+ lmsg.d = [-0.363528858080088, 0.16117037733986861, -8.1109585007538829e-05,
+ -0.00044776712298447841, 0.0]
+ lmsg.k = [430.15433020105519, 0.0, 311.71339830549732, 0.0, 430.60920415473657,
+ 221.06824942698509, 0.0, 0.0, 1.0]
+ lmsg.r = [0.99806560714807102, 0.0068562422224214027, 0.061790256276695904,
+ -0.0067522959054715113, 0.99997541519165112, -0.0018909025066874664,
+ -0.061801701660692349, 0.0014700186639396652, 0.99808736527268516]
+ lmsg.p = [295.53402059708782, 0.0, 285.55760765075684, 0.0, 0.0, 295.53402059708782,
+ 223.29617881774902, 0.0, 0.0, 0.0, 1.0, 0.0]
- rmsg.D = [-0.3560641041112021, 0.15647260261553159, -0.00016442960757099968, -0.00093175810713916221]
- rmsg.K = [428.38163131344191, 0.0, 327.95553847249192, 0.0, 428.85728580588329, 217.54828640915309, 0.0, 0.0, 1.0]
- rmsg.R = [0.9982082576219119, 0.0067433328293516528, 0.059454199832973849, -0.0068433268864187356, 0.99997549128605434, 0.0014784127772287513, -0.059442773257581252, -0.0018826283666309878, 0.99822993965212292]
- rmsg.P = [295.53402059708782, 0.0, 285.55760765075684, -26.507895206214123, 0.0, 295.53402059708782, 223.29617881774902, 0.0, 0.0, 0.0, 1.0, 0.0]
+ rmsg.d = [-0.3560641041112021, 0.15647260261553159, -0.00016442960757099968,
+ -0.00093175810713916221]
+ rmsg.k = [428.38163131344191, 0.0, 327.95553847249192, 0.0, 428.85728580588329,
+ 217.54828640915309, 0.0, 0.0, 1.0]
+ rmsg.r = [0.9982082576219119, 0.0067433328293516528, 0.059454199832973849,
+ -0.0068433268864187356, 0.99997549128605434, 0.0014784127772287513,
+ -0.059442773257581252, -0.0018826283666309878, 0.99822993965212292]
+ rmsg.p = [295.53402059708782, 0.0, 285.55760765075684, -26.507895206214123, 0.0,
+ 295.53402059708782, 223.29617881774902, 0.0, 0.0, 0.0, 1.0, 0.0]
cam = StereoCameraModel()
cam.fromCameraInfo(lmsg, rmsg)
@@ -51,7 +77,7 @@ def test_stereo(self):
self.assertAlmostEqual(y, ry, 3)
self.assertAlmostEqual(x, lx, 3)
self.assertAlmostEqual(x, rx + d, 3)
-
+
u = 100.0
v = 200.0
du = 17.0
@@ -66,6 +92,7 @@ def test_stereo(self):
self.assertAlmostEqual(cam.left.getDeltaX(du, Z), xyz1[0] - xyz0[0], 3)
self.assertAlmostEqual(cam.left.getDeltaY(dv, Z), xyz1[1] - xyz0[1], 3)
+
if __name__ == '__main__':
suite = unittest.TestSuite()
suite.addTest(TestDirected('test_stereo'))
diff --git a/image_geometry/test/test_copyright.py b/image_geometry/test/test_copyright.py
new file mode 100644
index 000000000..77911ca15
--- /dev/null
+++ b/image_geometry/test/test_copyright.py
@@ -0,0 +1,23 @@
+# Copyright 2018 Open Source Robotics Foundation, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from ament_copyright.main import main
+import pytest
+
+
+@pytest.mark.copyright
+@pytest.mark.linter
+def test_copyright():
+ rc = main(argv=['.', 'test'])
+ assert rc == 0, 'Found errors'
diff --git a/image_geometry/test/test_flake8.py b/image_geometry/test/test_flake8.py
new file mode 100644
index 000000000..d4c35d616
--- /dev/null
+++ b/image_geometry/test/test_flake8.py
@@ -0,0 +1,23 @@
+# Copyright 2018 Open Source Robotics Foundation, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from ament_flake8.main import main
+import pytest
+
+
+@pytest.mark.flake8
+@pytest.mark.linter
+def test_flake8():
+ rc = main(argv=[])
+ assert rc == 0, 'Found errors'
diff --git a/image_geometry/test/test_pep257.py b/image_geometry/test/test_pep257.py
new file mode 100644
index 000000000..19cd55a72
--- /dev/null
+++ b/image_geometry/test/test_pep257.py
@@ -0,0 +1,23 @@
+# Copyright 2018 Open Source Robotics Foundation, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from ament_pep257.main import main
+import pytest
+
+
+@pytest.mark.linter
+@pytest.mark.pep257
+def test_pep257():
+ rc = main(argv=[])
+ assert rc == 0, 'Found code style errors / warnings'
diff --git a/image_geometry/test/utest.cpp b/image_geometry/test/utest.cpp
index b002b0398..3afe6cf70 100644
--- a/image_geometry/test/utest.cpp
+++ b/image_geometry/test/utest.cpp
@@ -1,3 +1,17 @@
+// Copyright 2018 Open Source Robotics Foundation, Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
#include "image_geometry/pinhole_camera_model.h"
#include
#include