ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
2

Lower Kinect resolution for RGB/Camera using openni_launch

asked 2013-02-19 11:27:52 -0500

Tadhg Fitzgerald gravatar image

updated 2016-10-24 08:34:33 -0500

ngrennan gravatar image

Is there any way of lower the Kinect RGB image resolution from 640 * 480 to 320 * 240 when using the openni_launch package? I know it can be done in the openni_camera launch file by changing the image mode but I cant use this because depth doesn't show when I do for some reason. The reason I need to lower it is because I'm using cv_bridge to opencv but with the higer resolution this part runs unacceptably slowly.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
9

answered 2013-02-19 11:35:13 -0500

dbworth gravatar image

updated 2013-02-20 01:06:59 -0500

Have a look for information about ROS Dynamic Reconfigure. That allows you to change the resolution on-the-fly. Look at the params under the openni driver node.

Once you have found the parameter, you should be able to set it in a launch file like any other ROS Param.


Edit: I needed to test this myself...

Firstly test the supported parameters by changing them on the fly and viewing the output in Rviz:

$ rosrun dynamic_reconfigure reconfigure_gui

and selecting the node:
{your_kinect_camera_name}/driver

The ASUS/PrimeSense supports at least:

  image_mode: 2 (640x480 VGA 30Hz)
              5 (320x240 QVGA 30Hz)
              8 (160x120 QQVGA 30Hz)
  depth_mode: 2 (VGA 30Hz)
              5 (QVGA 30Hz)
              8 (QQVGA 30Hz)

Here are 2 separate examples of launching the dynamic reconfigure node to change some parameters:

    <node name="$(anon dynparam)" pkg="dynamic_reconfigure" type="dynparam" args="set_from_parameters tilt_hokuyo_node">
      <param name="intensity" type="bool" value="false" />
      <param name="min_ang" type="double" value="-1.15" />
      <param name="max_ang" type="double" value="1.15" />
    </node>

  <node name="pr2_arm_navigation_perception_change_narrow_stereo_params_speckle" pkg="dynamic_reconfigure" type="dynparam" 
    args="set /narrow_stereo_textured/narrow_stereo_textured_proc speckle_size 1000" />

Or can specify the OpenNI driver configuration via ROS params:

<launch>
  <arg name="kinect_frame_prefix" default="/head_mount_kinect" />
  <arg name="kinect_camera_name" default="head_mount_kinect" />
  <arg name="publish_tf" default="true" />

  <!-- Set driver params for 320x240 at 1-2 Hz frame rate -->
  <param name="/$(arg kinect_camera_name)/driver/data_skip" value="10" /> <!-- 0 is default, 10 will drop 9/10 frames -->
  <param name="/$(arg kinect_camera_name)/driver/image_mode" value="5" /> <!-- 2 is default -->
  <param name="/$(arg kinect_camera_name)/driver/depth_mode" value="5" /> <!-- 2 is default -->

  <include file="$(find openni_launch)/launch/openni.launch">
    <arg name="device_id" value="#1" /> <!-- Use 1st device found, or you can specify first device on USB Bus #2 using 2@0 -->
    <arg name="camera" value="$(arg kinect_camera_name)" />
    <arg name="rgb_frame_id" value="$(arg kinect_frame_prefix)_rgb_optical_frame" />
    <arg name="depth_frame_id" value="$(arg kinect_frame_prefix)_ir_optical_frame" />
    <arg name="publish_tf" value="$(arg publish_tf)"/>
    <arg name="respawn" value="true"/>
    <arg name="depth_registration" value="true"/>
  </include>

</launch>
edit flag offensive delete link more

Comments

Thank you very much for the in depth answer!

Tadhg Fitzgerald gravatar image Tadhg Fitzgerald  ( 2013-02-20 04:25:56 -0500 )edit

Really a good answer!

ZiyangLI gravatar image ZiyangLI  ( 2014-02-25 02:20:07 -0500 )edit
1

answered 2013-02-19 12:39:45 -0500

Besides using dynamic_reconfigure as @dbworth suggested, you might want to use nodelets if you are passing images around in a single machine. That will make communication much faster ("zero-copy", as they say) while maintaining the modularity of nodes. Most of the image pipeline already supports nodelets.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2013-02-19 11:27:52 -0500

Seen: 4,500 times

Last updated: Feb 20 '13