From 4cfc593605f737166a808c53583704853fa4fc08 Mon Sep 17 00:00:00 2001 From: Kei Okada Date: Tue, 13 Dec 2022 11:15:51 +0900 Subject: [PATCH 01/29] add noetic build test --- .github/workflows/config.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/config.yml b/.github/workflows/config.yml index 8be5cd9023..14ef8de3d9 100644 --- a/.github/workflows/config.yml +++ b/.github/workflows/config.yml @@ -66,16 +66,26 @@ jobs: NOT_TEST_INSTALL : true USE_JENKINS: true DOCKER_IMAGE_JENKINS: ros-ubuntu:20.04-pcl - TEST_PKGS : 'jsk_recognition_msgs' # to skip test BEFORE_SCRIPT : "sudo pip install numpy==1.16.6; sudo pip install fcn chainercv chainer-mask-rcnn==0.3.0 decorator==4.4.2 chainer==6.7.0 protobuf==3.18.0 cupy-cuda91 pytesseract==0.3.6 torch==1.4.0;" + BUILD_PKGS: 'checkerboard_detector imagesift jsk_perception jsk_recognition_utils resized_image_transport' + experimental : false + - ROS_DISTRO: noetic + USE_DEB: false + NOT_TEST_INSTALL : true + USE_JENKINS: true + DOCKER_IMAGE_JENKINS: ros-ubuntu:20.04-pcl + TEST_PKGS : 'jsk_pcl_ros_utils jsk_pcl_ros' + BEFORE_SCRIPT : "sudo pip install numpy==1.16.6; sudo pip install fcn chainercv chainer-mask-rcnn==0.3.0 decorator==4.4.2 chainer==6.7.0 protobuf==3.18.0 cupy-cuda91 pytesseract==0.3.6 torch==1.4.0;" + BUILD_PKGS: 'jsk_pcl_ros_utils jsk_pcl_ros' experimental : false - ROS_DISTRO: noetic USE_DEB: false NOT_TEST_INSTALL : true USE_JENKINS: true DOCKER_IMAGE_JENKINS: ros-ubuntu:20.04-pcl + TEST_PKGS : 'jsk_recognition_msgs' # to skip test BEFORE_SCRIPT : "sudo pip install numpy==1.16.6; sudo pip install fcn chainercv chainer-mask-rcnn==0.3.0 decorator==4.4.2 chainer==6.7.0 protobuf==3.18.0 cupy-cuda91 pytesseract==0.3.6 torch==1.4.0;" - experimental : true + experimental : false steps: From 0decc5f0efd3e5a2475a0f21f85244dcd6fda982 Mon Sep 17 00:00:00 2001 From: Kei Okada Date: Wed, 14 Dec 2022 13:18:50 +0900 Subject: [PATCH 02/29] add link from CATKIN_PACKAGE_SHARE_DESTINATION to node_scriptws/openpose --- jsk_perception/CMakeLists.txt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/jsk_perception/CMakeLists.txt b/jsk_perception/CMakeLists.txt index 310d6748b4..eea3a54c5a 100644 --- a/jsk_perception/CMakeLists.txt +++ b/jsk_perception/CMakeLists.txt @@ -447,9 +447,17 @@ catkin_install_python( PROGRAMS ${NODE_SCRIPT_PROGRAMS} DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/node_scripts ) +if(CATKIN_DEVEL_PREFIX) + add_custom_target(link_dir_mkdir + COMMAND ${CMAKE_COMMAND} -E make_directory ${CATKIN_DEVEL_PREFIX}/${CATKIN_PACKAGE_SHARE_DESTINATION}/node_scripts) + foreach(SUB_DIR craft deep_sort hmr openpose) + add_custom_target(link_dir_${SUB_DIR} ALL + COMMAND ${CMAKE_COMMAND} -E create_symlink ${PROJECT_SOURCE_DIR}/node_scripts/${SUB_DIR} ${CATKIN_DEVEL_PREFIX}/${CATKIN_PACKAGE_SHARE_DESTINATION}/node_scripts/${SUB_DIR}) + add_dependencies(link_dir_${SUB_DIR} link_dir_mkdir) + endforeach() +endif(CATKIN_DEVEL_PREFIX) endif() - # ------------------------------------------------------------------------------------ # Test # ------------------------------------------------------------------------------------ From e4495b72783c9ed3d1d559038d395df5bbbb3057 Mon Sep 17 00:00:00 2001 From: Kei Okada Date: Wed, 14 Dec 2022 13:21:17 +0900 Subject: [PATCH 03/29] add .travis.rosinstall.noetic to fix error Unsupported image format: 16UC1; compressedDepth when playing existing bagfiles, see https://github.com/ros-perception/image_transport_plugins/pull/64 --- .travis.rosinstall.noetic | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .travis.rosinstall.noetic diff --git a/.travis.rosinstall.noetic b/.travis.rosinstall.noetic new file mode 100644 index 0000000000..62d2cb6127 --- /dev/null +++ b/.travis.rosinstall.noetic @@ -0,0 +1,4 @@ +- git: # https://github.com/ros-perception/image_transport_plugins/pull/64 + uri: https://github.com/ros-perception/image_transport_plugins.git + local-name: image_transport_plugins + version: noetic-devel From af6f1ec74c87f49e10afa52e7496eb89801179fa Mon Sep 17 00:00:00 2001 From: Kei Okada Date: Thu, 15 Dec 2022 00:11:12 +0900 Subject: [PATCH 04/29] use python3-shapely for ROS_PHTHON_VERSION==3 --- jsk_recognition_utils/package.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jsk_recognition_utils/package.xml b/jsk_recognition_utils/package.xml index 237e47bf78..f749d7fe08 100644 --- a/jsk_recognition_utils/package.xml +++ b/jsk_recognition_utils/package.xml @@ -46,7 +46,8 @@ python-skimage python3-skimage python-fcn-pip - python-shapely + python-shapely + python3-shapely sensor_msgs std_msgs tf2_ros From 435626ee7865973d086181f44819ec9f19194796 Mon Sep 17 00:00:00 2001 From: Kei Okada Date: Thu, 15 Dec 2022 00:11:21 +0900 Subject: [PATCH 05/29] use pip3 for noetic --- .github/workflows/config.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/config.yml b/.github/workflows/config.yml index 14ef8de3d9..390ca24c64 100644 --- a/.github/workflows/config.yml +++ b/.github/workflows/config.yml @@ -66,7 +66,7 @@ jobs: NOT_TEST_INSTALL : true USE_JENKINS: true DOCKER_IMAGE_JENKINS: ros-ubuntu:20.04-pcl - BEFORE_SCRIPT : "sudo pip install numpy==1.16.6; sudo pip install fcn chainercv chainer-mask-rcnn==0.3.0 decorator==4.4.2 chainer==6.7.0 protobuf==3.18.0 cupy-cuda91 pytesseract==0.3.6 torch==1.4.0;" + BEFORE_SCRIPT : "sudo pip3 install numpy==1.16.6; sudo pip3 install fcn chainercv chainer-mask-rcnn==0.3.0 decorator==4.4.2 chainer==6.7.0 protobuf==3.18.0 cupy-cuda91 pytesseract==0.3.6 torch==1.4.0;" BUILD_PKGS: 'checkerboard_detector imagesift jsk_perception jsk_recognition_utils resized_image_transport' experimental : false - ROS_DISTRO: noetic @@ -75,7 +75,7 @@ jobs: USE_JENKINS: true DOCKER_IMAGE_JENKINS: ros-ubuntu:20.04-pcl TEST_PKGS : 'jsk_pcl_ros_utils jsk_pcl_ros' - BEFORE_SCRIPT : "sudo pip install numpy==1.16.6; sudo pip install fcn chainercv chainer-mask-rcnn==0.3.0 decorator==4.4.2 chainer==6.7.0 protobuf==3.18.0 cupy-cuda91 pytesseract==0.3.6 torch==1.4.0;" + BEFORE_SCRIPT : "sudo pip3 install numpy==1.16.6; sudo pip3 install fcn chainercv chainer-mask-rcnn==0.3.0 decorator==4.4.2 chainer==6.7.0 protobuf==3.18.0 cupy-cuda91 pytesseract==0.3.6 torch==1.4.0;" BUILD_PKGS: 'jsk_pcl_ros_utils jsk_pcl_ros' experimental : false - ROS_DISTRO: noetic @@ -84,7 +84,7 @@ jobs: USE_JENKINS: true DOCKER_IMAGE_JENKINS: ros-ubuntu:20.04-pcl TEST_PKGS : 'jsk_recognition_msgs' # to skip test - BEFORE_SCRIPT : "sudo pip install numpy==1.16.6; sudo pip install fcn chainercv chainer-mask-rcnn==0.3.0 decorator==4.4.2 chainer==6.7.0 protobuf==3.18.0 cupy-cuda91 pytesseract==0.3.6 torch==1.4.0;" + BEFORE_SCRIPT : "sudo pip3 install numpy==1.16.6; sudo pip3 install fcn chainercv chainer-mask-rcnn==0.3.0 decorator==4.4.2 chainer==6.7.0 protobuf==3.18.0 cupy-cuda91 pytesseract==0.3.6 torch==1.4.0;" experimental : false From 5623a6e9b3ea3547b20853f16226138b4d7fcf55 Mon Sep 17 00:00:00 2001 From: Kei Okada Date: Thu, 15 Dec 2022 13:35:27 +0900 Subject: [PATCH 06/29] sklearn_classifier, bof_histogram_extractor: update for python3, use _pickle instead of cPickle, update for scikit-learning updates --- .../node_scripts/bof_histogram_extractor.py | 22 ++++++++++++++----- .../node_scripts/sklearn_classifier.py | 11 ++++++++-- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/jsk_perception/node_scripts/bof_histogram_extractor.py b/jsk_perception/node_scripts/bof_histogram_extractor.py index 4b06167593..3c592ab19a 100755 --- a/jsk_perception/node_scripts/bof_histogram_extractor.py +++ b/jsk_perception/node_scripts/bof_histogram_extractor.py @@ -5,8 +5,12 @@ """ import gzip -import cPickle as pickle -from distutils.version import StrictVersion +import sys +if sys.version_info.major <= 2: + import cPickle as pickle +else: # for python3 + import _pickle as pickle +from distutils.version import LooseVersion from pkg_resources import get_distribution import numpy as np @@ -34,14 +38,20 @@ def __init__(self): if bof_data is None: quit() with gzip.open(bof_data, 'rb') as f: - self.bof = pickle.load(f) - if (StrictVersion(get_distribution('scikit-learn').version) >= - StrictVersion('0.17.0')): + if sys.version_info.major <= 2: + self.bof = pickle.load(f) + else: + self.bof = pickle.load(f, encoding='latin1') + if (LooseVersion(get_distribution('scikit-learn').version) >= + LooseVersion('0.17.0')): if 'n_jobs' not in self.bof.nn.__dict__ or not isinstance(self.bof.nn.n_jobs, int): # In scikit-learn>=0.17.0, # sklearn.neighbors.NearestNeighbors needs 'n_jobs' attribute. # https://github.com/jsk-ros-pkg/jsk_recognition/issues/1669 self.bof.nn.n_jobs = 1 + # noetic uses newer scikit-learn which uses n_samples_fit_ + if 'n_ssamples_fit_' not in self.bof.nn.__dict__: + self.bof.nn.n_samples_fit_ = self.bof.nn._fit_X.shape[0] self._pub = self.advertise('~output', VectorArray, queue_size=1) rospy.loginfo('Initialized BoF histogram extractor') @@ -79,7 +89,7 @@ def _apply(self, feature_msg, label_msg): decomposed = decompose_descriptors_with_label( descriptors=desc, positions=pos, label_img=label, skip_zero_label=True) - X = np.array(decomposed.values()) + X = np.array(list(decomposed.values())) if X.size == 0: return X = self.bof.transform(X) diff --git a/jsk_perception/node_scripts/sklearn_classifier.py b/jsk_perception/node_scripts/sklearn_classifier.py index e42dbef968..be3729f5c4 100755 --- a/jsk_perception/node_scripts/sklearn_classifier.py +++ b/jsk_perception/node_scripts/sklearn_classifier.py @@ -3,7 +3,11 @@ # from __future__ import division import gzip -import cPickle as pickle +import sys +if sys.version_info.major <= 2: + import cPickle as pickle +else: # for python3 + import _pickle as pickle import numpy as np from sklearn.preprocessing import normalize @@ -23,7 +27,10 @@ def __init__(self): def _init_classifier(self): clf_path = rospy.get_param('~clf_path') with gzip.open(clf_path) as f: - self.clf = pickle.load(f) + if sys.version_info.major <= 2: + self.clf = pickle.load(f) + else: + self.clf = pickle.load(f, encoding='latin1') def subscribe(self): self.sub_hist = rospy.Subscriber('~input', VectorArray, self._predict) From e3695b3d058f1591b53fbb2f43bdb74fd43952c0 Mon Sep 17 00:00:00 2001 From: Kei Okada Date: Thu, 15 Dec 2022 13:45:31 +0900 Subject: [PATCH 07/29] jsk_perception: add image_transport to test_depend --- jsk_pcl_ros/package.xml | 2 ++ jsk_perception/package.xml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/jsk_pcl_ros/package.xml b/jsk_pcl_ros/package.xml index 51635bba71..b4ef3165d4 100644 --- a/jsk_pcl_ros/package.xml +++ b/jsk_pcl_ros/package.xml @@ -91,6 +91,8 @@ visualization_msgs yaml-cpp + compressed_depth_image_transport + compressed_image_transport jsk_perception jsk_tools roslaunch diff --git a/jsk_perception/package.xml b/jsk_perception/package.xml index 9b61648d03..a4ebb03676 100644 --- a/jsk_perception/package.xml +++ b/jsk_perception/package.xml @@ -119,6 +119,8 @@ + compressed_depth_image_transport + compressed_image_transport jsk_tools roslaunch roslint From a95b0fed11026a874c42900eff0fd79580b5d855 Mon Sep 17 00:00:00 2001 From: Kei Okada Date: Thu, 15 Dec 2022 16:27:02 +0900 Subject: [PATCH 08/29] jsk_pcl_ros: add ml_classifiers_INCLUDE_DIRS to incldue_directories() --- jsk_pcl_ros/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jsk_pcl_ros/CMakeLists.txt b/jsk_pcl_ros/CMakeLists.txt index 7b7dbe9c63..c257cb7281 100644 --- a/jsk_pcl_ros/CMakeLists.txt +++ b/jsk_pcl_ros/CMakeLists.txt @@ -140,7 +140,7 @@ generate_dynamic_reconfigure_options( find_package(OpenCV REQUIRED core imgproc) -include_directories(include ${catkin_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS} ${PCL_INCLUDE_DIRS}) +include_directories(include ${catkin_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS} ${PCL_INCLUDE_DIRS} ${ml_classifiers_INCLUDE_DIRS}) link_directories(${catkin_LIBRARY_DIRS}) if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -z defs") From c2a6159c1bd0f65ce82730bc50c3095d8ae759b2 Mon Sep 17 00:00:00 2001 From: Kei Okada Date: Fri, 16 Dec 2022 12:39:23 +0900 Subject: [PATCH 09/29] use xacro instaed of xacro.py, whcih is depreceted since hydro https://github.com/ros/xacro/blob/noetic-devel/CHANGELOG.rst#183-2013-04-22 --- jsk_pcl_ros/sample/sample_incremental_model_registration.launch | 2 +- jsk_pcl_ros/sample/sample_joint_state_static_filter.launch | 2 +- jsk_perception/sample/include/play_rosbag_pr2_self_see.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/jsk_pcl_ros/sample/sample_incremental_model_registration.launch b/jsk_pcl_ros/sample/sample_incremental_model_registration.launch index a5d35e1ea8..4e43474db5 100644 --- a/jsk_pcl_ros/sample/sample_incremental_model_registration.launch +++ b/jsk_pcl_ros/sample/sample_incremental_model_registration.launch @@ -3,7 +3,7 @@ - + - + + command="$(find xacro)/xacro '$(find pr2_description)/robots/pr2.urdf.xacro'"/> From 93c194b94babcf18c6e1f3068a46918a442295cf Mon Sep 17 00:00:00 2001 From: Kei Okada Date: Fri, 16 Dec 2022 12:53:45 +0900 Subject: [PATCH 10/29] workaround until https://github.com/jsk-ros-pkg/jsk_visualization/pull/864 is merged and released. --- .../scripts/cloud_on_plane_info.py | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/jsk_pcl_ros_utils/scripts/cloud_on_plane_info.py b/jsk_pcl_ros_utils/scripts/cloud_on_plane_info.py index 818d38d66d..ce05f59536 100755 --- a/jsk_pcl_ros_utils/scripts/cloud_on_plane_info.py +++ b/jsk_pcl_ros_utils/scripts/cloud_on_plane_info.py @@ -6,6 +6,27 @@ from jsk_rviz_plugins.overlay_text_interface import OverlayTextInterface from jsk_recognition_msgs.msg import BoolStamped +# workaround until https://github.com/jsk-ros-pkg/jsk_visualization/pull/864 is merged and released. +class OverlayTextInterface_fix(OverlayTextInterface): + def publish(self, text): + msg = OverlayText() + msg.text = text + msg.width = int(self.config.width) + msg.height = int(self.config.height) + msg.top = int(self.config.top) + msg.left = int(self.config.left) + msg.fg_color.a = self.config.fg_alpha + msg.fg_color.r = self.config.fg_red + msg.fg_color.g = self.config.fg_green + msg.fg_color.b = self.config.fg_blue + msg.bg_color.a = self.config.bg_alpha + msg.bg_color.r = self.config.bg_red + msg.bg_color.g = self.config.bg_green + msg.bg_color.b = self.config.bg_blue + msg.text_size = self.config.text_size + self.pub.publish(msg) + + g_lock = Lock() g_msg = None def callback(msg): @@ -23,7 +44,7 @@ def publish_text(event): if __name__ == "__main__": rospy.init_node("cloud_on_plane_info") - text_interface = OverlayTextInterface("~text") + text_interface = OverlayTextInterface_fix("~text") sub = rospy.Subscriber("~input", BoolStamped, callback) rospy.Timer(rospy.Duration(0.1), publish_text) rospy.spin() From 18279fd7619ad8416de3a0dd25e4ba0c8ae0acf3 Mon Sep 17 00:00:00 2001 From: Kei Okada Date: Fri, 16 Dec 2022 16:23:21 +0900 Subject: [PATCH 11/29] [.github/workflows] install pytesseract==0.3.10, torchvision==0.5.0 --- .github/workflows/config.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/config.yml b/.github/workflows/config.yml index 390ca24c64..80ce5b8cee 100644 --- a/.github/workflows/config.yml +++ b/.github/workflows/config.yml @@ -66,7 +66,7 @@ jobs: NOT_TEST_INSTALL : true USE_JENKINS: true DOCKER_IMAGE_JENKINS: ros-ubuntu:20.04-pcl - BEFORE_SCRIPT : "sudo pip3 install numpy==1.16.6; sudo pip3 install fcn chainercv chainer-mask-rcnn==0.3.0 decorator==4.4.2 chainer==6.7.0 protobuf==3.18.0 cupy-cuda91 pytesseract==0.3.6 torch==1.4.0;" + BEFORE_SCRIPT : "sudo pip3 install numpy==1.16.6; sudo pip3 install fcn chainercv chainer-mask-rcnn==0.3.0 decorator==4.4.2 chainer==6.7.0 protobuf==3.18.0 cupy-cuda91 pytesseract==0.3.10 torch==1.4.0 torchvision==0.5.0;" BUILD_PKGS: 'checkerboard_detector imagesift jsk_perception jsk_recognition_utils resized_image_transport' experimental : false - ROS_DISTRO: noetic @@ -75,7 +75,7 @@ jobs: USE_JENKINS: true DOCKER_IMAGE_JENKINS: ros-ubuntu:20.04-pcl TEST_PKGS : 'jsk_pcl_ros_utils jsk_pcl_ros' - BEFORE_SCRIPT : "sudo pip3 install numpy==1.16.6; sudo pip3 install fcn chainercv chainer-mask-rcnn==0.3.0 decorator==4.4.2 chainer==6.7.0 protobuf==3.18.0 cupy-cuda91 pytesseract==0.3.6 torch==1.4.0;" + BEFORE_SCRIPT : "sudo pip3 install numpy==1.16.6; sudo pip3 install fcn chainercv chainer-mask-rcnn==0.3.0 decorator==4.4.2 chainer==6.7.0 protobuf==3.18.0 cupy-cuda91 pytesseract==0.3.10 torch==1.4.0 torchvision==0.5.0;" BUILD_PKGS: 'jsk_pcl_ros_utils jsk_pcl_ros' experimental : false - ROS_DISTRO: noetic @@ -84,7 +84,7 @@ jobs: USE_JENKINS: true DOCKER_IMAGE_JENKINS: ros-ubuntu:20.04-pcl TEST_PKGS : 'jsk_recognition_msgs' # to skip test - BEFORE_SCRIPT : "sudo pip3 install numpy==1.16.6; sudo pip3 install fcn chainercv chainer-mask-rcnn==0.3.0 decorator==4.4.2 chainer==6.7.0 protobuf==3.18.0 cupy-cuda91 pytesseract==0.3.6 torch==1.4.0;" + BEFORE_SCRIPT : "sudo pip3 install numpy==1.16.6; sudo pip3 install fcn chainercv chainer-mask-rcnn==0.3.0 decorator==4.4.2 chainer==6.7.0 protobuf==3.18.0 cupy-cuda91 pytesseract==0.3.10 torch==1.4.0 torchvision==0.5.0;" experimental : false From c013c412a82bf40abee044e305408cbf1b3b98d9 Mon Sep 17 00:00:00 2001 From: Kei Okada Date: Fri, 16 Dec 2022 16:34:46 +0900 Subject: [PATCH 12/29] fix for python3, mostly use int() for /2 and fix module name --- .../node_scripts/binpack_rect_array.py | 2 + jsk_perception/node_scripts/matchtemplate.py | 43 +++++++++-------- .../node_scripts/people_pose_estimation_2d.py | 6 +-- ...gional_feature_based_object_recognition.py | 1 + .../node_scripts/solidity_rag_merge.py | 2 + .../node_scripts/ssd_object_detector.py | 6 +-- .../sample/sample_color_histogram.launch | 3 +- jsk_perception/test/publish_mouse_event.py | 47 +++++++++++++++++++ 8 files changed, 83 insertions(+), 27 deletions(-) create mode 100755 jsk_perception/test/publish_mouse_event.py diff --git a/jsk_perception/node_scripts/binpack_rect_array.py b/jsk_perception/node_scripts/binpack_rect_array.py index d7854b9efb..21ee0fb80b 100755 --- a/jsk_perception/node_scripts/binpack_rect_array.py +++ b/jsk_perception/node_scripts/binpack_rect_array.py @@ -24,6 +24,8 @@ def width_cmp(self, another): return self.rect.width - another.rect.width def __cmp__(self, another): # python2 return self.max_cmp(another) or self.min_cmp(another) or self.height_cmp(another) or self.width_cmp(another) or 0 + def __lt__(self, another): # python3 + return self.max_cmp(another) or self.min_cmp(another) or self.height_cmp(another) or self.width_cmp(another) or 0 class Packer(): def __init__(self): diff --git a/jsk_perception/node_scripts/matchtemplate.py b/jsk_perception/node_scripts/matchtemplate.py index 0a46300e0b..432aa5dfb0 100755 --- a/jsk_perception/node_scripts/matchtemplate.py +++ b/jsk_perception/node_scripts/matchtemplate.py @@ -3,7 +3,10 @@ import roslib; roslib.load_manifest('jsk_perception') import rospy import numpy as np -import thread +try: + import thread +except: + import _thread as thread from sensor_msgs.msg import Image from geometry_msgs.msg import * from jsk_recognition_msgs.msg import Rect @@ -37,10 +40,10 @@ def _MinMaxLock2nd(arr,ex_size,is_min): if is_min: idx = 0 else: idx = 1 status = cv2.minMaxLoc(arr) - pt1 = (max(status[2+idx][0]-ex_size[0]/2,0), - max(status[2+idx][1]-ex_size[1]/2,0)) - pt2 = (min(status[2+idx][0]+ex_size[0]/2,arr.shape[1]), - min(status[2+idx][1]+ex_size[1]/2,arr.shape[0])) + pt1 = (max(status[2+idx][0]-int(ex_size[0]/2),0), + max(status[2+idx][1]-int(ex_size[1]/2),0)) + pt2 = (min(status[2+idx][0]+int(ex_size[0]/2),arr.shape[1]), + min(status[2+idx][1]+int(ex_size[1]/2),arr.shape[0])) mask = np.ones((arr.shape[0], arr.shape[1]), dtype=np.uint8) * 255 mask[pt1[0]:pt2[0], pt1[1]:pt2[1]] = 0 status2 = cv2.minMaxLoc(arr, mask) @@ -127,8 +130,8 @@ def set_template (self, ref_id='', ref_image=None, ref_rect=None, template_image = cv2.cvtColor( ref_image_rect, cv2.COLOR_BGR2HSV) - self.templates[ref_id]['ref_point'] = (ref_rect[0]+ref_rect[2]/2, - ref_rect[1]+ref_rect[3]/2) + self.templates[ref_id]['ref_point'] = (ref_rect[0]+int(ref_rect[2]/2), + ref_rect[1]+int(ref_rect[3]/2)) self.templates[ref_id]['ref_image'] = template_image rospy.loginfo("set ref_image id=%s, rect=%s", ref_id, ref_rect); @@ -160,13 +163,13 @@ def set_reference (self, rect): def set_reference_point_callback (self, msg): # PointStamped self.lockobj.acquire() pt = (int(msg.point.x),int(msg.point.y)) - rect = (pt[0]-self.default_template_size[0]/2, - pt[1]-self.default_template_size[1]/2, + rect = (pt[0]-int(self.default_template_size[0]/2), + pt[1]-int(self.default_template_size[1]/2), self.default_template_size[0], self.default_template_size[1]) self.set_reference(rect) print(rect) - search_rect = (pt[0]-self.default_search_size[0]/2, - pt[1]-self.default_search_size[1]/2, + search_rect = (pt[0]-int(self.default_search_size[0]/2), + pt[1]-int(self.default_search_size[1]/2), self.default_search_size[0],self.default_search_size[1]) self.set_template('',ser_frame=None, ser_rect=search_rect) self.lockobj.release() @@ -204,7 +207,7 @@ def reconfigure(self,config,level): (template['ref_image'] is not None): ref_pt = template['ref_point'] ref_size = template['ref_image'].shape - ref_rect = (ref_pt[0]-ref_size[0]/2,ref_pt[1]-ref_size[1]/2,ref_size[0],ref_size[1]) + ref_rect = (ref_pt[0]-int(ref_size[0]/2),ref_pt[1]-int(ref_size[1]/2),ref_size[0],ref_size[1]) self.set_template(ref_id=config['current_template_id'], color=config['template_color_space'], ref_rect=ref_rect, @@ -270,8 +273,8 @@ def ser_image_callback (self, msg): status = MaxLock2nd(results,reference_size) # maximum for others status = (1 - status[0], 1 - status[1], status[2], status[3]) - result_pt = (status[2][0]+search_rect[0]+reference_size[0]/2, - status[2][1]+search_rect[1]+reference_size[1]/2) + result_pt = (status[2][0]+search_rect[0]+int(reference_size[0]/2), + status[2][1]+search_rect[1]+int(reference_size[1]/2)) # publish center position as result result.child_frame_id = template_id @@ -291,8 +294,8 @@ def ser_image_callback (self, msg): # self feedback if self.auto_search_area: - val_x = result_pt[0]-search_rect[2]/2 - val_y = result_pt[1]-search_rect[3]/2 + val_x = result_pt[0]-int(search_rect[2]/2) + val_y = result_pt[1]-int(search_rect[3]/2) ser_scale = max(2,5+np.log(status[0])) # ??? new_ser_rect = ( min(max(val_x,0),image_size[0]-search_rect[2]), @@ -303,10 +306,10 @@ def ser_image_callback (self, msg): # draw on debug image if self.show_debug_image: cv2.rectangle(debug_image, - (result_pt[0] - reference_size[0]/2, - result_pt[1] - reference_size[1]/2), - (result_pt[0] + reference_size[0]/2, - result_pt[1] + reference_size[1]/2), + (result_pt[0] - int(reference_size[0]/2), + result_pt[1] - int(reference_size[1]/2)), + (result_pt[0] + int(reference_size[0]/2), + result_pt[1] + int(reference_size[1]/2)), color=(0, 0, 255)) # red cv2.rectangle(debug_image, (search_rect[0], search_rect[1]), diff --git a/jsk_perception/node_scripts/people_pose_estimation_2d.py b/jsk_perception/node_scripts/people_pose_estimation_2d.py index 08cd7bcc19..62b2fbe8ba 100755 --- a/jsk_perception/node_scripts/people_pose_estimation_2d.py +++ b/jsk_perception/node_scripts/people_pose_estimation_2d.py @@ -706,7 +706,7 @@ def _draw_joints(self, img, people_joint_positions, all_peaks): cv2.fillConvexPoly(roi2, polygon - np.array([left, top]), color) cv2.addWeighted(roi, 0.4, roi2, 0.6, 0.0, dst=roi) # - offset += len(self.index2handname) / 2 + offset += int(len(self.index2handname) / 2) return img @@ -812,8 +812,8 @@ def _hand_estimate_chainer_backend_each(self, hand_bgr, cx, cy, left_hand): for i, heatmap in enumerate(hmaps): conf = heatmap.max() cds = np.array(np.where(heatmap==conf)).flatten().tolist() - py = cy + cds[0] - hand_bgr.shape[0] / 2 - px = cx + cds[1] - hand_bgr.shape[1] / 2 + py = cy + cds[0] - int(hand_bgr.shape[0] / 2) + px = cx + cds[1] - int(hand_bgr.shape[1] / 2) keypoints.append({'x': px, 'y': py, 'score': conf, 'limb': self.index2handname[idx_offset+i]}) return keypoints diff --git a/jsk_perception/node_scripts/regional_feature_based_object_recognition.py b/jsk_perception/node_scripts/regional_feature_based_object_recognition.py index 0bebd48372..a7217494bb 100755 --- a/jsk_perception/node_scripts/regional_feature_based_object_recognition.py +++ b/jsk_perception/node_scripts/regional_feature_based_object_recognition.py @@ -73,6 +73,7 @@ def __init__(self): rospy.loginfo('Fitting KNN from db') db = np.load(db_file) X, y, self.target_names = db['X'], db['y'], db['target_names'] + self.target_names = np.array(list(map(lambda name: name.decode('utf-8') if hasattr(name, 'decode') else name, self.target_names))) self.knn = KNeighborsClassifier(n_neighbors=10) self.knn.fit(X, y) rospy.loginfo('Finished fitting KNN from db') diff --git a/jsk_perception/node_scripts/solidity_rag_merge.py b/jsk_perception/node_scripts/solidity_rag_merge.py index 7f343d51b1..ba5e2a2b38 100755 --- a/jsk_perception/node_scripts/solidity_rag_merge.py +++ b/jsk_perception/node_scripts/solidity_rag_merge.py @@ -39,6 +39,8 @@ def rag_solidity(labels, connectivity=2): + if LooseVersion(skimage.__version__) >= '0.16.0': + RAG.node = RAG.nodes graph = RAG() # The footprint is constructed in such a way that the first diff --git a/jsk_perception/node_scripts/ssd_object_detector.py b/jsk_perception/node_scripts/ssd_object_detector.py index e95d189f67..359568f9ae 100755 --- a/jsk_perception/node_scripts/ssd_object_detector.py +++ b/jsk_perception/node_scripts/ssd_object_detector.py @@ -186,9 +186,9 @@ def image_cb(self, msg): rect_msg = RectArray(header=msg.header) for bbox in bboxes: - rect = Rect(x=bbox[1], y=bbox[0], - width= bbox[3] - bbox[1], - height=bbox[2] - bbox[0]) + rect = Rect(x=int(bbox[1]), y=int(bbox[0]), + width= int(bbox[3] - bbox[1]), + height=int(bbox[2] - bbox[0])) rect_msg.rects.append(rect) if self.profiling: diff --git a/jsk_perception/sample/sample_color_histogram.launch b/jsk_perception/sample/sample_color_histogram.launch index b5c1fb791b..d75d2fc11c 100644 --- a/jsk_perception/sample/sample_color_histogram.launch +++ b/jsk_perception/sample/sample_color_histogram.launch @@ -24,8 +24,9 @@ use_window: $(arg gui) + + pkg="jsk_perception" type="publish_mouse_event.py"> image_width: 256 diff --git a/jsk_perception/test/publish_mouse_event.py b/jsk_perception/test/publish_mouse_event.py new file mode 100755 index 0000000000..899d505fd3 --- /dev/null +++ b/jsk_perception/test/publish_mouse_event.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# copied from image_view2 +# workaround until https://github.com/jsk-ros-pkg/jsk_common/pull/1774 is merged and released +# + +import cv2 +import numpy as np + +import rospy +from sensor_msgs.msg import Image +import cv_bridge +from image_view2.msg import MouseEvent + + +def main(): + pub_plus = rospy.Publisher('~plus_rect_event', MouseEvent, queue_size=1) + pub_minus = rospy.Publisher('~minus_rect_event', MouseEvent, queue_size=1) + + width = int(rospy.get_param('~image_width')) + height = int(rospy.get_param('~image_height')) + plus_events = [ + MouseEvent(type=3, x=int(width/4), y=int(height/4), width=width, height=height), + MouseEvent(type=4, x=int(width/2), y=int(height/2), width=width, height=height), + MouseEvent(type=2, x=int(3*width/4), y=int(3*height/4), width=width, height=height), + ] + minus_events = [ + MouseEvent(type=3, x=int(3*width/4), y=int(3*height/4), width=width, height=height), + MouseEvent(type=4, x=int(width/2), y=int(height/2), width=width, height=height), + MouseEvent(type=2, x=int(width/4), y=int(height/4), width=width, height=height), + ] + rate = rospy.Rate(10) + while not rospy.is_shutdown(): + for e in plus_events: + e.header.stamp = rospy.get_rostime() + pub_plus.publish(e) + rate.sleep() + for e in minus_events: + e.header.stamp = rospy.get_rostime() + pub_minus.publish(e) + rate.sleep() + + +if __name__ == '__main__': + rospy.init_node('publish_mouse_event') + main() From 6e07624b800d575e0f82e0548179f1b00582d117 Mon Sep 17 00:00:00 2001 From: Kei Okada Date: Fri, 16 Dec 2022 16:45:59 +0900 Subject: [PATCH 13/29] move LabelImageClassifier and VGG16ObjectRecognition to src/jsk_perception to reuse from other files --- .../alexnet_object_recognition.py | 2 +- .../node_scripts/label_image_classifier.py | 39 +---- .../probability_image_classifier.py | 2 +- .../node_scripts/vgg16_object_recognition.py | 103 +----------- jsk_perception/setup.py | 5 +- jsk_perception/src/jsk_perception/__init__.py | 0 .../jsk_perception/label_image_classifier.py | 47 ++++++ .../vgg16_object_recognition.py | 148 ++++++++++++++++++ 8 files changed, 203 insertions(+), 143 deletions(-) create mode 100644 jsk_perception/src/jsk_perception/__init__.py create mode 100644 jsk_perception/src/jsk_perception/label_image_classifier.py create mode 100644 jsk_perception/src/jsk_perception/vgg16_object_recognition.py diff --git a/jsk_perception/node_scripts/alexnet_object_recognition.py b/jsk_perception/node_scripts/alexnet_object_recognition.py index 7722715d30..73fbdd88b7 100755 --- a/jsk_perception/node_scripts/alexnet_object_recognition.py +++ b/jsk_perception/node_scripts/alexnet_object_recognition.py @@ -30,7 +30,7 @@ from jsk_recognition_utils.chainermodels import AlexNetBatchNormalization import rospy from sensor_msgs.msg import Image -from vgg16_object_recognition import VGG16ObjectRecognition +from jsk_perception.vgg16_object_recognition import VGG16ObjectRecognition class AlexNetObjectRecognition(VGG16ObjectRecognition): diff --git a/jsk_perception/node_scripts/label_image_classifier.py b/jsk_perception/node_scripts/label_image_classifier.py index 7804510b22..8494773d97 100755 --- a/jsk_perception/node_scripts/label_image_classifier.py +++ b/jsk_perception/node_scripts/label_image_classifier.py @@ -7,45 +7,8 @@ import rospy from sensor_msgs.msg import Image +from jsk_perception.label_image_classifier import LabelImageClassifier -class LabelImageClassifier(ConnectionBasedTransport): - - classifier_name = 'label_image_classifier' - - def __init__(self): - super(LabelImageClassifier, self).__init__() - self.ignore_labels = rospy.get_param('~ignore_labels', []) - self.target_names = rospy.get_param('~target_names', []) - self.pub = self.advertise( - '~output', ClassificationResult, queue_size=1) - - def subscribe(self): - self.sub = rospy.Subscriber('~input', Image, self._cb) - - def unsubscribe(self): - self.sub.unregister() - - def _cb(self, imgmsg): - bridge = cv_bridge.CvBridge() - img = bridge.imgmsg_to_cv2(imgmsg) - label, proba = self._classify(img) - msg = ClassificationResult() - msg.header = imgmsg.header - msg.labels = [label] - msg.label_names = [self.target_names[label]] - msg.label_proba = [proba[label]] - msg.probabilities = proba - msg.classifier = self.classifier_name - msg.target_names = self.target_names - self.pub.publish(msg) - - def _classify(self, label_img): - counts = np.bincount(label_img.flatten(), - minlength=len(self.target_names)) - counts[self.ignore_labels] = 0 - label = np.argmax(counts) - proba = counts.astype(np.float32) / counts.sum() - return label, proba if __name__ == '__main__': diff --git a/jsk_perception/node_scripts/probability_image_classifier.py b/jsk_perception/node_scripts/probability_image_classifier.py index 768ea81d72..65282c5199 100755 --- a/jsk_perception/node_scripts/probability_image_classifier.py +++ b/jsk_perception/node_scripts/probability_image_classifier.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -from label_image_classifier import LabelImageClassifier +from jsk_perception.label_image_classifier import LabelImageClassifier import numpy as np import rospy diff --git a/jsk_perception/node_scripts/vgg16_object_recognition.py b/jsk_perception/node_scripts/vgg16_object_recognition.py index ce29e13175..4169ecac57 100755 --- a/jsk_perception/node_scripts/vgg16_object_recognition.py +++ b/jsk_perception/node_scripts/vgg16_object_recognition.py @@ -43,109 +43,8 @@ import rospy from sensor_msgs.msg import Image +from jsk_perception.vgg16_object_recognition import VGG16ObjectRecognition -class VGG16ObjectRecognition(ConnectionBasedTransport): - - mean_bgr = np.array([104.00698793, 116.66876762, 122.67891434]) - - def __init__(self): - super(self.__class__, self).__init__() - self.insize = 224 - self.gpu = rospy.get_param('~gpu', -1) - self.target_names = rospy.get_param('~target_names') - self.model_name = rospy.get_param('~model_name') - if self.model_name == 'vgg16': - self.model = VGG16(n_class=len(self.target_names)) - elif self.model_name == 'vgg16_batch_normalization': - self.model = VGG16BatchNormalization( - n_class=len(self.target_names)) - else: - rospy.logerr('Unsupported ~model_name: {0}' - .format(self.model_name)) - model_file = rospy.get_param('~model_file') - S.load_hdf5(model_file, self.model) - if self.gpu != -1: - self.model.to_gpu(self.gpu) - self.pub = self.advertise('~output', ClassificationResult, - queue_size=1) - self.pub_input = self.advertise( - '~debug/net_input', Image, queue_size=1) - - def subscribe(self): - if rospy.get_param('~use_mask', False): - # larger buff_size is necessary for taking time callback - # http://stackoverflow.com/questions/26415699/ros-subscriber-not-up-to-date/29160379#29160379 # NOQA - sub = message_filters.Subscriber( - '~input', Image, queue_size=1, buff_size=2**24) - sub_mask = message_filters.Subscriber( - '~input/mask', Image, queue_size=1, buff_size=2**24) - self.subs = [sub, sub_mask] - queue_size = rospy.get_param('~queue_size', 10) - if rospy.get_param('~approximate_sync', False): - slop = rospy.get_param('~slop', 0.1) - sync = message_filters.ApproximateTimeSynchronizer( - self.subs, queue_size=queue_size, slop=slop) - else: - sync = message_filters.TimeSynchronizer( - self.subs, queue_size=queue_size) - sync.registerCallback(self._recognize) - else: - sub = rospy.Subscriber( - '~input', Image, self._recognize, callback_args=None, - queue_size=1, buff_size=2**24) - self.subs = [sub] - - def unsubscribe(self): - for sub in self.subs: - sub.unregister() - - def _recognize(self, imgmsg, mask_msg=None): - bridge = cv_bridge.CvBridge() - bgr = bridge.imgmsg_to_cv2(imgmsg, desired_encoding='bgr8') - if mask_msg is not None: - mask = bridge.imgmsg_to_cv2(mask_msg) - if mask.shape != bgr.shape[:2]: - logerr_throttle(10, - 'Size of input image and mask is different') - return - elif mask.size == 0: - logerr_throttle(10, 'Size of input mask is 0') - return - bgr[mask == 0] = self.mean_bgr - bgr = skimage.transform.resize( - bgr, (self.insize, self.insize), preserve_range=True) - input_msg = bridge.cv2_to_imgmsg(bgr.astype(np.uint8), encoding='bgr8') - input_msg.header = imgmsg.header - self.pub_input.publish(input_msg) - - blob = (bgr - self.mean_bgr).transpose((2, 0, 1)) - x_data = np.array([blob], dtype=np.float32) - if self.gpu != -1: - x_data = cuda.to_gpu(x_data, device=self.gpu) - if LooseVersion(chainer.__version__) < LooseVersion('2.0.0'): - x = Variable(x_data, volatile=True) - self.model.train = False - self.model(x) - else: - with chainer.using_config('train', False), \ - chainer.no_backprop_mode(): - x = Variable(x_data) - self.model(x) - - proba = cuda.to_cpu(self.model.pred.data)[0] - label = np.argmax(proba) - label_name = self.target_names[label] - label_proba = proba[label] - cls_msg = ClassificationResult( - header=imgmsg.header, - labels=[label], - label_names=[label_name], - label_proba=[label_proba], - probabilities=proba, - classifier=self.model_name, - target_names=self.target_names, - ) - self.pub.publish(cls_msg) if __name__ == '__main__': diff --git a/jsk_perception/setup.py b/jsk_perception/setup.py index 66f43a495a..b4eee0e9e8 100644 --- a/jsk_perception/setup.py +++ b/jsk_perception/setup.py @@ -3,6 +3,9 @@ from setuptools import setup from catkin_pkg.python_setup import generate_distutils_setup -d = generate_distutils_setup() +d = generate_distutils_setup( + packages=['jsk_perception'], + package_dir={'': 'src'}, +) setup(**d) diff --git a/jsk_perception/src/jsk_perception/__init__.py b/jsk_perception/src/jsk_perception/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/jsk_perception/src/jsk_perception/label_image_classifier.py b/jsk_perception/src/jsk_perception/label_image_classifier.py new file mode 100644 index 0000000000..08567fb847 --- /dev/null +++ b/jsk_perception/src/jsk_perception/label_image_classifier.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python + +import cv_bridge +from jsk_recognition_msgs.msg import ClassificationResult +from jsk_topic_tools import ConnectionBasedTransport +import numpy as np +import rospy +from sensor_msgs.msg import Image + +class LabelImageClassifier(ConnectionBasedTransport): + + classifier_name = 'label_image_classifier' + + def __init__(self): + super(LabelImageClassifier, self).__init__() + self.ignore_labels = rospy.get_param('~ignore_labels', []) + self.target_names = rospy.get_param('~target_names', []) + self.pub = self.advertise( + '~output', ClassificationResult, queue_size=1) + + def subscribe(self): + self.sub = rospy.Subscriber('~input', Image, self._cb) + + def unsubscribe(self): + self.sub.unregister() + + def _cb(self, imgmsg): + bridge = cv_bridge.CvBridge() + img = bridge.imgmsg_to_cv2(imgmsg) + label, proba = self._classify(img) + msg = ClassificationResult() + msg.header = imgmsg.header + msg.labels = [label] + msg.label_names = [self.target_names[label]] + msg.label_proba = [proba[label]] + msg.probabilities = proba + msg.classifier = self.classifier_name + msg.target_names = self.target_names + self.pub.publish(msg) + + def _classify(self, label_img): + counts = np.bincount(label_img.flatten(), + minlength=len(self.target_names)) + counts[self.ignore_labels] = 0 + label = np.argmax(counts) + proba = counts.astype(np.float32) / counts.sum() + return label, proba diff --git a/jsk_perception/src/jsk_perception/vgg16_object_recognition.py b/jsk_perception/src/jsk_perception/vgg16_object_recognition.py new file mode 100644 index 0000000000..f582daa74b --- /dev/null +++ b/jsk_perception/src/jsk_perception/vgg16_object_recognition.py @@ -0,0 +1,148 @@ +#!/usr/bin/env python + +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + + +import itertools, pkg_resources, sys +from distutils.version import LooseVersion +if LooseVersion(pkg_resources.get_distribution("chainer").version) >= LooseVersion('7.0.0') and \ + sys.version_info.major == 2: + print('''Please install chainer < 7.0.0: + + sudo pip install chainer==6.7.0 + +c.f https://github.com/jsk-ros-pkg/jsk_recognition/pull/2485 +''', file=sys.stderr) + sys.exit(1) +if [p for p in list(itertools.chain(*[pkg_resources.find_distributions(_) for _ in sys.path])) if "cupy-" in p.project_name or "cupy" == p.project_name ] == []: + print('''Please install CuPy + + sudo pip install cupy-cuda[your cuda version] +i.e. + sudo pip install cupy-cuda91 + +''', file=sys.stderr) + # sys.exit(1) +import chainer +from chainer import cuda +import chainer.serializers as S +from chainer import Variable +from distutils.version import LooseVersion +import numpy as np +import skimage.transform + +import cv_bridge +from jsk_recognition_msgs.msg import ClassificationResult +from jsk_recognition_utils.chainermodels import VGG16 +from jsk_recognition_utils.chainermodels import VGG16BatchNormalization +from jsk_topic_tools import ConnectionBasedTransport +from jsk_topic_tools.log_utils import logerr_throttle +import message_filters +import rospy +from sensor_msgs.msg import Image + + +class VGG16ObjectRecognition(ConnectionBasedTransport): + + mean_bgr = np.array([104.00698793, 116.66876762, 122.67891434]) + + def __init__(self): + super(self.__class__, self).__init__() + self.insize = 224 + self.gpu = rospy.get_param('~gpu', -1) + self.target_names = rospy.get_param('~target_names') + self.model_name = rospy.get_param('~model_name') + if self.model_name == 'vgg16': + self.model = VGG16(n_class=len(self.target_names)) + elif self.model_name == 'vgg16_batch_normalization': + self.model = VGG16BatchNormalization( + n_class=len(self.target_names)) + else: + rospy.logerr('Unsupported ~model_name: {0}' + .format(self.model_name)) + model_file = rospy.get_param('~model_file') + S.load_hdf5(model_file, self.model) + if self.gpu != -1: + self.model.to_gpu(self.gpu) + self.pub = self.advertise('~output', ClassificationResult, + queue_size=1) + self.pub_input = self.advertise( + '~debug/net_input', Image, queue_size=1) + + def subscribe(self): + if rospy.get_param('~use_mask', False): + # larger buff_size is necessary for taking time callback + # http://stackoverflow.com/questions/26415699/ros-subscriber-not-up-to-date/29160379#29160379 # NOQA + sub = message_filters.Subscriber( + '~input', Image, queue_size=1, buff_size=2**24) + sub_mask = message_filters.Subscriber( + '~input/mask', Image, queue_size=1, buff_size=2**24) + self.subs = [sub, sub_mask] + queue_size = rospy.get_param('~queue_size', 10) + if rospy.get_param('~approximate_sync', False): + slop = rospy.get_param('~slop', 0.1) + sync = message_filters.ApproximateTimeSynchronizer( + self.subs, queue_size=queue_size, slop=slop) + else: + sync = message_filters.TimeSynchronizer( + self.subs, queue_size=queue_size) + sync.registerCallback(self._recognize) + else: + sub = rospy.Subscriber( + '~input', Image, self._recognize, callback_args=None, + queue_size=1, buff_size=2**24) + self.subs = [sub] + + def unsubscribe(self): + for sub in self.subs: + sub.unregister() + + def _recognize(self, imgmsg, mask_msg=None): + bridge = cv_bridge.CvBridge() + bgr = bridge.imgmsg_to_cv2(imgmsg, desired_encoding='bgr8') + if mask_msg is not None: + mask = bridge.imgmsg_to_cv2(mask_msg) + if mask.shape != bgr.shape[:2]: + logerr_throttle(10, + 'Size of input image and mask is different') + return + elif mask.size == 0: + logerr_throttle(10, 'Size of input mask is 0') + return + bgr[mask == 0] = self.mean_bgr + bgr = skimage.transform.resize( + bgr, (self.insize, self.insize), preserve_range=True) + input_msg = bridge.cv2_to_imgmsg(bgr.astype(np.uint8), encoding='bgr8') + input_msg.header = imgmsg.header + self.pub_input.publish(input_msg) + + blob = (bgr - self.mean_bgr).transpose((2, 0, 1)) + x_data = np.array([blob], dtype=np.float32) + if self.gpu != -1: + x_data = cuda.to_gpu(x_data, device=self.gpu) + if LooseVersion(chainer.__version__) < LooseVersion('2.0.0'): + x = Variable(x_data, volatile=True) + self.model.train = False + self.model(x) + else: + with chainer.using_config('train', False), \ + chainer.no_backprop_mode(): + x = Variable(x_data) + self.model(x) + + proba = cuda.to_cpu(self.model.pred.data)[0] + label = np.argmax(proba) + label_name = self.target_names[label] + label_proba = proba[label] + cls_msg = ClassificationResult( + header=imgmsg.header, + labels=[label], + label_names=[label_name], + label_proba=[label_proba], + probabilities=proba, + classifier=self.model_name, + target_names=self.target_names, + ) + self.pub.publish(cls_msg) From c36f381b9062d0272b6978dd3c8160b4b148f79b Mon Sep 17 00:00:00 2001 From: Kei Okada Date: Sat, 17 Dec 2022 11:32:14 +0900 Subject: [PATCH 14/29] add pr2-description to noetic EXTRA_DEB --- .github/workflows/config.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/config.yml b/.github/workflows/config.yml index 80ce5b8cee..8f0a2c8b5e 100644 --- a/.github/workflows/config.yml +++ b/.github/workflows/config.yml @@ -68,6 +68,7 @@ jobs: DOCKER_IMAGE_JENKINS: ros-ubuntu:20.04-pcl BEFORE_SCRIPT : "sudo pip3 install numpy==1.16.6; sudo pip3 install fcn chainercv chainer-mask-rcnn==0.3.0 decorator==4.4.2 chainer==6.7.0 protobuf==3.18.0 cupy-cuda91 pytesseract==0.3.10 torch==1.4.0 torchvision==0.5.0;" BUILD_PKGS: 'checkerboard_detector imagesift jsk_perception jsk_recognition_utils resized_image_transport' + EXTRA_DEB: ros-noetic-pr2-description experimental : false - ROS_DISTRO: noetic USE_DEB: false @@ -77,6 +78,7 @@ jobs: TEST_PKGS : 'jsk_pcl_ros_utils jsk_pcl_ros' BEFORE_SCRIPT : "sudo pip3 install numpy==1.16.6; sudo pip3 install fcn chainercv chainer-mask-rcnn==0.3.0 decorator==4.4.2 chainer==6.7.0 protobuf==3.18.0 cupy-cuda91 pytesseract==0.3.10 torch==1.4.0 torchvision==0.5.0;" BUILD_PKGS: 'jsk_pcl_ros_utils jsk_pcl_ros' + EXTRA_DEB: ros-noetic-pr2-description experimental : false - ROS_DISTRO: noetic USE_DEB: false @@ -85,6 +87,7 @@ jobs: DOCKER_IMAGE_JENKINS: ros-ubuntu:20.04-pcl TEST_PKGS : 'jsk_recognition_msgs' # to skip test BEFORE_SCRIPT : "sudo pip3 install numpy==1.16.6; sudo pip3 install fcn chainercv chainer-mask-rcnn==0.3.0 decorator==4.4.2 chainer==6.7.0 protobuf==3.18.0 cupy-cuda91 pytesseract==0.3.10 torch==1.4.0 torchvision==0.5.0;" + EXTRA_DEB: ros-noetic-pr2-description experimental : false From 6a529010bfb8554ed801badfb87127b7fad1f5c2 Mon Sep 17 00:00:00 2001 From: Kei Okada Date: Mon, 19 Dec 2022 14:09:22 +0900 Subject: [PATCH 15/29] imagesift/test/test_imagesift.test: retry 3 --- imagesift/test/test_imagesift.test | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/imagesift/test/test_imagesift.test b/imagesift/test/test_imagesift.test index 2ca00099cf..929c19e6a5 100644 --- a/imagesift/test/test_imagesift.test +++ b/imagesift/test/test_imagesift.test @@ -6,7 +6,8 @@ + pkg="jsk_tools" type="test_topic_published.py" + retry="3"> topic_0: /Feature0D timeout_0: 10 From 508e8bdd0855869bcd825084cc6f396ec1da4cc8 Mon Sep 17 00:00:00 2001 From: Kei Okada Date: Mon, 19 Dec 2022 19:46:50 +0900 Subject: [PATCH 16/29] add retry=3 / time-limit=120 for unstable tests --- .../test_cluster_point_indices_decomposer_bbox.test | 6 +++--- jsk_pcl_ros/test/test_convex_connected_voxels.test | 3 ++- .../test_organized_statistical_outlier_removal.test | 4 ++-- jsk_perception/test/human_mesh_recovery.test | 4 ++-- jsk_perception/test/people_pose_estimation_2d.test | 10 +++++----- jsk_perception/test/ssd_object_detector.test | 2 +- jsk_perception/test/vgg16_object_recognition.test | 7 ++++--- 7 files changed, 19 insertions(+), 17 deletions(-) diff --git a/jsk_pcl_ros/test/test_cluster_point_indices_decomposer_bbox.test b/jsk_pcl_ros/test/test_cluster_point_indices_decomposer_bbox.test index eb0e57e0b7..378be8ad4e 100644 --- a/jsk_pcl_ros/test/test_cluster_point_indices_decomposer_bbox.test +++ b/jsk_pcl_ros/test/test_cluster_point_indices_decomposer_bbox.test @@ -92,7 +92,7 @@ + time-limit="30" retry="3"> check_times: 10 @@ -102,7 +102,7 @@ + time-limit="30" retry="3"> check_times: 10 @@ -112,7 +112,7 @@ + time-limit="30" retry="3"> check_times: 10 diff --git a/jsk_pcl_ros/test/test_convex_connected_voxels.test b/jsk_pcl_ros/test/test_convex_connected_voxels.test index 6f632d3796..e22143f7d6 100644 --- a/jsk_pcl_ros/test/test_convex_connected_voxels.test +++ b/jsk_pcl_ros/test/test_convex_connected_voxels.test @@ -12,7 +12,8 @@ + pkg="jsk_tools" type="test_topic_published.py" + retry="3" time-limit="120"> topic_0: /sample_convex_connected_voxels/output/indices timeout_0: 100 diff --git a/jsk_pcl_ros/test/test_organized_statistical_outlier_removal.test b/jsk_pcl_ros/test/test_organized_statistical_outlier_removal.test index bd3a095e4d..38549c3fb0 100644 --- a/jsk_pcl_ros/test/test_organized_statistical_outlier_removal.test +++ b/jsk_pcl_ros/test/test_organized_statistical_outlier_removal.test @@ -7,10 +7,10 @@ + retry="3" time-limit="120"> topic_0: /statistical_outlier_removal/output - timeout_0: 30 + timeout_0: 100 diff --git a/jsk_perception/test/human_mesh_recovery.test b/jsk_perception/test/human_mesh_recovery.test index e59a9acf20..1992a43d0b 100644 --- a/jsk_perception/test/human_mesh_recovery.test +++ b/jsk_perception/test/human_mesh_recovery.test @@ -7,10 +7,10 @@ + retry="3" time-limit="120"> topic_0: /human_mesh_recovery/output/pose - timeout_0: 60 + timeout_0: 100 diff --git a/jsk_perception/test/people_pose_estimation_2d.test b/jsk_perception/test/people_pose_estimation_2d.test index 5fcd015d13..af4fc84494 100644 --- a/jsk_perception/test/people_pose_estimation_2d.test +++ b/jsk_perception/test/people_pose_estimation_2d.test @@ -7,16 +7,16 @@ + retry="3" time-limit="120"> topic_0: /people_pose_estimation_2d/output - timeout_0: 60 + timeout_0: 120 topic_1: /people_pose_estimation_2d/pose - timeout_1: 60 + timeout_1: 120 topic_2: /people_pose_estimation_2d/pose_2d - timeout_2: 60 + timeout_2: 120 topic_3: /people_pose_estimation_2d/skeleton - timeout_3: 60 + timeout_3: 120 diff --git a/jsk_perception/test/ssd_object_detector.test b/jsk_perception/test/ssd_object_detector.test index 24992e14ac..a23ce97b05 100644 --- a/jsk_perception/test/ssd_object_detector.test +++ b/jsk_perception/test/ssd_object_detector.test @@ -5,7 +5,7 @@ + retry="3" time-limit="120" > topic_0: /ssd_object_detector/output/image timeout_0: 120 diff --git a/jsk_perception/test/vgg16_object_recognition.test b/jsk_perception/test/vgg16_object_recognition.test index 7da18e04ce..9471b6cc2b 100644 --- a/jsk_perception/test/vgg16_object_recognition.test +++ b/jsk_perception/test/vgg16_object_recognition.test @@ -7,12 +7,13 @@ + pkg="jsk_tools" type="test_topic_published.py" + retry="3" time-limit="120" > topic_0: /vgg16_object_recognition/output - timeout_0: 30 + timeout_0: 120 topic_1: /vgg16_object_recognition/debug/net_input - timeout_1: 30 + timeout_1: 120 From fd74f0698271382b5f3eebc7d2cb7c8738108373 Mon Sep 17 00:00:00 2001 From: Kei Okada Date: Tue, 20 Dec 2022 08:11:36 +0000 Subject: [PATCH 17/29] jsk_recognition_msgs: fix opposit conditon for catkin_insta_python --- jsk_recognition_msgs/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jsk_recognition_msgs/CMakeLists.txt b/jsk_recognition_msgs/CMakeLists.txt index 116018c0b2..8407f01bfe 100644 --- a/jsk_recognition_msgs/CMakeLists.txt +++ b/jsk_recognition_msgs/CMakeLists.txt @@ -133,7 +133,7 @@ install(DIRECTORY sample USE_SOURCE_PERMISSIONS ) -if(NOT $ENV{ROS_DISTRO} STREQUAL "indigo") # on noetic it needs catkin_install_python to support Python3 and it does not work on indigo for some reason... +if($ENV{ROS_DISTRO} STREQUAL "indigo") # on noetic it needs catkin_install_python to support Python3 and it does not work on indigo for some reason... install(DIRECTORY scripts DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} USE_SOURCE_PERMISSIONS From 1bf1c2f91ffebbe8091eeca3aa120a217a3de58e Mon Sep 17 00:00:00 2001 From: Kei Okada Date: Wed, 21 Dec 2022 07:51:15 +0000 Subject: [PATCH 18/29] .github/workflow/config.yml: specify scipy/scikit-image version --- .github/workflows/config.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/config.yml b/.github/workflows/config.yml index 8f0a2c8b5e..651e4da1e7 100644 --- a/.github/workflows/config.yml +++ b/.github/workflows/config.yml @@ -66,7 +66,7 @@ jobs: NOT_TEST_INSTALL : true USE_JENKINS: true DOCKER_IMAGE_JENKINS: ros-ubuntu:20.04-pcl - BEFORE_SCRIPT : "sudo pip3 install numpy==1.16.6; sudo pip3 install fcn chainercv chainer-mask-rcnn==0.3.0 decorator==4.4.2 chainer==6.7.0 protobuf==3.18.0 cupy-cuda91 pytesseract==0.3.10 torch==1.4.0 torchvision==0.5.0;" + BEFORE_SCRIPT : "sudo pip3 install numpy==1.16.6 scipy==1.3.3 scikit-image==0.16.2 PyWavelets==0.5.1 imageio==2.4.1 pandas==0.25.3; sudo pip3 install fcn chainercv chainer-mask-rcnn==0.3.0 decorator==4.4.2 chainer==7.8.1 protobuf==3.6.1 cupy-cuda91 pytesseract==0.3.10 Pillow==9.3.0 torch==1.4.0 torchvision==0.5.0;" BUILD_PKGS: 'checkerboard_detector imagesift jsk_perception jsk_recognition_utils resized_image_transport' EXTRA_DEB: ros-noetic-pr2-description experimental : false @@ -76,7 +76,7 @@ jobs: USE_JENKINS: true DOCKER_IMAGE_JENKINS: ros-ubuntu:20.04-pcl TEST_PKGS : 'jsk_pcl_ros_utils jsk_pcl_ros' - BEFORE_SCRIPT : "sudo pip3 install numpy==1.16.6; sudo pip3 install fcn chainercv chainer-mask-rcnn==0.3.0 decorator==4.4.2 chainer==6.7.0 protobuf==3.18.0 cupy-cuda91 pytesseract==0.3.10 torch==1.4.0 torchvision==0.5.0;" + BEFORE_SCRIPT : "sudo pip3 install numpy==1.16.6 scipy==1.3.3 scikit-image==0.16.2 PyWavelets==0.5.1 imageio==2.4.1 pandas==0.25.3; sudo pip3 install fcn chainercv chainer-mask-rcnn==0.3.0 decorator==4.4.2 chainer==7.8.1 protobuf==3.6.1 cupy-cuda91 pytesseract==0.3.10 Pillow==9.3.0 torch==1.4.0 torchvision==0.5.0;" BUILD_PKGS: 'jsk_pcl_ros_utils jsk_pcl_ros' EXTRA_DEB: ros-noetic-pr2-description experimental : false @@ -86,7 +86,7 @@ jobs: USE_JENKINS: true DOCKER_IMAGE_JENKINS: ros-ubuntu:20.04-pcl TEST_PKGS : 'jsk_recognition_msgs' # to skip test - BEFORE_SCRIPT : "sudo pip3 install numpy==1.16.6; sudo pip3 install fcn chainercv chainer-mask-rcnn==0.3.0 decorator==4.4.2 chainer==6.7.0 protobuf==3.18.0 cupy-cuda91 pytesseract==0.3.10 torch==1.4.0 torchvision==0.5.0;" + BEFORE_SCRIPT : "sudo pip3 install numpy==1.16.6 scipy==1.3.3 scikit-image==0.16.2 PyWavelets==0.5.1 imageio==2.4.1 pandas==0.25.3; sudo pip3 install fcn chainercv chainer-mask-rcnn==0.3.0 decorator==4.4.2 chainer==7.8.1 protobuf==3.6.1 cupy-cuda91 pytesseract==0.3.10 Pillow==9.3.0 torch==1.4.0 torchvision==0.5.0;" EXTRA_DEB: ros-noetic-pr2-description experimental : false From edcc7dea2c495a34ccca0a5e388e9de50d913851 Mon Sep 17 00:00:00 2001 From: Kei Okada Date: Thu, 22 Dec 2022 10:24:29 +0900 Subject: [PATCH 19/29] run test_organized_statistical_outlier_removal.test with RATE==0.25 --- .../sample/include/play_rosbag_baxter_realsense_l515.xml | 3 ++- .../sample/sample_organized_statistical_outlier_removal.launch | 2 ++ .../test/test_organized_statistical_outlier_removal.test | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/jsk_pcl_ros/sample/include/play_rosbag_baxter_realsense_l515.xml b/jsk_pcl_ros/sample/include/play_rosbag_baxter_realsense_l515.xml index b77e1cb643..f88073eacd 100644 --- a/jsk_pcl_ros/sample/include/play_rosbag_baxter_realsense_l515.xml +++ b/jsk_pcl_ros/sample/include/play_rosbag_baxter_realsense_l515.xml @@ -6,11 +6,12 @@ + + args="--rate $(arg RATE) $(find jsk_pcl_ros)/sample/data/baxter_realsense_l515.bag --clock --loop"/> diff --git a/jsk_pcl_ros/sample/sample_organized_statistical_outlier_removal.launch b/jsk_pcl_ros/sample/sample_organized_statistical_outlier_removal.launch index 4ae2a0a164..b9618465b7 100644 --- a/jsk_pcl_ros/sample/sample_organized_statistical_outlier_removal.launch +++ b/jsk_pcl_ros/sample/sample_organized_statistical_outlier_removal.launch @@ -1,9 +1,11 @@ + + diff --git a/jsk_pcl_ros/test/test_organized_statistical_outlier_removal.test b/jsk_pcl_ros/test/test_organized_statistical_outlier_removal.test index 38549c3fb0..56519753ae 100644 --- a/jsk_pcl_ros/test/test_organized_statistical_outlier_removal.test +++ b/jsk_pcl_ros/test/test_organized_statistical_outlier_removal.test @@ -2,6 +2,7 @@ + Date: Thu, 22 Dec 2022 09:34:06 +0000 Subject: [PATCH 20/29] increase unstable tests --- .../test/apply_context_to_label_probability.test | 6 +++--- jsk_perception/test/deep_sort_tracker.test | 6 +++--- jsk_perception/test/face_pose_estimation.test | 8 ++++---- jsk_perception/test/fcn_object_segmentation.test | 4 ++-- jsk_perception/test/label_image_classifier.test | 4 ++-- jsk_perception/test/probability_image_classifier.test | 4 ++-- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/jsk_perception/test/apply_context_to_label_probability.test b/jsk_perception/test/apply_context_to_label_probability.test index 301f2c8348..8629c18214 100644 --- a/jsk_perception/test/apply_context_to_label_probability.test +++ b/jsk_perception/test/apply_context_to_label_probability.test @@ -8,12 +8,12 @@ + retry="3" time-limit="120"> topic_0: /apply_context_to_label_probability/output - timeout_0: 60 + timeout_0: 120 topic_1: /apply_context_to_label_probability/output/label - timeout_1: 60 + timeout_1: 120 diff --git a/jsk_perception/test/deep_sort_tracker.test b/jsk_perception/test/deep_sort_tracker.test index a421e64707..a12d814fd8 100644 --- a/jsk_perception/test/deep_sort_tracker.test +++ b/jsk_perception/test/deep_sort_tracker.test @@ -8,12 +8,12 @@ + retry="3" time-limit="120"> topic_0: /deep_sort_tracker/output/viz - timeout_0: 60 + timeout_0: 120 topic_1: /deep_sort_tracker/output/labels - timeout_1: 60 + timeout_1: 120 diff --git a/jsk_perception/test/face_pose_estimation.test b/jsk_perception/test/face_pose_estimation.test index 35d8e6d5b9..ebb24ce560 100644 --- a/jsk_perception/test/face_pose_estimation.test +++ b/jsk_perception/test/face_pose_estimation.test @@ -7,14 +7,14 @@ + retry="3" time-limit="120"> topic_0: /face_pose_estimation/output/rects - timeout_0: 60 + timeout_0: 120 topic_1: /face_pose_estimation/output/pose - timeout_1: 60 + timeout_1: 120 topic_2: /face_pose_estimation/output/gender - timeout_2: 60 + timeout_2: 120 diff --git a/jsk_perception/test/fcn_object_segmentation.test b/jsk_perception/test/fcn_object_segmentation.test index dd65968f1e..5baa01ef36 100644 --- a/jsk_perception/test/fcn_object_segmentation.test +++ b/jsk_perception/test/fcn_object_segmentation.test @@ -11,10 +11,10 @@ + retry="3" time-limit="120"> topic_0: /fcn_object_segmentation/output - timeout_0: 60 + timeout_0: 120 diff --git a/jsk_perception/test/label_image_classifier.test b/jsk_perception/test/label_image_classifier.test index ba37c915b7..c4e476bf14 100644 --- a/jsk_perception/test/label_image_classifier.test +++ b/jsk_perception/test/label_image_classifier.test @@ -9,10 +9,10 @@ + retry="3" time-limit="120"> topic_0: /label_image_classifier/output - timeout_0: 60 + timeout_0: 120 diff --git a/jsk_perception/test/probability_image_classifier.test b/jsk_perception/test/probability_image_classifier.test index 71cb98c7c5..8f25ae32db 100644 --- a/jsk_perception/test/probability_image_classifier.test +++ b/jsk_perception/test/probability_image_classifier.test @@ -9,10 +9,10 @@ + retry="3" time-limit="120"> topic_0: /probability_image_classifier/output - timeout_0: 60 + timeout_0: 120 From ff4c296178abe44d7dd7814163077ecd145407e6 Mon Sep 17 00:00:00 2001 From: Kei Okada Date: Fri, 23 Dec 2022 01:34:33 +0000 Subject: [PATCH 21/29] jsk_perception/node_scripts/bof_histogram_extractor.py: with LooseVersion we need to use >= 0.17 instead of >= 0.17.0 --- jsk_perception/node_scripts/bof_histogram_extractor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jsk_perception/node_scripts/bof_histogram_extractor.py b/jsk_perception/node_scripts/bof_histogram_extractor.py index 3c592ab19a..e8ccb05186 100755 --- a/jsk_perception/node_scripts/bof_histogram_extractor.py +++ b/jsk_perception/node_scripts/bof_histogram_extractor.py @@ -43,7 +43,7 @@ def __init__(self): else: self.bof = pickle.load(f, encoding='latin1') if (LooseVersion(get_distribution('scikit-learn').version) >= - LooseVersion('0.17.0')): + LooseVersion('0.17')): if 'n_jobs' not in self.bof.nn.__dict__ or not isinstance(self.bof.nn.n_jobs, int): # In scikit-learn>=0.17.0, # sklearn.neighbors.NearestNeighbors needs 'n_jobs' attribute. From f9d2d8f1112eb046bfc069c352b8a7b9f6cbfa4d Mon Sep 17 00:00:00 2001 From: Kei Okada Date: Sat, 24 Dec 2022 15:45:30 +0900 Subject: [PATCH 22/29] use numpy==1.17.5 for noetic --- .github/workflows/config.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/config.yml b/.github/workflows/config.yml index 651e4da1e7..b5389a86b1 100644 --- a/.github/workflows/config.yml +++ b/.github/workflows/config.yml @@ -66,7 +66,7 @@ jobs: NOT_TEST_INSTALL : true USE_JENKINS: true DOCKER_IMAGE_JENKINS: ros-ubuntu:20.04-pcl - BEFORE_SCRIPT : "sudo pip3 install numpy==1.16.6 scipy==1.3.3 scikit-image==0.16.2 PyWavelets==0.5.1 imageio==2.4.1 pandas==0.25.3; sudo pip3 install fcn chainercv chainer-mask-rcnn==0.3.0 decorator==4.4.2 chainer==7.8.1 protobuf==3.6.1 cupy-cuda91 pytesseract==0.3.10 Pillow==9.3.0 torch==1.4.0 torchvision==0.5.0;" + BEFORE_SCRIPT : "sudo pip3 install numpy==1.17.5 scipy==1.3.3 scikit-image==0.16.2 PyWavelets==0.5.1 imageio==2.4.1 pandas==0.25.3; sudo pip3 install fcn chainercv chainer-mask-rcnn==0.3.0 decorator==4.4.2 chainer==7.8.1 protobuf==3.6.1 cupy-cuda91 pytesseract==0.3.10 Pillow==9.3.0 torch==1.4.0 torchvision==0.5.0;" BUILD_PKGS: 'checkerboard_detector imagesift jsk_perception jsk_recognition_utils resized_image_transport' EXTRA_DEB: ros-noetic-pr2-description experimental : false @@ -76,7 +76,7 @@ jobs: USE_JENKINS: true DOCKER_IMAGE_JENKINS: ros-ubuntu:20.04-pcl TEST_PKGS : 'jsk_pcl_ros_utils jsk_pcl_ros' - BEFORE_SCRIPT : "sudo pip3 install numpy==1.16.6 scipy==1.3.3 scikit-image==0.16.2 PyWavelets==0.5.1 imageio==2.4.1 pandas==0.25.3; sudo pip3 install fcn chainercv chainer-mask-rcnn==0.3.0 decorator==4.4.2 chainer==7.8.1 protobuf==3.6.1 cupy-cuda91 pytesseract==0.3.10 Pillow==9.3.0 torch==1.4.0 torchvision==0.5.0;" + BEFORE_SCRIPT : "sudo pip3 install numpy==1.17.5 scipy==1.3.3 scikit-image==0.16.2 PyWavelets==0.5.1 imageio==2.4.1 pandas==0.25.3; sudo pip3 install fcn chainercv chainer-mask-rcnn==0.3.0 decorator==4.4.2 chainer==7.8.1 protobuf==3.6.1 cupy-cuda91 pytesseract==0.3.10 Pillow==9.3.0 torch==1.4.0 torchvision==0.5.0;" BUILD_PKGS: 'jsk_pcl_ros_utils jsk_pcl_ros' EXTRA_DEB: ros-noetic-pr2-description experimental : false @@ -86,7 +86,7 @@ jobs: USE_JENKINS: true DOCKER_IMAGE_JENKINS: ros-ubuntu:20.04-pcl TEST_PKGS : 'jsk_recognition_msgs' # to skip test - BEFORE_SCRIPT : "sudo pip3 install numpy==1.16.6 scipy==1.3.3 scikit-image==0.16.2 PyWavelets==0.5.1 imageio==2.4.1 pandas==0.25.3; sudo pip3 install fcn chainercv chainer-mask-rcnn==0.3.0 decorator==4.4.2 chainer==7.8.1 protobuf==3.6.1 cupy-cuda91 pytesseract==0.3.10 Pillow==9.3.0 torch==1.4.0 torchvision==0.5.0;" + BEFORE_SCRIPT : "sudo pip3 install numpy==1.17.5 scipy==1.3.3 scikit-image==0.16.2 PyWavelets==0.5.1 imageio==2.4.1 pandas==0.25.3; sudo pip3 install fcn chainercv chainer-mask-rcnn==0.3.0 decorator==4.4.2 chainer==7.8.1 protobuf==3.6.1 cupy-cuda91 pytesseract==0.3.10 Pillow==9.3.0 torch==1.4.0 torchvision==0.5.0;" EXTRA_DEB: ros-noetic-pr2-description experimental : false From 272b3d1eb751e469a0301572d26482657bfa7aac Mon Sep 17 00:00:00 2001 From: Kei Okada Date: Mon, 26 Dec 2022 07:18:36 +0000 Subject: [PATCH 23/29] jsk_pcl_ros/CMakeLists.txt use catkin_install_python() --- jsk_pcl_ros/CMakeLists.txt | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/jsk_pcl_ros/CMakeLists.txt b/jsk_pcl_ros/CMakeLists.txt index c257cb7281..0076d779f3 100644 --- a/jsk_pcl_ros/CMakeLists.txt +++ b/jsk_pcl_ros/CMakeLists.txt @@ -505,10 +505,34 @@ install(TARGETS ${jsk_pcl_ros_install_libraries} LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} ) -install(DIRECTORY config euslisp launch plugins sample scripts test +install(DIRECTORY config euslisp launch plugins test DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} USE_SOURCE_PERMISSIONS ) +if($ENV{ROS_DISTRO} STREQUAL "indigo") # on noetic it needs catkin_install_python to support Python3 and it does not work on indigo for some reason... +install(DIRECTORY sample scripts + DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} + USE_SOURCE_PERMISSIONS + ) +else() +install(DIRECTORY sample scripts + DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} + USE_SOURCE_PERMISSIONS + PATTERN "*" + PATTERN "*/*.py" EXCLUDE +) + +file(GLOB SCRIPT_PROGRAMS scripts/*.py) +catkin_install_python( + PROGRAMS ${SCRIPT_PROGRAMS} + DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/scripts +) +file(GLOB SAMPLE_SCRIPT_PROGRAMS sample/*.py) +catkin_install_python( + PROGRAMS ${SAMPLE_SCRIPT_PROGRAMS} + DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/sample +) +endif() if (CATKIN_ENABLE_TESTING) find_package(jsk_perception REQUIRED) From 5718b38a161407c9f86fc15aa90f82161692a7e4 Mon Sep 17 00:00:00 2001 From: Kei Okada Date: Tue, 27 Dec 2022 04:59:15 +0000 Subject: [PATCH 24/29] jsk_pcl_ros/scripts/check_depth_error/depth_error_calibration.py: use // instead of / for pytohn3 --- .../scripts/check_depth_error/depth_error_calibration.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jsk_pcl_ros/scripts/check_depth_error/depth_error_calibration.py b/jsk_pcl_ros/scripts/check_depth_error/depth_error_calibration.py index 5e464e0745..f18e6d01f0 100755 --- a/jsk_pcl_ros/scripts/check_depth_error/depth_error_calibration.py +++ b/jsk_pcl_ros/scripts/check_depth_error/depth_error_calibration.py @@ -348,7 +348,7 @@ def updatePlot(): def generateFrequencyMap(): global width, height # bgr - img = np.tile(np.uint8([0,0,0]), (height / 10, width / 10, 1)) + img = np.tile(np.uint8([0,0,0]), (height // 10, width // 10, 1)) frequency = dict() for (u, v) in value_cache.keys(): min_color = np.uint8([255, 0, 0]) From 4152a70729699124cfee48d30631d66e37defcb8 Mon Sep 17 00:00:00 2001 From: Kei Okada Date: Tue, 27 Dec 2022 05:05:43 +0000 Subject: [PATCH 25/29] jsk_perception/CMakeLists.txt jsk_python_setup works on indigo --- jsk_perception/CMakeLists.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/jsk_perception/CMakeLists.txt b/jsk_perception/CMakeLists.txt index eea3a54c5a..af6d2449f6 100644 --- a/jsk_perception/CMakeLists.txt +++ b/jsk_perception/CMakeLists.txt @@ -41,9 +41,7 @@ find_package(catkin REQUIRED COMPONENTS find_package(roseus) -if(NOT $ENV{ROS_DISTRO} STREQUAL "indigo") # on noetic it needs catkin_install_python to support Python3 and it does not work on indigo for some reason... - catkin_python_setup() -endif() +catkin_python_setup() find_package(Boost REQUIRED COMPONENTS filesystem system) From b24c1b030c6a041a5863df280f925e54e40dc036 Mon Sep 17 00:00:00 2001 From: Kei Okada Date: Thu, 5 Jan 2023 19:12:13 +0900 Subject: [PATCH 26/29] noetic: install libpcl-features1.10, which is re-build debian package with https://github.com/PointCloudLibrary/pcl/pull/3623 patch --- .github/workflows/config.yml | 6 +++--- jsk_perception/test/fcn_object_segmentation.test | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/config.yml b/.github/workflows/config.yml index b5389a86b1..7d7abc3bb0 100644 --- a/.github/workflows/config.yml +++ b/.github/workflows/config.yml @@ -66,7 +66,7 @@ jobs: NOT_TEST_INSTALL : true USE_JENKINS: true DOCKER_IMAGE_JENKINS: ros-ubuntu:20.04-pcl - BEFORE_SCRIPT : "sudo pip3 install numpy==1.17.5 scipy==1.3.3 scikit-image==0.16.2 PyWavelets==0.5.1 imageio==2.4.1 pandas==0.25.3; sudo pip3 install fcn chainercv chainer-mask-rcnn==0.3.0 decorator==4.4.2 chainer==7.8.1 protobuf==3.6.1 cupy-cuda91 pytesseract==0.3.10 Pillow==9.3.0 torch==1.4.0 torchvision==0.5.0;" + BEFORE_SCRIPT : "sudo pip3 install numpy==1.17.5 scipy==1.3.3 scikit-image==0.16.2 PyWavelets==0.5.1 imageio==2.4.1 pandas==0.25.3; sudo pip3 install fcn chainercv chainer-mask-rcnn==0.3.0 decorator==4.4.2 chainer==7.8.1 protobuf==3.6.1 cupy-cuda91 pytesseract==0.3.10 Pillow==9.3.0 torch==1.4.0 torchvision==0.5.0;sudo dpkg -i /workspace/.ros/data/libpcl-features1.10_1.10.0+dfsg-5ubuntu1_amd64.deb;" BUILD_PKGS: 'checkerboard_detector imagesift jsk_perception jsk_recognition_utils resized_image_transport' EXTRA_DEB: ros-noetic-pr2-description experimental : false @@ -76,7 +76,7 @@ jobs: USE_JENKINS: true DOCKER_IMAGE_JENKINS: ros-ubuntu:20.04-pcl TEST_PKGS : 'jsk_pcl_ros_utils jsk_pcl_ros' - BEFORE_SCRIPT : "sudo pip3 install numpy==1.17.5 scipy==1.3.3 scikit-image==0.16.2 PyWavelets==0.5.1 imageio==2.4.1 pandas==0.25.3; sudo pip3 install fcn chainercv chainer-mask-rcnn==0.3.0 decorator==4.4.2 chainer==7.8.1 protobuf==3.6.1 cupy-cuda91 pytesseract==0.3.10 Pillow==9.3.0 torch==1.4.0 torchvision==0.5.0;" + BEFORE_SCRIPT : "sudo pip3 install numpy==1.17.5 scipy==1.3.3 scikit-image==0.16.2 PyWavelets==0.5.1 imageio==2.4.1 pandas==0.25.3; sudo pip3 install fcn chainercv chainer-mask-rcnn==0.3.0 decorator==4.4.2 chainer==7.8.1 protobuf==3.6.1 cupy-cuda91 pytesseract==0.3.10 Pillow==9.3.0 torch==1.4.0 torchvision==0.5.0;sudo dpkg -i /workspace/.ros/data/libpcl-features1.10_1.10.0+dfsg-5ubuntu1_amd64.deb;" BUILD_PKGS: 'jsk_pcl_ros_utils jsk_pcl_ros' EXTRA_DEB: ros-noetic-pr2-description experimental : false @@ -86,7 +86,7 @@ jobs: USE_JENKINS: true DOCKER_IMAGE_JENKINS: ros-ubuntu:20.04-pcl TEST_PKGS : 'jsk_recognition_msgs' # to skip test - BEFORE_SCRIPT : "sudo pip3 install numpy==1.17.5 scipy==1.3.3 scikit-image==0.16.2 PyWavelets==0.5.1 imageio==2.4.1 pandas==0.25.3; sudo pip3 install fcn chainercv chainer-mask-rcnn==0.3.0 decorator==4.4.2 chainer==7.8.1 protobuf==3.6.1 cupy-cuda91 pytesseract==0.3.10 Pillow==9.3.0 torch==1.4.0 torchvision==0.5.0;" + BEFORE_SCRIPT : "sudo pip3 install numpy==1.17.5 scipy==1.3.3 scikit-image==0.16.2 PyWavelets==0.5.1 imageio==2.4.1 pandas==0.25.3; sudo pip3 install fcn chainercv chainer-mask-rcnn==0.3.0 decorator==4.4.2 chainer==7.8.1 protobuf==3.6.1 cupy-cuda91 pytesseract==0.3.10 Pillow==9.3.0 torch==1.4.0 torchvision==0.5.0;sudo dpkg -i /workspace/.ros/data/libpcl-features1.10_1.10.0+dfsg-5ubuntu1_amd64.deb;" EXTRA_DEB: ros-noetic-pr2-description experimental : false diff --git a/jsk_perception/test/fcn_object_segmentation.test b/jsk_perception/test/fcn_object_segmentation.test index 5baa01ef36..c7571d8e1c 100644 --- a/jsk_perception/test/fcn_object_segmentation.test +++ b/jsk_perception/test/fcn_object_segmentation.test @@ -11,7 +11,7 @@ + time-limit="120"> topic_0: /fcn_object_segmentation/output timeout_0: 120 From d25bb2b5b1ad82bd4a4efd3b25483acf68233e59 Mon Sep 17 00:00:00 2001 From: Kei Okada Date: Mon, 9 Jan 2023 12:48:04 +0900 Subject: [PATCH 27/29] jsk_perception/test/tile_image.test: fix eng name=DISPLAY -> arg name=gui --- jsk_perception/test/tile_image.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jsk_perception/test/tile_image.test b/jsk_perception/test/tile_image.test index 73a211d0d1..6996c73781 100644 --- a/jsk_perception/test/tile_image.test +++ b/jsk_perception/test/tile_image.test @@ -1,7 +1,7 @@ - + Date: Fri, 13 Jan 2023 13:09:42 +0900 Subject: [PATCH 28/29] lock startRegistration to protect samples_check if samples_ --- jsk_pcl_ros/src/incremental_model_registration_nodelet.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/jsk_pcl_ros/src/incremental_model_registration_nodelet.cpp b/jsk_pcl_ros/src/incremental_model_registration_nodelet.cpp index 8999bbd05b..e8dd20e319 100644 --- a/jsk_pcl_ros/src/incremental_model_registration_nodelet.cpp +++ b/jsk_pcl_ros/src/incremental_model_registration_nodelet.cpp @@ -207,6 +207,7 @@ namespace jsk_pcl_ros std_srvs::Empty::Request& req, std_srvs::Empty::Response& res) { + boost::mutex::scoped_lock lock(mutex_); if (samples_.size() <= 1) { ROS_ERROR("no enough samples"); return false; From bcdc802b35d2b4c348ead848547f8c734ec26f37 Mon Sep 17 00:00:00 2001 From: Kei Okada Date: Mon, 16 Jan 2023 12:37:28 +0000 Subject: [PATCH 29/29] jsk_pcl_ros/src/incremental_model_registration_nodelet.cpp: startRegistration return true --- jsk_pcl_ros/src/incremental_model_registration_nodelet.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/jsk_pcl_ros/src/incremental_model_registration_nodelet.cpp b/jsk_pcl_ros/src/incremental_model_registration_nodelet.cpp index e8dd20e319..abb16d9b84 100644 --- a/jsk_pcl_ros/src/incremental_model_registration_nodelet.cpp +++ b/jsk_pcl_ros/src/incremental_model_registration_nodelet.cpp @@ -252,6 +252,7 @@ namespace jsk_pcl_ros nonregistered_ros_cloud.header.stamp = ros::Time::now(); nonregistered_ros_cloud.header.frame_id = frame_id_; pub_cloud_non_registered_.publish(nonregistered_ros_cloud); + return true; } }