Closed liushuya7 closed 1 year ago
It seems like the OpenCV finds the system's Eigen instead. There was only "EIGEN3_DIR" not "EIGEN3_INCLUDE_DIR". This is the opencv cmake configuration:
The third-party packages eigen 3.3.4 and opencv 3.4.12 specified by this repo couldn't make xreg to be built on my Ubuntu 20.04 I solved it by building it with system's Eigen 3.3.7 and OpenCV 4.2.0 Two files need to be modified due to switching to opencv 4:
// file:xreg/lib/opencv/xregOpenCVUtils.cpp - line 484
// change
// cv::cvtColor(img, dst_img, CV_GRAY2BGR);
// to
cv::cvtColor(img, dst_img, cv::COLOR_GRAY2BGR);
and
// file:xreg/lib/regi/sim_metrics_2d/xregImgSimMetric2DBoundaryEdgesCPU.cpp - line 64
// change
// cv::distanceTransform(fixed_edges, fixed_edge_dist_map_, CV_DIST_L2, CV_DIST_MASK_PRECISE);
// to
cv::distanceTransform(fixed_edges, fixed_edge_dist_map_, cv::DIST_L2, cv::DIST_MASK_PRECISE);
Seems like the real issue is that the opencv didn't link to the specified eigen3 during building.
As of now, I can only build it by using system's Eigen 3.3.7 and OpenCV 4.2.0 So something must have gone wrong when building these two third-party packages using the example_build_script
Although I still don't know why, I think I finally figured out something that will make it work: if you set -DWITH_EIGEN:BOOL=OFF
when building opencv, then xreg builds successfully depending on the third-party libraries specified in the _example_buildscript.
Hi Joshua,
Thanks a lot for investigating this. It sounds like the following happened in your original problem:
I will try to reproduce this and add: 1. a change to the example build script and 2. a source code change that works with OpenCV 3 and 4. Maybe there will be more errors to fix - I am not sure until I can reproduce the problem.
Another potential solution is to 1. remove the local Eigen download and 2. remove the OpenCV build from the build script (2) and instead use the system versions of OpenCV and Eigen (I understand there was that compile error, but you have a fix for that).
I was able to reproduce this issue with this minimal docker file:
FROM ubuntu:20.04
RUN export DEBIAN_FRONTEND=noninteractive && \
apt-get update && apt-get install -y --no-install-recommends \
build-essential \
ca-certificates \
cmake \
wget \
libssl-dev \
git \
cmake \
ninja-build \
libopencv-dev \
libeigen3-dev \
libglew-dev \
libxt-dev \
unzip && \
rm -rf /var/lib/apt/lists/*
RUN git clone https://github.com/rg2/xreg.git xreg-git
RUN cd xreg-git && ./example_build_script_2
Thanks, Rob, for taking a look at this!
I personally prefer using the built-in system dependencies if possible. I was experimenting if I can compile xreg using system libraries. I was able to successfully build it on my Ubuntu 20.04. The only thing that I need to do is to download VTK 9.2.2 and ITK 5.2.1 to compile them, then configure the path for xreg to find them during cmake.
The rest of the dependencies can be easily installed by:
sudo apt install libtbb-dev libfmt-dev libeigen3-dev libviennacl-dev libnlopt-cxx-dev libopencv-dev
and the cmake should find these system libraries automatically.
Although you do need to update some syntax since Ubuntu 20.04 has opencv4 by default, see d8c1e433986f92b308fdacab4fa9469733fd046d.
I think if that works for you, then that's great! The example is just that, an example. Glad that you were able to get things going to meet your needs.
I will try to update the example so at least it does NOT result in an error.
Closing this for now as I have merged #23, which should fix this issue when using the example build script when system versions of Eigen and OpenCV are also installed.
By running the example_build_script_2,I was able to build all the third-party packages, but when I tried to build xreg, I got the following error:
Any help is appreciated!