Skip to content

Commit

Permalink
Merge branch 'rolling' into bugfix/image-publisher-camera-info-startup
Browse files Browse the repository at this point in the history
  • Loading branch information
Kotochleb committed May 28, 2024
2 parents 149ed41 + 78d80f7 commit 8996ed3
Show file tree
Hide file tree
Showing 22 changed files with 116 additions and 13 deletions.
49 changes: 49 additions & 0 deletions camera_calibration/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,55 @@
Changelog for package camera_calibration
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

6.0.0 (2024-05-27)
------------------
* fix: cv2.aruco.interpolateCornersCharuco is deprecated (`#979 <https://github.com/ros-perception/image_pipeline/issues/979>`_)
There has been API Changes in the newer releases of opencv2 (from
4.8.0). The PR addresses this by supporting both the old and new APIs.
updated Syntax
```
charucodetector = cv2.aruco.CharucoDetector(board)
charuco_corners, charuco_ids, marker_corners, marker_ids = charucodetector.detectBoard(image)
```
before 4.8.0
```
marker_corners, marker_ids, rejectedImgPoints = cv2.aruco.detectMarkers( image, dictionary)
retval, charuco_corners, charuco_ids = cv2.aruco.interpolateCornersCharuco( marker_corners, marker_ids, image, board)
```
See the changed examples in the main opencv2 repo:
https://github.com/opencv/opencv/blob/f9a59f2592993d3dcc080e495f4f5e02dd8ec7ef/samples/python/calibrate.py#L110
* Update for compatibility with image_pipeline 4.1.0 (`#968 <https://github.com/ros-perception/image_pipeline/issues/968>`_)
This is a PR to fix:
- `#966 <https://github.com/ros-perception/image_pipeline/issues/966>`_
As noted in `#966 <https://github.com/ros-perception/image_pipeline/issues/966>`_, as of writing image_pipeline [4.1.0 has been
released](https://github.com/ros-perception/vision_opencv/releases/tag/4.1.0),
is updated on
[index.ros.org](https://index.ros.org/p/image_geometry/github-ros-perception-vision_opencv/#rolling),
but it has not yet been migrated to
[packages.ros.org](http://packages.ros.org/ros2/ubuntu/dists/noble/main/binary-amd64/Packages).
As such `camera_calibration` will also require the source of
[image_pipeline
4.1.0](https://github.com/ros-perception/vision_opencv/releases/tag/4.1.0)
or higher to successfully build.
I tested to ensure successful build with colcon build & colcon test.
Note that colcon test has the following warning that is out of scope of
this PR:
```
=============================== warnings summary ===============================
src/camera_calibration/calibrator.py:47
Warning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
```
Please let me know if there are any questions, concerns, or requested
changes.
* replace disutils with python3-semver (`#970 <https://github.com/ros-perception/image_pipeline/issues/970>`_)
Fix for
- `#969 <https://github.com/ros-perception/image_pipeline/issues/969>`_
I added a dependency for `python3-semver` to replace version parsing
with `disutils`.
Please let me know if you have any questions, concerns, or additional
requested changes.
* Contributors: Földi Tamás, Scott Monaghan

5.0.1 (2024-03-26)
------------------
* Fix spelling error for cv2.aruco.DICT from 6x6_50 to 7x7_1000 (`#961 <https://github.com/ros-perception/image_pipeline/issues/961>`_)
Expand Down
2 changes: 1 addition & 1 deletion camera_calibration/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>camera_calibration</name>
<version>5.0.1</version>
<version>6.0.0</version>
<description>
camera_calibration allows easy calibration of monocular or stereo
cameras using a checkerboard calibration target.
Expand Down
2 changes: 1 addition & 1 deletion camera_calibration/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name=PACKAGE_NAME,
version='5.0.1',
version='6.0.0',
packages=["camera_calibration", "camera_calibration.nodes"],
data_files=[
('share/ament_index/resource_index/packages',
Expand Down
3 changes: 3 additions & 0 deletions depth_image_proc/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
Changelog for package depth_image_proc
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

6.0.0 (2024-05-27)
------------------

5.0.1 (2024-03-26)
------------------
* Update depth_image_proc::RegisterNode documentation (`#957 <https://github.com/ros-perception/image_pipeline/issues/957>`_)
Expand Down
2 changes: 1 addition & 1 deletion depth_image_proc/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>depth_image_proc</name>
<version>5.0.1</version>
<version>6.0.0</version>
<description>

Contains components for processing depth images such as those
Expand Down
3 changes: 3 additions & 0 deletions image_pipeline/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
Changelog for package image_pipeline
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

6.0.0 (2024-05-27)
------------------

5.0.1 (2024-03-26)
------------------
* DisparityNode: replace full_dp parameter with sgbm_mode (`#945 <https://github.com/ros-perception/image_pipeline/issues/945>`_)
Expand Down
2 changes: 1 addition & 1 deletion image_pipeline/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>image_pipeline</name>
<version>5.0.1</version>
<version>6.0.0</version>
<description>image_pipeline fills the gap between getting raw images from a camera driver and higher-level vision processing.</description>

<maintainer email="[email protected]">Vincent Rabaud</maintainer>
Expand Down
3 changes: 3 additions & 0 deletions image_proc/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
Changelog for package image_proc
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

6.0.0 (2024-05-27)
------------------

5.0.1 (2024-03-26)
------------------
* Fix parameter names in components.rst (`#959 <https://github.com/ros-perception/image_pipeline/issues/959>`_)
Expand Down
2 changes: 1 addition & 1 deletion image_proc/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>image_proc</name>
<version>5.0.1</version>
<version>6.0.0</version>
<description>Single image rectification and color processing.</description>

<maintainer email="[email protected]">Vincent Rabaud</maintainer>
Expand Down
14 changes: 14 additions & 0 deletions image_publisher/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@
Changelog for package image_publisher
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

6.0.0 (2024-05-27)
------------------
* [rolling] image_publisher: Fix image, constantly flipping when static image is published (`#986 <https://github.com/ros-perception/image_pipeline/issues/986>`_)
Continuation of
https://github.com/ros-perception/image_pipeline/pull/984.
When publishing video stream from a camera, the image was flipped
correctly. Yet for a static image, which was loaded once, the flip
function was applied every time `ImagePublisher::doWork()` was called,
resulting in the published image being flipped back and forth all the
time.
This PR should be straightforward to port it to `Humble`, `Iron` and
`Jazzy`.
* Contributors: Krzysztof Wojciechowski

5.0.1 (2024-03-26)
------------------
* unified changelog, add missing image, deduplicate tutorials (`#938 <https://github.com/ros-perception/image_pipeline/issues/938>`_)
Expand Down
1 change: 1 addition & 0 deletions image_publisher/doc/components.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Published Topics
Parameters
^^^^^^^^^^
* **filename** (string, default: ""): Name of image file to be published.
* **field_of_view** (double, default: 0): Camera field of view (deg) used to calculate focal length for camera info topic.
* **flip_horizontal** (bool, default: false): Flip output image horizontally.
* **flip_vertical** (bool, default: false): Flip output image vertically.
* **frame_id** (string, default: "camera") Frame id inserted in published
Expand Down
2 changes: 2 additions & 0 deletions image_publisher/include/image_publisher/image_publisher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ class ImagePublisher : public rclcpp::Node
rclcpp::Node::OnSetParametersCallbackHandle::SharedPtr on_set_parameters_callback_handle_;

std::string filename_;
double field_of_view_;
bool flip_horizontal_;
bool flip_vertical_;
bool image_flipped_;
bool retry_; // If enabled will retry loading image from the filename_
int timeout_; // Time after which retrying starts

Expand Down
2 changes: 1 addition & 1 deletion image_publisher/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>image_publisher</name>
<version>5.0.1</version>
<version>6.0.0</version>
<description>

Contains a node publish an image stream from single image file
Expand Down
22 changes: 19 additions & 3 deletions image_publisher/src/image_publisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.

#include <cmath>
#include <chrono>
#include <limits>
#include <string>
#include <thread>
#include <vector>
Expand Down Expand Up @@ -60,6 +62,7 @@ ImagePublisher::ImagePublisher(
std::string topic_name = node_base->resolve_topic_or_service_name("image_raw", false);
pub_ = image_transport::create_camera_publisher(this, topic_name);

field_of_view_ = this->declare_parameter("field_of_view", static_cast<double>(0));
flip_horizontal_ = this->declare_parameter("flip_horizontal", false);
flip_vertical_ = this->declare_parameter("flip_vertical", false);
frame_id_ = this->declare_parameter("frame_id", std::string("camera"));
Expand All @@ -81,6 +84,10 @@ ImagePublisher::ImagePublisher(
filename_ = parameter.as_string();
RCLCPP_INFO(get_logger(), "Reset filename as '%s'", filename_.c_str());
call_init = true;
} else if (parameter.get_name() == "field_of_view") {
field_of_view_ = parameter.as_double();
RCLCPP_INFO(get_logger(), "Reset field_of_view as '%f'", field_of_view_);
call_init = true;
} else if (parameter.get_name() == "flip_horizontal") {
flip_horizontal_ = parameter.as_bool();
RCLCPP_INFO(get_logger(), "Reset flip_horizontal as '%d'", flip_horizontal_);
Expand Down Expand Up @@ -152,9 +159,11 @@ void ImagePublisher::doWork()
if (!cap_.read(image_)) {
cap_.set(cv::CAP_PROP_POS_FRAMES, 0);
}
image_flipped_ = false;
}
if (flip_image_) {
if (flip_image_ && !image_flipped_) {
cv::flip(image_, image_, flip_value_);
image_flipped_ = true;
}

sensor_msgs::msg::Image::SharedPtr out_img =
Expand Down Expand Up @@ -221,15 +230,22 @@ void ImagePublisher::onInit()
} else {
flip_image_ = false;
}
image_flipped_ = false; // Image newly read, needs to be flipped

camera_info_.width = image_.cols;
camera_info_.height = image_.rows;
camera_info_.distortion_model = "plumb_bob";
camera_info_.d = {0, 0, 0, 0, 0};
camera_info_.k = {1, 0, static_cast<float>(camera_info_.width / 2), 0, 1,

double f_approx = 1.0; // FOV equal to 0 disables the approximation
if (std::abs(field_of_view_) > std::numeric_limits<double>::epsilon()) {
// Based on https://learnopencv.com/approximate-focal-length-for-webcams-and-cell-phone-cameras/
f_approx = (camera_info_.width / 2) / std::tan((field_of_view_ * M_PI / 180) / 2);
}
camera_info_.k = {f_approx, 0, static_cast<float>(camera_info_.width / 2), 0, f_approx,
static_cast<float>(camera_info_.height / 2), 0, 0, 1};
camera_info_.r = {1, 0, 0, 0, 1, 0, 0, 0, 1};
camera_info_.p = {1, 0, static_cast<float>(camera_info_.width / 2), 0, 0, 1,
camera_info_.p = {f_approx, 0, static_cast<float>(camera_info_.width / 2), 0, 0, f_approx,
static_cast<float>(camera_info_.height / 2), 0, 0, 0, 1, 0};

ImagePublisher::reconfigureCallback();
Expand Down
3 changes: 3 additions & 0 deletions image_rotate/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
Changelog for package image_rotate
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

6.0.0 (2024-05-27)
------------------

5.0.1 (2024-03-26)
------------------
* fix image publisher remapping (`#941 <https://github.com/ros-perception/image_pipeline/issues/941>`_)
Expand Down
2 changes: 1 addition & 1 deletion image_rotate/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>image_rotate</name>
<version>5.0.1</version>
<version>6.0.0</version>
<description>
<p>
Contains a node that rotates an image stream in a way that minimizes
Expand Down
3 changes: 3 additions & 0 deletions image_view/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
Changelog for package image_view
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

6.0.0 (2024-05-27)
------------------

5.0.1 (2024-03-26)
------------------
* unified changelog, add missing image, deduplicate tutorials (`#938 <https://github.com/ros-perception/image_pipeline/issues/938>`_)
Expand Down
2 changes: 1 addition & 1 deletion image_view/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>image_view</name>
<version>5.0.1</version>
<version>6.0.0</version>
<description>
A simple viewer for ROS image topics. Includes a specialized viewer
for stereo + disparity images.
Expand Down
3 changes: 3 additions & 0 deletions stereo_image_proc/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
Changelog for package stereo_image_proc
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

6.0.0 (2024-05-27)
------------------

5.0.1 (2024-03-26)
------------------
* DisparityNode: replace full_dp parameter with sgbm_mode (`#945 <https://github.com/ros-perception/image_pipeline/issues/945>`_)
Expand Down
2 changes: 1 addition & 1 deletion stereo_image_proc/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>stereo_image_proc</name>
<version>5.0.1</version>
<version>6.0.0</version>
<description>Stereo and single image rectification and disparity processing.</description>

<maintainer email="[email protected]">Vincent Rabaud</maintainer>
Expand Down
3 changes: 3 additions & 0 deletions tracetools_image_pipeline/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
Changelog for package tracetools_image_pipeline
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

6.0.0 (2024-05-27)
------------------

5.0.1 (2024-03-26)
------------------

Expand Down
2 changes: 1 addition & 1 deletion tracetools_image_pipeline/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<?xml-model href="http://download.ros.org/schema/package_format2.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="2">
<name>tracetools_image_pipeline</name>
<version>5.0.1</version>
<version>6.0.0</version>
<description>
LTTng tracing provider wrapper for image_pipeline ROS 2 meta-package.
</description>
Expand Down

0 comments on commit 8996ed3

Please sign in to comment.