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

pull upstream noetic #10

Open
wants to merge 33 commits into
base: noetic
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
ace8c78
add DLL import/export macros (#266)
kejxu Mar 28, 2020
578af4d
update CMakeLists.txt for Windows build environment (#265)
kejxu Mar 28, 2020
9acfe21
Noetic release (#323)
ahcorde Apr 3, 2020
1a53e42
Changelogs
mjcarroll Apr 6, 2020
86da0fe
1.14.0
mjcarroll Apr 6, 2020
929d413
more portable fixes. (#328)
seanyen Apr 30, 2020
55bf089
[Noetic] Use opencv3 on buster (#330)
sloretz May 19, 2020
3369726
Changelogs
mjcarroll May 19, 2020
d9e8898
1.15.0
mjcarroll May 19, 2020
6769481
Fix typo (#333)
MatthijsBurgh May 27, 2020
0a908b0
Fix Python linking on OSX (#331)
Tobias-Fischer May 27, 2020
51ca543
Optimize includes (#354)
mvieth Aug 28, 2020
fc782bb
Add equidistant distortion model (#358)
mintar Mar 1, 2021
906d326
Implement unrectifyImage() (#359)
mintar Apr 16, 2021
eeaf346
decode images in mode IMREAD_UNCHANGED (#228)
christian-rauch Oct 11, 2021
15ddb06
Fix rectifyRoi when used with binning and/or ROI (#378)
mintar Nov 23, 2021
a01cfec
substituted missing sphinx extension (#417)
iPaddy Nov 23, 2021
f1dc651
prevent conversion of single channel 16bit integer images to/from col…
christian-rauch Nov 23, 2021
12889b7
1.16.0
mjcarroll Nov 23, 2021
c791220
Add header arg to cv2_to_imgmsg (#326)
708yamaguchi Nov 23, 2021
2cb900f
add fovX and fovY functions in python, cpp. also some typo fixes
cst0 Mar 22, 2022
9ec9cf5
add license file, closes https://github.com/ros/rosdistro/pull/32505#…
k-okada Mar 31, 2022
ec468f5
Fix 16U encoding type
HemaZ Jul 18, 2022
55c62bd
Merge pull request #445 from HemaZ/noetic
ijnek Sep 6, 2022
619de36
update CHANGELOG
ijnek Sep 6, 2022
8627296
1.16.1
ijnek Sep 6, 2022
e229d98
Merge pull request #430 from k-okada/add_license
ijnek Sep 7, 2022
fe95a55
Fixes to python camera model
cst0 Sep 25, 2022
eef41f9
Merge pull request #428 from cst0/cst/add_fov
ijnek Sep 25, 2022
7dc78a0
changelog
ijnek Oct 3, 2022
08b012c
1.16.2
ijnek Oct 3, 2022
8cc34b0
add opencv_include_dirs in include
knorth55 Jun 12, 2024
cfabf72
Merge pull request #534 from knorth55/opencv-include-dirs
ijnek Aug 20, 2024
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
6 changes: 3 additions & 3 deletions .travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@ function travis_time_end {
set -x
}

apt-get update -qq && apt-get install -y -q wget sudo lsb-release gnupg # for docker
apt-get update -qq && apt-get install -y -q wget sudo lsb-release gnupg build-essential # for docker
DEBIAN_FRONTEND=noninteractive apt-get install -y tzdata # https://stackoverflow.com/questions/44331836/apt-get-install-tzdata-noninteractive

travis_time_start setup.before_install
#before_install:
# Define some config vars.
# Install ROS
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
sudo sh -c 'echo "deb http://repositories.ros.org/ubuntu/testing $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
wget http://packages.ros.org/ros.key -O - | sudo apt-key add -
sudo apt-get update -qq || echo Ignore error on apt-get update
# Install ROS
sudo apt-get install -qq -y python-catkin-pkg python-catkin-tools python-rosdep python-wstool ros-$ROS_DISTRO-catkin
sudo apt-get install -qq -y python3-catkin-pkg python3-catkin-tools python3-osrf-pycommon python3-rosdep python3-wstool ros-$ROS_DISTRO-catkin
source /opt/ros/$ROS_DISTRO/setup.bash
# Setup for rosdep
sudo rosdep init
Expand Down
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ sudo: required
dist: trusty
language: generic
env:
- ROS_DISTRO=melodic
- ROS_DISTRO=noetic
# Install system dependencies, namely ROS.
before_install:
# Define some config vars.
Expand All @@ -11,7 +11,7 @@ before_install:
- export ROS_PARALLEL_JOBS='-j8 -l6'
script:
- echo "Testing branch $TRAVIS_BRANCH of $REPOSITORY_NAME"
- docker run --rm -i -v $CI_SOURCE_PATH:$CI_SOURCE_PATH -e "CI_SOURCE_PATH=$CI_SOURCE_PATH" -e "HOME=$HOME" -e "ROS_DISTRO=$ROS_DISTRO" -e "ROS_PARALLEL_JOBS=$ROS_PARALLEL_JOBS" -t ubuntu:bionic sh -c "cd $CI_SOURCE_PATH; ./.travis.sh"
- docker run --rm -i -v $CI_SOURCE_PATH:$CI_SOURCE_PATH -e "CI_SOURCE_PATH=$CI_SOURCE_PATH" -e "HOME=$HOME" -e "ROS_DISTRO=$ROS_DISTRO" -e "ROS_PARALLEL_JOBS=$ROS_PARALLEL_JOBS" -t ubuntu:focal sh -c "cd $CI_SOURCE_PATH; ./.travis.sh"
after_failure:
- find ${HOME}/.ros/test_results -type f -exec echo "== {} ==" \; -exec cat {} \;
- for file in ${HOME}/.ros/log/rostest-*; do echo "=== $file ==="; cat $file; done
29 changes: 29 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
BSD 3-Clause License

Copyright (c) 2008, Willow Garage, Inc.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 changes: 33 additions & 0 deletions cv_bridge/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,39 @@
Changelog for package cv_bridge
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

1.16.2 (2022-10-03)
-------------------

1.16.1 (2022-09-06)
-------------------
* Fix 16U encoding type (`#445 <https://github.com/ros-perception/vision_opencv/issues/445>`_)
* Add header arg to cv2_to_imgmsg (`#326 <https://github.com/ros-perception/vision_opencv/issues/326>`_)
* Contributors: Ibrahim Essam, Kenji Brameld, Naoya Yamaguchi

1.16.0 (2021-11-23)
-------------------
* prevent conversion of single channel 16bit integer images to/from colour (`#412 <https://github.com/ros-perception/vision_opencv/issues/412>`_)
* decode images in mode IMREAD_UNCHANGED (`#228 <https://github.com/ros-perception/vision_opencv/issues/228>`_)
* Optimize includes (`#354 <https://github.com/ros-perception/vision_opencv/issues/354>`_)
As suggested by include-what-you-use
* Fix Python linking on OSX (`#331 <https://github.com/ros-perception/vision_opencv/issues/331>`_)
* Fix typo (`#333 <https://github.com/ros-perception/vision_opencv/issues/333>`_)
* Contributors: Christian Rauch, Markus Vieth, Matthijs van der Burgh, Tobias Fischer

1.15.0 (2020-05-19)
-------------------
* [Noetic] Use opencv3 on buster (`#330 <https://github.com/ros-perception/vision_opencv/issues/330>`_)
* more portable fixes. (`#328 <https://github.com/ros-perception/vision_opencv/issues/328>`_)
* Contributors: Sean Yen, Shane Loretz

1.14.0 (2020-04-06)
-------------------
* Noetic release (`#323 <https://github.com/ros-perception/vision_opencv/issues/323>`_)
* update CMakeLists.txt for Windows build environment (`#265 <https://github.com/ros-perception/vision_opencv/issues/265>`_)
* remove path splash separator from 'package_dir' (`#267 <https://github.com/ros-perception/vision_opencv/issues/267>`_)
* fix travis. (`#269 <https://github.com/ros-perception/vision_opencv/issues/269>`_)
* Contributors: Alejandro Hernández Cordero, James Xu, Sean Yen

1.13.0 (2018-04-30)
-------------------
* Use rosdep OpenCV and not ROS one.
Expand Down
22 changes: 17 additions & 5 deletions cv_bridge/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 3.0.2)
project(cv_bridge)

find_package(catkin REQUIRED COMPONENTS rosconsole sensor_msgs)

if(NOT ANDROID)
find_package(PythonLibs)
if(PYTHONLIBS_VERSION_STRING VERSION_LESS 3)
find_package(Boost REQUIRED python)

if(PYTHONLIBS_VERSION_STRING VERSION_LESS "3.8")
# Debian Buster
find_package(Boost REQUIRED python37)
else()
find_package(Boost REQUIRED python3)
# Ubuntu Focal
find_package(Boost REQUIRED python)
endif()
else()
find_package(Boost REQUIRED)
endif()
find_package(OpenCV 3 REQUIRED

set(_opencv_version 4)
find_package(OpenCV 4 QUIET)
if(NOT OpenCV_FOUND)
message(STATUS "Did not find OpenCV 4, trying OpenCV 3")
set(_opencv_version 3)
endif()

find_package(OpenCV ${_opencv_version} REQUIRED
COMPONENTS
opencv_core
opencv_imgproc
Expand All @@ -32,6 +43,7 @@ catkin_package(
catkin_python_setup()

include_directories(include ${Boost_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS} ${catkin_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})

if(NOT ANDROID)
add_subdirectory(python)
Expand Down
2 changes: 1 addition & 1 deletion cv_bridge/include/cv_bridge/rgb_colors.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#ifndef CV_BRIDGE_RGB_COLORS_H_
#define CV_BRIDGE_RGB_COLORS_H_

#include <opencv2/opencv.hpp>
#include <opencv2/core/matx.hpp>


namespace cv_bridge
Expand Down
12 changes: 6 additions & 6 deletions cv_bridge/package.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<package format="2">
<name>cv_bridge</name>
<version>1.13.0</version>
<version>1.16.2</version>
<description>
This contains CvBridge, which converts between ROS
Image messages and OpenCV images.
Expand All @@ -21,21 +21,21 @@

<build_depend>boost</build_depend>
<build_depend>libopencv-dev</build_depend>
<build_depend>python</build_depend>
<build_depend>python-opencv</build_depend>
<build_depend>python3</build_depend>
<build_depend>python3-opencv</build_depend>
<build_depend>rosconsole</build_depend>
<build_depend>sensor_msgs</build_depend>

<exec_depend>boost</exec_depend>
<exec_depend>libopencv-dev</exec_depend>
<exec_depend>python</exec_depend>
<exec_depend>python-opencv</exec_depend>
<exec_depend>python3</exec_depend>
<exec_depend>python3-opencv</exec_depend>
<exec_depend>rosconsole</exec_depend>
<build_export_depend>libopencv-dev</build_export_depend>
<build_export_depend>sensor_msgs</build_export_depend>

<test_depend>rostest</test_depend>
<test_depend>python-numpy</test_depend>
<test_depend>python3-numpy</test_depend>

<doc_depend>dvipng</doc_depend>
</package>
15 changes: 11 additions & 4 deletions cv_bridge/python/cv_bridge/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def compressed_imgmsg_to_cv2(self, cmprs_img_msg, desired_encoding = "passthroug
str_msg = cmprs_img_msg.data
buf = np.ndarray(shape=(1, len(str_msg)),
dtype=np.uint8, buffer=cmprs_img_msg.data)
im = cv2.imdecode(buf, cv2.IMREAD_ANYCOLOR)
im = cv2.imdecode(buf, cv2.IMREAD_UNCHANGED)

if desired_encoding == "passthrough":
return im
Expand Down Expand Up @@ -167,8 +167,12 @@ def imgmsg_to_cv2(self, img_msg, desired_encoding = "passthrough"):
im = np.ndarray(shape=(img_msg.height, img_msg.width),
dtype=dtype, buffer=img_msg.data)
else:
im = np.ndarray(shape=(img_msg.height, img_msg.width, n_channels),
dtype=dtype, buffer=img_msg.data)
if(type(img_msg.data) == str):
im = np.ndarray(shape=(img_msg.height, img_msg.width, n_channels),
dtype=dtype, buffer=img_msg.data.encode())
else:
im = np.ndarray(shape=(img_msg.height, img_msg.width, n_channels),
dtype=dtype, buffer=img_msg.data)
# If the byt order is different between the message and the system.
if img_msg.is_bigendian == (sys.byteorder == 'little'):
im = im.byteswap().newbyteorder()
Expand Down Expand Up @@ -222,7 +226,7 @@ def cv2_to_compressed_imgmsg(self, cvim, dst_format = "jpg"):

return cmprs_img_msg

def cv2_to_imgmsg(self, cvim, encoding = "passthrough"):
def cv2_to_imgmsg(self, cvim, encoding = "passthrough", header = None):
"""
Convert an OpenCV :cpp:type:`cv::Mat` type to a ROS sensor_msgs::Image message.

Expand All @@ -231,6 +235,7 @@ def cv2_to_imgmsg(self, cvim, encoding = "passthrough"):

* ``"passthrough"``
* one of the standard strings in sensor_msgs/image_encodings.h
:param header: A std_msgs.msg.Header message

:rtype: A sensor_msgs.msg.Image message
:raises CvBridgeError: when the ``cvim`` has a type that is incompatible with ``encoding``
Expand All @@ -247,6 +252,8 @@ def cv2_to_imgmsg(self, cvim, encoding = "passthrough"):
img_msg = sensor_msgs.msg.Image()
img_msg.height = cvim.shape[0]
img_msg.width = cvim.shape[1]
if header is not None:
img_msg.header = header
if len(cvim.shape) < 3:
cv_type = self.dtype_with_channels_to_cvtype2(cvim.dtype, 1)
else:
Expand Down
2 changes: 1 addition & 1 deletion cv_bridge/setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python
from distutils.core import setup
from setuptools import setup
from catkin_pkg.python_setup import generate_distutils_setup

d = generate_distutils_setup()
Expand Down
24 changes: 17 additions & 7 deletions cv_bridge/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ add_library(${PROJECT_NAME} cv_bridge.cpp rgb_colors.cpp)
add_dependencies(${PROJECT_NAME} ${catkin_EXPORTED_TARGETS})
target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBRARIES} ${catkin_LIBRARIES})

install(TARGETS ${PROJECT_NAME} DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION})
install(TARGETS ${PROJECT_NAME}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}
)

if(NOT ANDROID)
# add a Boost Python library
Expand Down Expand Up @@ -32,24 +36,30 @@ if (PYTHON_VERSION_MAJOR VERSION_EQUAL 3)
add_definitions(-DPYTHON3)
endif()

if (OpenCV_VERSION_MAJOR VERSION_EQUAL 3)
add_library(${PROJECT_NAME}_boost module.cpp module_opencv3.cpp)
else()
add_library(${PROJECT_NAME}_boost module.cpp module_opencv2.cpp)
endif()
add_library(${PROJECT_NAME}_boost module.cpp module_opencv4.cpp)
target_link_libraries(${PROJECT_NAME}_boost ${Boost_LIBRARIES}
${catkin_LIBRARIES}
${PYTHON_LIBRARIES}
${PROJECT_NAME}
)

if(NOT APPLE)
target_link_libraries(${PROJECT_NAME}_boost ${PYTHON_LIBRARIES})
endif()

set_target_properties(${PROJECT_NAME}_boost PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${CATKIN_DEVEL_PREFIX}/${CATKIN_GLOBAL_PYTHON_DESTINATION}/${PROJECT_NAME}/boost/
RUNTIME_OUTPUT_DIRECTORY ${CATKIN_DEVEL_PREFIX}/${CATKIN_GLOBAL_PYTHON_DESTINATION}/${PROJECT_NAME}/boost/
PREFIX ""
)
if(APPLE)
set_target_properties(${PROJECT_NAME}_boost PROPERTIES
SUFFIX ".so")
set_target_properties(${PROJECT_NAME}_boost PROPERTIES
LINK_FLAGS "-undefined dynamic_lookup")
endif()
if(MSVC)
set_target_properties(${PROJECT_NAME}_boost PROPERTIES
SUFFIX ".pyd")
endif()

install(TARGETS ${PROJECT_NAME}_boost DESTINATION ${CATKIN_PACKAGE_PYTHON_DESTINATION}/boost/)
Expand Down
37 changes: 21 additions & 16 deletions cv_bridge/src/cv_bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ void CvImage::toCompressedImageMsg(sensor_msgs::CompressedImage& ros_image, cons
{
ros_image.header = header;
cv::Mat image;
if (encoding == enc::BGR8 || encoding == enc::BGRA8)
if (encoding == enc::BGR8 || encoding == enc::BGRA8 || encoding == enc::MONO8 || encoding == enc::MONO16)
{
image = this->image;
}
Expand Down Expand Up @@ -519,19 +519,24 @@ CvImagePtr toCvCopy(const sensor_msgs::CompressedImage& source, const std::strin
// Loads as BGR or BGRA.
const cv::Mat rgb_a = cv::imdecode(in, cv::IMREAD_UNCHANGED);

switch (rgb_a.channels())
{
case 4:
return toCvCopyImpl(rgb_a, source.header, enc::BGRA8, encoding);
break;
case 3:
return toCvCopyImpl(rgb_a, source.header, enc::BGR8, encoding);
break;
case 1:
return toCvCopyImpl(rgb_a, source.header, enc::MONO8, encoding);
break;
default:
return CvImagePtr();
if (encoding != enc::MONO16) {
switch (rgb_a.channels())
{
case 4:
return toCvCopyImpl(rgb_a, source.header, enc::BGRA8, encoding);
break;
case 3:
return toCvCopyImpl(rgb_a, source.header, enc::BGR8, encoding);
break;
case 1:
return toCvCopyImpl(rgb_a, source.header, enc::MONO8, encoding);
break;
default:
return CvImagePtr();
}
}
else {
return toCvCopyImpl(rgb_a, source.header, enc::MONO16, encoding);
}
}

Expand Down Expand Up @@ -677,9 +682,9 @@ CvImageConstPtr cvtColorForDisplay(const CvImageConstPtr& source,
else if (source->encoding == "CV_8UC4")
source_typed->encoding = enc::BGRA8;
else if (source->encoding == "CV_16UC3")
source_typed->encoding = enc::BGR8;
source_typed->encoding = enc::BGR16;
else if (source->encoding == "CV_16UC4")
source_typed->encoding = enc::BGRA8;
source_typed->encoding = enc::BGRA16;

// If no conversion is needed, don't convert
if (source_typed->encoding == encoding)
Expand Down
10 changes: 2 additions & 8 deletions cv_bridge/src/module.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,10 @@ int convert_to_CvMat2(const PyObject* o, cv::Mat& m);

PyObject* pyopencv_from(const cv::Mat& m);

#if PYTHON3
static int do_numpy_import( )
static void * do_numpy_import( )
{
import_array( );
return nullptr;
}
#else
static void do_numpy_import( )
{
import_array( );
}
#endif

#endif
Loading