Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OPENCV Problems? #15

Closed
firstbeer opened this issue May 22, 2022 · 12 comments
Closed

OPENCV Problems? #15

firstbeer opened this issue May 22, 2022 · 12 comments

Comments

@firstbeer
Copy link

firstbeer commented May 22, 2022

Hello,I meet this problems when catkin_make , where is the problems? what should we do ?

problems:
/catkin_ws/devel/lib/libimage_util.so:对‘cv::imshow(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, cv::_InputArray const&)’未定义的引用
/catkin_ws/devel/lib/libimage_util.so:对‘cv::namedWindow(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, int)’未定义的引用
....

@firstbeer
Copy link
Author

sorry,I saw the same problem in the closed module,the answer was important and useful ,but I couldnot solve this problem. Could you give me an example about opencv configure in the cmakelists.txt? thanks ,looking forward to your early reply.

@YukunXia
Copy link
Owner

YukunXia commented May 22, 2022

Hi firstbeer, sorry to hear that you have some issues with opencv when compiling this repository. I haven't compiled ros/cmake programs with opencv for a while, and to be honest, your question is more suitable to be asked at stackoverflow, but I'll try my best to give a few suggestions.

Firstly, a simple suggestion is that you can try building a minimal system with just opencv imread and imshow. Oftentimes, that doesn't work either with similar error messages, and is much easier to debug than this large repository.

In terms of using opencv in cmake, I think https://github.com/YukunXia/VLOAM-CMU-16833/blob/master/src/visual_odometry/CMakeLists.txt could be a good example. Search for opencv on that page, and you will see three related spots. (1)find_package lets cmake to try searching for opencv and configure it. (2) include_directories includes the opencv header files into the current workspace. (3)target_link_libraries links its target, either an executable or a library, to opencv's .so files. From that, you can print out opencv variables to verify their correctness. Besides, I remember, at the top of catkin_make messages, you can see the paths of those linked .so files (<- correct me if it's wrong).

Back to your compilation errors, 未定义的引用 (undefined reference) sounds like you have a problem with the target_link_libraries step. I'm not sure how you configure your opencv in your system, and which OS you are using. If it's linux, how many opencv versions do you have? How and where did you install them? For me, I have two versions, one installed via apt-get under /usr and another one built from source stored under /usr/local. Next, you have to make sure your opencv config file exists and the content is correct in your cmake path. Try locate OpenCVConfig.cmake in your terminal, and mine is under /usr/local/cmake/opencv4.

In the context of ros, if you have two opencv versions installed like me, and use cv_bridge in your system, there could be a conflict between the two opencvs. By default, cv_bridge links to the apt-get one. My solution was to uninstall cv_bridge coming from ros installation, and build it from scratch linking to my second opencv.

@firstbeer
Copy link
Author

Very glad to receive your letter also to fully show no felt sorry I met problems. I use the operating system is ubuntu18.04, ROS
version is melodic, download the melodic opencv3.2.0 installed under/usr folder. I downloaded the opencv4.5.1
in/home/firstbear home directory. And then I in/home/firstbear/opencv - 4.5.1 / build folder $sudo cmake - D
CMAKE_BUILD_TYPE = Release - D CMAKE_INSTALL_PREFIX = / usr/local.. ; $sudo make; $sudo make install. About
opencv4.5.1 PKG_CONFIG_PATH = $PKG_CONFIG_PATH: / usr/local/lib/pkgconfig; includedir=/usr/local/include;
libdir=/usr/local/lib. About OpenCVConfig.cmake , I found the following
path, /home/firstbear/opencv-4.5.1/build/OpenCVConfig.cmake ;/usr/local/lib/cmake/opencv4/OpenCVConfig.cmake; /usr/s
hare/OpenCV/OpenCVConfig.cmake. What I need to do is change / home / firstbear / catkin_ ws/src/VLOAMCMU-
16833/src/vloam_ main/CMakeLists. txt and CV_ Bridge?
Thanks,looking forward to your reply.

