how to compile cv_bridge tutorial with opencv3?
Hey,
I'm using ros kinetic and want to use cv2 in python. while 'import cv2' I got this error:
import cv2
ImportError: dynamic module does not define module export function (PyInit_cv2)
my cmakelists file looks:
cmake_minimum_required(VERSION 2.8.3)
project(cv2_sendbox)
## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS
cv_bridge
roscpp
rospy
sensor_msgs
std_msgs
)
find_package(OpenCV 3 REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
How can I fix this?
Thanks in advance
Asked by SHPOWER on 2016-06-22 09:05:39 UTC
Answers
Here is my makelists file for CV bridge using openCV2. I struggled for a while on this install but don't remember where I found the solution...so just giving you the file that works for me.
In my case this is Jade on 14.04 but installed CVbridge using the current git within last month.
In the end I removed reference to 2 or 3. I left in the commented lines so you get a feeling of what I played with while finding answer.
Maybe this will help in your case as well. I would post this as a comment but too long for comment. Good luck!
cmake_minimum_required(VERSION 2.8)
project(cv_bridge)
find_package(catkin REQUIRED COMPONENTS rosconsole sensor_msgs)
if(NOT ANDROID)
find_package(PythonLibs)
if(PYTHONLIBS_VERSION_STRING VERSION_LESS 3)
find_package(Boost REQUIRED python)
else()
find_package(Boost REQUIRED python3)
endif()
else()
find_package(Boost REQUIRED)
endif()
find_package(OpenCV)
include_directories(${OpenCV_INCLUDE_DIRS})
#target_link_libraries(${OpenCV_LIBRARIES})
#find_package(OpenCV 2 REQUIRED)
#find_package(OpenCV 3 REQUIRED
# COMPONENTS
# opencv_core
# opencv_imgproc
# opencv_imgcodecs
# CONFIG
#)
catkin_package(
INCLUDE_DIRS include
LIBRARIES ${PROJECT_NAME}
CATKIN_DEPENDS rosconsole sensor_msgs
DEPENDS OpenCV
CFG_EXTRAS cv_bridge-extras.cmake
)
catkin_python_setup()
include_directories(include ${Boost_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS} ${catkin_INCLUDE_DIRS})
if(NOT ANDROID)
add_subdirectory(python)
endif()
add_subdirectory(src)
if(CATKIN_ENABLE_TESTING)
add_subdirectory(test)
endif()
# install the include folder
install(
DIRECTORY include/${PROJECT_NAME}/
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
)
Asked by billy on 2019-03-25 01:10:56 UTC
Comments