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

cv2 (2.4.8) missing DIST_L2 for distanceTransform?

asked 2016-04-02 22:55:18 -0600

dcconner gravatar image

updated 2016-04-02 22:55:53 -0600

I'm trying to implement a image segmentation node. If I following the image segementation example code

 dist_transform = cv2.distanceTransform(opening, cv2.DIST_L2, 5)

I get the following error:

AttributeError: 'module' object has no attribute 'DIST_L2'

Checking the __dict_ there is not a DIST_L2. I tried substituting NORM_L2, but that did not give the expected result.

The "import cv2" gives me version 2.4.8 (as installed by ROS Jade on Ubuntu 14.04)

Has anyone seen this issue?

Is it possible to use OpenCV 3 in python, or is that only for C++?

edit retag flag offensive close merge delete


Can you write a minimal script which demonstrates this behavior. You have not clarified what cv2 exactly is. And point to the documentation from which you believe that cv2.DIST_L2 should exist.

tfoote gravatar image tfoote  ( 2016-04-03 19:58:38 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2016-04-04 03:35:50 -0600

Mehdi. gravatar image

updated 2016-04-04 03:40:32 -0600

This is more a StackOverflow question, or OpenCV Q&A as the library itself is independent from ROS, and the answer can also be found here and here.

Try with:
edit flag offensive delete link more


Supposedly OpenCV 3 is installed with Jade. The directions for using with C++ seem straightforward with CMake, but I'm not sure about Python.

Does OpenCV 3 work with Python in the Jade installation?

dcconner gravatar image dcconner  ( 2016-04-04 07:53:18 -0600 )edit

AFAIK Ubuntu Opencv 3 cannot be installed directly on Ubuntu 14.04 (using apt-get) so I guess that Jade will use Opencv2 instead.

Mehdi. gravatar image Mehdi.  ( 2016-04-04 08:56:29 -0600 )edit

Question Tools

1 follower


Asked: 2016-04-02 22:55:18 -0600

Seen: 973 times

Last updated: Apr 04 '16