@YukunXia
Copy link
Owner

Before taking care ofvloam_main/CMakeLists and cv_bridge, please try the simple suggestion first to replicate your problem in a minimal system.

@firstbeer
Copy link
Author

Ok, thanks for your advice, I will use ubuntu18 and opencv4.5.1 to read images to verify my opencv4.5.1 environment configuration.

@firstbeer
Copy link
Author

Hello,I saved the problem about opencv and finished the catkin_make.Thanks for your help. But ,when I run the step2 and step3 ,no result to be shown in the rviz . And there are two errors in the terminal just like this. Could you give me some suggestion ? thanks.
屏幕截图 2022-06-02 162002

@YukunXia
Copy link
Owner

YukunXia commented Jun 8, 2022

Maybe you need to completely shutdown rosmaster and roscore, and start everything from scratch.

@firstbeer
Copy link
Author

非常感谢你的帮助,前段时间有些忙就没再整理,最近在ubuntu20.04新系统上重新配置之后就可以运行了,环境是ubuntu20.04+ros noetic+opencv4.5.1+eigen3.3.7+ceres2.0.0+默认的pcl,效果图如下:
f2284b8e0da32fb5eca1ce41fc64450
运行成功之后还有两个问题请教您:
1.如果我想用我的雷达和相机,除了更改对应的话题名字之外,雷达和相机之间的标定参数文件在哪里更改?
2.请问我该怎么保存建好的点云地图pcd文件?
最后再次感谢您的帮助,祝你身体健康,天天开心!(I am Chinese.If you are the same,let us communicate in Chinese,which will be more convenient)

@YukunXia
Copy link
Owner

YukunXia commented Jul 2, 2022

1, 雷达和相机之间的标定参数文件在哪里更改?

所有的标定信息都在在vloam_tf里面,比如

imu_stamped_tf_velo = tf_buffer_ptr->lookupTransform("imu_link", "velo_link", ros::Time(0), ros::Duration(3.0));
读取了imu和velodyne中间的transformation。可以改这个函数,从本地读config,也可以把transformation用roslaunch发到tf2上。我不记得为什么没有直接读相机和velodyne之间的transformation,但这个函数主要功能是提供velo_T_cam0
velo_T_cam0 = imu_T_velo.inverse() * imu_T_cam0;
以及提供其他transformation给rviz。

2,保存建好的点云地图pcd文件

我记得rviz可以直接存point cloud。lidar mapping那边我直接用的aloam,印象中运行时间长了global map会剔除太久以前的point cloud。如果需要输出完整的kitti的point cloud map,可以看下lidar global map是不是实际上存了所有的。如果是的话,可以定义一下lidar mapping的destructor,在里面加导出到本地pcd。如果不是的话,可以试下把每一帧的point cloud和mapped odometry都存下来成独立的pcd,最后再单独写一个程序把它们拼接起来。

@YukunXia
Copy link
Owner

YukunXia commented Jul 3, 2022

保存point cloud到pcd:https://wiki.ros.org/pcl_ros#pointcloud_to_pcd

@firstbeer
Copy link
Author

好的 收到 非常感谢 。对了,请问您的VLOAM实现过程中使用KITTI数据集IMU数据了吗?KITTI数据集中的四个相机数据您这边都使用了吗? 非常开心与您进行交流,谢谢

@YukunXia
Copy link
Owner

YukunXia commented Jul 4, 2022

  • VLOAM实现过程中使用KITTI数据集IMU数据了吗?

没有,但是用到了和imu相关的transformation,参考这个comment:#16 (comment)

  • KITTI数据集中的四个相机数据您这边都使用了吗?

没有,只用了left gray


另外不用客气。这个仓库只是作为一个课程项目的vloam简单实现,还有很多有待完善的地方,只能说抛砖引玉了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants