opencv2 import problem with python
Jason E. Hale
jhale at FreeBSD.org
Sun Jun 29 17:50:14 UTC 2014
On Sun, Jun 29, 2014 at 4:47 AM, Zenny <garbytrash at gmail.com> wrote:
> Thanks John:
>
> I am getting the following:
>
> "% grep ZTIN2cv15FeatureDetectorE /usr/local/lib/*
> Binary file /usr/local/lib/libopencv_contrib.so matches
> Binary file /usr/local/lib/libopencv_contrib.so.2 matches
> Binary file /usr/local/lib/libopencv_contrib.so.2.4.7 matches
> Binary file /usr/local/lib/libopencv_features2d.so matches
> Binary file /usr/local/lib/libopencv_features2d.so.2 matches
> Binary file /usr/local/lib/libopencv_features2d.so.2.4.7 matches
> Binary file /usr/local/lib/libopencv_legacy.so matches
> Binary file /usr/local/lib/libopencv_legacy.so.2 matches
> Binary file /usr/local/lib/libopencv_legacy.so.2.4.7 matches
> Binary file /usr/local/lib/libopencv_stitching.so matches
> Binary file /usr/local/lib/libopencv_stitching.so.2 matches
> Binary file /usr/local/lib/libopencv_stitching.so.2.4.7 matches
>
> I am CCing this mail to jhale for his attention, who is reportedly the
> maintainer accoring to the ports Makefile.
>
> /z
>
>
>
>
> On Sun, Jun 29, 2014 at 10:34 AM, John-Mark Gurney <jmg at funkthat.com> wrote:
>>
>> Zenny wrote this message on Sun, Jun 29, 2014 at 10:24 +0200:
>> > Hi:
>> >
>> > I am trying to run opencv2 and installed it using the pkg binaries
>> > (opencv
>> > and py27-opencv).
>> >
>> > However when I try to import opencv2 module, it outputs:
>> >
>> > "% python
>> > Python 2.7.6 (default, Mar 4 2014, 19:30:28)
>> > [GCC 4.2.1 Compatible FreeBSD Clang 3.3 (tags/RELEASE_33/final 183502)]
>> > on
>> > freebsd10
>> > Type "help", "copyright", "credits" or "license" for more information.
>> > >>> import cv2
>> > Traceback (most recent call last):
>> > File "<stdin>", line 1, in <module>
>> > ImportError: /usr/local/lib/python2.7/site-packages/cv2.so: Undefined
>> > symbol "_ZTIN2cv15FeatureDetectorE"
>> > >>>"
>> >
>> > cv2.so file does exist. Any hints to run opencv2 in FreeBSD 10.0 will be
>> > appreciated! Thanks!
>>
>> Sounds like one of the libraries that cv2.so depends upon wasn't linked
>> w/ cv2.so... doing a: grep ZTIN2cv15FeatureDetectorE /usr/local/lib/*
>> should identify it, and you should report it to opencv2's maintainer
>> to fix..
>>
>> --
>> John-Mark Gurney Voice: +1 415 225 5579
>>
>> "All that I will do, has been done, All that I have, has not."
>
>
I'm moving this discussion to the freebsd-ports mailing list.
Could you try the attached diff? It's interesting that this has been
in the ports
tree for 7 months and nobody noticed it until now.
Note: you need to import numpy before cv2.
-------------- next part --------------
Index: opencv/Makefile
===================================================================
--- opencv/Makefile (revision 357036)
+++ opencv/Makefile (working copy)
@@ -10,7 +10,7 @@
MAINTAINER= jhale at FreeBSD.org
COMMENT= Open Source Computer Vision library
-LICENSE= BSD
+LICENSE= BSD3CLAUSE
LICENSE_FILE= ${WRKSRC}/doc/license.txt
USES= cmake pkgconfig
@@ -204,12 +204,15 @@
BUILD_DEPENDS+= ${PYNUMPY}
RUN_DEPENDS+= ${PYNUMPY}
USE_PYTHON= yes
+OCV_PYTHON_LIBS=-lopencv_core -lopencv_contrib -lopencv_flann -lopencv_imgproc \
+ -lopencv_ml -lopencv_features2d -lopencv_objdetect -lopencv_video \
+ -lopencv_photo -lopencv_highgui
CFLAGS+= -I${LOCALBASE}/include
CMAKE_ARGS+= -DBUILD_opencv_python:BOOL=On
. for module in ${OCV_MODS} ${OCV_CORE_MODS} ${OCV_JAVA_MODS}
CMAKE_ARGS+= -DBUILD_opencv_${module}:BOOL=Off
. endfor
-CMAKE_ENV+= LDFLAGS="${LDFLAGS} -L${LOCALBASE}/lib"
+LDFLAGS+= -L${LOCALBASE}/lib ${OCV_PYTHON_LIBS}
INSTALL_WRKSRC= ${WRKSRC}/modules/python
.elif defined(OCV_JAVA)
BUILD_DEPENDS+= ant:${PORTSDIR}/devel/apache-ant
Index: py-opencv/Makefile
===================================================================
--- py-opencv/Makefile (revision 357036)
+++ py-opencv/Makefile (working copy)
@@ -1,7 +1,7 @@
# Created by: Martin Matuska <mm at FreeBSD.org>
# $FreeBSD$
-PORTREVISION= 1
+PORTREVISION= 2
CATEGORIES= graphics python
PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}
More information about the freebsd-ports
mailing list