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

TypeError: <unknown> is not a numpy array in pi_head_tracking_tutorial

asked 2011-06-17 02:27:09 -0600

Pi Robot gravatar image

updated 2011-06-17 02:32:40 -0600

I am asking and answering my own question here to help a few people who have run into a snag when trying my pi_head_tracking_tutorial when running Diamondback. This tutorial uses the Python OpenCV CamShift function to track a colored patch in a video when the user selects the patch with the mouse. While this function worked fine under C-Turtle, under Diamondback, the following error occurs right after selecting the region to track:

TypeError: <unknown> is not a numpy array

The error occurs right after this function call:

(iters, (area, value, rect), track_box) = cv.CamShift(backproject, self.track_window, crit)

I have submitted a ticket to see if it is really a bug.

Compiling OpenCV from the latest source does not fix the problem. Please see my answer below for a workaround.

--patrick

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2011-06-17 02:32:18 -0600

Pi Robot gravatar image

The only fix at the moment seems to be to overlay the C-Turtle version of the vision_opencv stack and then set your ROS_PACKAGE_PATH and PYTHONPATH environment variables to pick up this version before Diamondback's version. This has been tested under Ubuntu 10.04 using Debian packages for Diamondback and the C-Turtle vision_opencv stack.

To apply this fix on your machine, follow these steps:

$ sudo apt-get install ros-cturtle-vision-opencv
$ cd
$ echo -e "\nexport ROS_PACKAGE_PATH=/opt/ros/cturtle/stacks/vision_opencv:$ROS_PACKAGE_PATH" >> .bashrc
$ echo -e "\nexport PYTHONPATH=/opt/ros/cturtle/stacks/vision_opencv/opencv2/lib:$PYTHONPATH" >> .bashrc
$ source .bashrc

(The last command is only necessary in any currently open terminal windows. The path changes will be automatically picked up in any new terminal windows you launch in the future.)

In the meantime, I have updated the pi_head_tracking_tutorial package to include support for the Kinect (previously only webcams were supported). To use a Kinect, edit the head_track.launch file and set the "kinect" arg to True. I have noticed that color tracking with the Kinect does not seem to work as well as with the webcams I have tried. I have an idea how to improve this and will post an update when I have it implemented.

--patrick

edit flag offensive delete link more

Question Tools

Stats

Asked: 2011-06-17 02:27:09 -0600

Seen: 927 times

Last updated: Jun 17 '11