diff --git a/.github/workflows/macos-dep-src.yml b/.github/workflows/macos-dep-src.yml new file mode 100644 index 0000000..bf234f8 --- /dev/null +++ b/.github/workflows/macos-dep-src.yml @@ -0,0 +1,65 @@ +name: MacOS-dep-src + +# https://www.jeffgeerling.com/blog/2020/running-github-actions-workflow-on-schedule-and-other-events +on: + push: + pull_request: + schedule: + - cron: '0 2 * * SUN' + +jobs: + build-macos-dep-sec: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [macos-11, macos-12.0] + + steps: + # https://github.com/marketplace/actions/cancel-workflow-action + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.9.1 + with: + access_token: ${{ github.token }} + + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Print system information + run: | + sysctl -a | grep machdep.cpu + sysctl -a | grep logical + + - name: Print OS information + run: system_profiler SPSoftwareDataType + + - name: Install dependencies + run: brew install libpng libjpeg libdc1394 opencv pcl librealsense zbar pkg-config nlohmann-json + + # Openblas location is exported explicitly because openblas is keg-only, + # which means it was not symlinked into /usr/local/. + # qt@5 is as a requested dependency for vtk and thus for pcl 1.13.0 + # qt@5 is keg-only, which means it was not symlinked into /usr/local that's why we need to set Qt5_DIR + - name: Clone and configure ViSP + run: | + git clone --depth 1 https://github.com/lagadic/visp.git ${HOME}/visp + cd ${HOME}/visp + export LDFLAGS="-L/usr/local/opt/openblas/lib" + export CPPFLAGS="-I/usr/local/opt/openblas/include" + export Qt5_DIR="$(brew --prefix qt5)/lib/cmake/Qt5" + mkdir build && cd build + cmake .. -DQt5_DIR=$(brew --prefix qt5)/lib/cmake/Qt5 -DBUILD_DEMOS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_TESTS=OFF -DBUILD_TUTORIALS=OFF -DCMAKE_INSTALL_PREFIX=$(pwd)/install + cat ViSP-third-party.txt + + - name: Build and install ViSP + run: | + cd ${HOME}/visp/build + make -j$(sysctl -n hw.logicalcpu) install + echo "VISP_DIR=$(pwd)/install" >> $GITHUB_ENV + echo $VISP_DIR + + - name: Configure CMake and build visp_sample + run: | + mkdir build && cd build + cmake .. -DCMAKE_BUILD_TYPE=Release + make -j$(sysctl -n hw.logicalcpu) diff --git a/.github/workflows/ubuntu-dep-src.yml b/.github/workflows/ubuntu-dep-src.yml new file mode 100644 index 0000000..8d3352a --- /dev/null +++ b/.github/workflows/ubuntu-dep-src.yml @@ -0,0 +1,74 @@ +name: Ubuntu-dep-src + +# https://www.jeffgeerling.com/blog/2020/running-github-actions-workflow-on-schedule-and-other-events +on: + push: + pull_request: + schedule: + - cron: '0 2 * * SUN' + +jobs: + build-ubuntu-dep-src: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-20.04, ubuntu-22.04] + + steps: + # https://github.com/marketplace/actions/cancel-workflow-action + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.5.0 + with: + access_token: ${{ github.token }} + + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Print system information + run: lscpu + + - name: Print OS information + run: lsb_release -a + + - name: Install dependencies for ubuntu 18.04 and 20.04 + if: matrix.os != 'ubuntu-22.04' + run: | + sudo apt-get update + sudo apt-get install -y libx11-dev libdc1394-22-dev libv4l-dev liblapack-dev libopenblas-dev libeigen3-dev libopencv-dev libxml2-dev libpcl-dev nlohmann-json3-dev + sudo apt-get install -y libssl-dev libusb-1.0-0-dev pkg-config libgtk-3-dev libglfw3-dev libgl1-mesa-dev libglu1-mesa-dev + + - name: Install dependencies for ubuntu 22.04 + if: matrix.os == 'ubuntu-22.04' + run: | + sudo apt-get update + sudo apt-get install -y libx11-dev libdc1394-dev libv4l-dev liblapack-dev libopenblas-dev libeigen3-dev libopencv-dev libxml2-dev libpcl-dev nlohmann-json3-dev + sudo apt-get install -y libssl-dev libusb-1.0-0-dev pkg-config libgtk-3-dev libglfw3-dev libgl1-mesa-dev libglu1-mesa-dev + + - name: Build librealsense2 from source + run: | + pwd + git clone --depth 1 https://github.com/IntelRealSense/librealsense.git ${HOME}/librealsense + cd ${HOME}/librealsense + mkdir build && cd build && mkdir install + cmake .. -DBUILD_EXAMPLES=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$(pwd)/install + make -j$(nproc) install + echo "REALSENSE2_DIR=$(pwd)/install" >> $GITHUB_ENV + echo $REALSENSE2_DIR + + - name: Build ViSP from source + run: | + git clone --depth 1 https://github.com/lagadic/visp.git ${HOME}/visp + cd ${HOME}/visp + mkdir build && cd build && mkdir install + cmake .. -DBUILD_DEMOS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_TESTS=OFF -DBUILD_TUTORIALS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$(pwd)/install + cat ViSP-third-party.txt + make -j$(nproc) install + echo "VISP_DIR=$(pwd)/install" >> $GITHUB_ENV + echo $VISP_DIR + + - name: Configure CMake and build visp_sample + run: | + mkdir build && cd build + cmake .. -DCMAKE_BUILD_TYPE=Release + make -j$(nproc) diff --git a/.github/workflows/ubuntu-extra.yml b/.github/workflows/ubuntu-extra.yml new file mode 100644 index 0000000..c51587f --- /dev/null +++ b/.github/workflows/ubuntu-extra.yml @@ -0,0 +1,97 @@ +name: Ubuntu-extra + +# https://www.jeffgeerling.com/blog/2020/running-github-actions-workflow-on-schedule-and-other-events +on: + push: + pull_request: + schedule: + - cron: '0 2 * * SUN' + +jobs: + build-ubuntu-extra: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-20.04, ubuntu-22.04] + + steps: + # https://github.com/marketplace/actions/cancel-workflow-action + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.5.0 + with: + access_token: ${{ github.token }} + + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Print system information + run: lscpu + + - name: Print OS information + run: lsb_release -a + + - name: Install dependencies for ubuntu 18.04 and 20.04 + if: matrix.os != 'ubuntu-22.04' + run: | + sudo apt-get update + sudo apt-get install -y libx11-dev libdc1394-22-dev libv4l-dev gfortran liblapack-dev libopenblas-dev libeigen3-dev libopencv-dev libxml2-dev libpcl-dev nlohmann-json3-dev + sudo apt-get install -y libssl-dev libusb-1.0-0-dev pkg-config libgtk-3-dev libglfw3-dev libgl1-mesa-dev libglu1-mesa-dev + + - name: Install dependencies for ubuntu 22.04 + if: matrix.os == 'ubuntu-22.04' + run: | + sudo apt-get update + sudo apt-get install -y libx11-dev libdc1394-dev libv4l-dev gfortran liblapack-dev libopenblas-dev libeigen3-dev libopencv-dev libxml2-dev libpcl-dev nlohmann-json3-dev + sudo apt-get install -y libssl-dev libusb-1.0-0-dev pkg-config libgtk-3-dev libglfw3-dev libgl1-mesa-dev libglu1-mesa-dev + + - name: Build librealsense2 from source + run: | + pwd + git clone --depth 1 https://github.com/IntelRealSense/librealsense.git ${HOME}/librealsense + cd ${HOME}/librealsense + mkdir build && cd build && mkdir install + cmake .. -DBUILD_EXAMPLES=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$(pwd)/install + make -j$(nproc) install + echo "REALSENSE2_DIR=$(pwd)/install" >> $GITHUB_ENV + echo $REALSENSE2_DIR + + - name: Build ViSP from source + run: | + git clone --depth 1 https://github.com/lagadic/visp.git ${HOME}/visp + cd ${HOME}/visp + mkdir build && cd build && mkdir install + cmake .. -DBUILD_DEMOS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_TESTS=OFF -DBUILD_TUTORIALS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$(pwd)/install + cat ViSP-third-party.txt + make -j$(nproc) install + echo "ViSP_WS=${HOME}" >> $GITHUB_ENV + echo $ViSP_WS + + - name: Build visp_sample with ViSP from build tree + run: | + mkdir visp_sample-build && cd visp_sample-build + cmake .. -DCMAKE_BUILD_TYPE=Release -DVISP_DIR=$ViSP_WS/visp/build + make -j$(nproc) + + - name: Build visp_sample using visp-config from build tree + run: | + make -f Makefile.visp-config VISP_INSTALL_PREFIX=$ViSP_WS/visp/build + make -j$(nproc) -f Makefile.visp-config clean + + - name: Build visp_sample with ViSP from install tree + run: | + mkdir visp_sample-build_2 && cd visp_sample-build_2 + cmake .. -DCMAKE_BUILD_TYPE=Release -DVISP_DIR=$ViSP_WS/visp/build/install/lib/cmake/visp + make -j$(nproc) + + - name: Build visp_sample using visp.pc from install tree + run: | + export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$ViSP_WS/visp/build/install/lib/pkgconfig + make -j$(nproc) -f Makefile.visp.pc + make -j$(nproc) -f Makefile.visp.pc clean + + - name: Build visp_sample using visp-config from install tree + run: | + export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$ViSP_WS/visp/build/install/lib/pkgconfig + make -j$(nproc) -f Makefile.visp-config VISP_INSTALL_PREFIX=$ViSP_WS/visp/build/install + make -j$(nproc) -f Makefile.visp-config clean diff --git a/Makefile.visp-config b/Makefile.visp-config index 9577cf5..ff4a66b 100644 --- a/Makefile.visp-config +++ b/Makefile.visp-config @@ -1,7 +1,6 @@ -#CXX = g++ -VISP_BUILD_DIR = /tmp/usr/local -VISP_CFLAGS = `$(VISP_BUILD_DIR)/bin/visp-config --cflags` -VISP_LDFLAGS = `$(VISP_BUILD_DIR)/bin/visp-config --libs` +CXX = g++ +VISP_CFLAGS = `$(VISP_INSTALL_PREFIX)/bin/visp-config --cflags` +VISP_LDFLAGS = `$(VISP_INSTALL_PREFIX)/bin/visp-config --libs` SOURCES=$(shell find . -name "sample*.cpp") TARGETS=$(SOURCES:%.cpp=%) diff --git a/README.md b/README.md index 4b5ff40..3b7e38d 100644 --- a/README.md +++ b/README.md @@ -2,14 +2,51 @@ ViSP sample code used as code snippet in ViSP doxygen [documentation](https://visp-doc.inria.fr/doxygen/visp-daily/index.html). +This project uses [ViSP](https://github.com/lagadic/visp) that needs to be build with the following as 3rd-parties: +- OpenCV +- librealsense +- libxml2 +- PCL -This project uses [ViSP](https://github.com/lagadic/visp) as 3rd-party. +## 1. Prerequisities -## Build visp_sample with ViSP build tree +### 1.1. Install required 3rd parties + +- On ubuntu + + - Install required packages: + + ``` + $ sudo apt-get update + $ sudo apt-get install pkg-config libopencv-dev libxml2-dev libpcl-dev + ``` + + - Install librealsense from source following these [instructions](https://visp-doc.inria.fr/doxygen/visp-daily/tutorial-install-ubuntu.html#install_ubuntu_3rdparty_realsense) + +- On OSX +``` +$ brew update; brew upgrade +$ brew install opencv librealsense libxml2 pcl +``` + +### 1.2. Build and install ViSP from source See ViSP installation from source [tutorials](https://visp-doc.inria.fr/doxygen/visp-daily/tutorial_install_src.html). -Once ViSP is build, you can build `visp_sample` project: +``` +$ cd $VISP_WS +$ git clone https://github.com/lagadic/visp.git +$ mkdir $VISP_WS/visp-build +$ cd $VISP_WS/visp-build +$ cmake ../visp -DCMAKE_INSTALL_PREFIX=/tmp/usr/local +$ make -j4 install +``` + +Once ViSP is build, you can build `visp_sample` project using one of the 5 different ways that are given in the next sections. + +## 2. Build visp_sample project + +### 2.1. Build visp_sample with ViSP from build tree ``` $ cd $ViSP_WS @@ -17,41 +54,42 @@ $ git clone https://github.com/lagadic/visp_sample $ mkdir visp_sample-build $ cd visp_sample-build $ cmake ../visp_sample -DVISP_DIR=$ViSP_WS/visp-build +$ make -j4 +``` + +### 2.2. Build visp_sample using `visp-config` from build tree + +``` +$ cd $ViSP_WS/visp_sample +$ make -j4 -f Makefile.visp-config VISP_INSTALL_PREFIX=$ViSP_WS/visp-build +$ make -j4 -f Makefile.visp-config clean ``` -## Build visp_sample with ViSP install tree - -- build and install ViSP - ``` - $ cd $ViSP_WS/visp-build - $ cmake ../visp -DCMAKE_INSTALL_PREFIX=/tmp/usr/local - $ make -j4 - $ make -j4 install - ``` - -- build `visp_sample` using `cmake` - ``` - $ cd $ViSP_WS/visp_sample - $ mkdir build - $ cd build - $ cmake ../ -DVISP_DIR=/tmp/usr/local/lib/cmake/visp - $ make -j4 - ``` - -- build `visp_sample` using `visp-config` - ``` - $ cd $ViSP_WS/visp_sample - $ export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/tmp/usr/local/lib/pkgconfig - $ make -j4 -f Makefile.visp-config - $ make -j4 -f Makefile.visp-config clean - ``` - -- build `visp_sample` using `visp.pc` - ``` - $ cd $ViSP_WS/visp_sample - $ export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/tmp/usr/local/lib/pkgconfig - $ make -j4 -f Makefile.visp.pc - $ make -j4 -f Makefile.visp.pc clean - ``` +### 2.3. Build visp_sample with ViSP from install tree +``` +$ cd $ViSP_WS +$ git clone https://github.com/lagadic/visp_sample +$ mkdir visp_sample-build +$ cd visp_sample-build +$ cmake ../visp_sample -DVISP_DIR=/tmp/usr/local/lib/cmake/visp +$ make -j4 +``` +### 2.4. Build visp_sample using `visp.pc` from install tree + +``` +$ cd $ViSP_WS/visp_sample +$ export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/tmp/usr/local/lib/pkgconfig +$ make -j4 -f Makefile.visp.pc +$ make -j4 -f Makefile.visp.pc clean +``` + +### 2.5. Build visp_sample using `visp-config` from install tree + +``` +$ cd $ViSP_WS/visp_sample +$ export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/tmp/usr/local/lib/pkgconfig +$ make -j4 -f Makefile.visp-config VISP_INSTALL_PREFIX=/tmp/usr/local +$ make -j4 -f Makefile.visp-config clean +``` diff --git a/mbt/sample-vpMbEdgeKltTracker-1.cpp b/mbt/sample-vpMbEdgeKltTracker-1.cpp index 3cc7667..e3032c3 100644 --- a/mbt/sample-vpMbEdgeKltTracker-1.cpp +++ b/mbt/sample-vpMbEdgeKltTracker-1.cpp @@ -21,9 +21,7 @@ int main() display.init(I,100,100,"Mb Hybrid Tracker"); #endif -#if defined VISP_HAVE_PUGIXML tracker.loadConfigFile("cube.xml"); // Load the configuration of the tracker -#endif tracker.getCameraParameters(cam); // Get the camera parameters used by the tracker (from the configuration file). // load the 3d model, to read .wrl model coin is required, if coin is not installed .cao file can be used. tracker.loadModel("cube.cao"); diff --git a/mbt/sample-vpMbEdgeKltTracker-2.cpp b/mbt/sample-vpMbEdgeKltTracker-2.cpp index da1f663..72afdac 100644 --- a/mbt/sample-vpMbEdgeKltTracker-2.cpp +++ b/mbt/sample-vpMbEdgeKltTracker-2.cpp @@ -10,20 +10,18 @@ int main() #if defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION < 0x030000) vpMbEdgeKltTracker tracker; // Create an hybrid model based tracker. vpImage I; - vpHomogeneousMatrix cMo; // Pose used to display the model. + vpHomogeneousMatrix cMo; // Pose used to display the model. vpCameraParameters cam; - + // Acquire an image vpImageIo::readPGM(I, "cube.pgm"); - + #if defined VISP_HAVE_X11 vpDisplayX display; display.init(I,100,100,"Mb Hybrid Tracker"); #endif -#if defined VISP_HAVE_XML2 tracker.loadConfigFile("cube.xml"); // Load the configuration of the tracker -#endif tracker.getCameraParameters(cam); // Get the camera parameters used by the tracker (from the configuration file). tracker.loadModel("cube.cao"); // load the 3d model, to read .wrl model coi is required, if coin is not installed .cao file can be used. @@ -34,11 +32,6 @@ int main() tracker.display(I, cMo, cam, vpColor::darkRed, 1, true); // Display the model at the computed pose. vpDisplay::flush(I); } - -#if defined VISP_HAVE_XML2 - // Cleanup memory allocated by xml library used to parse the xml config file in vpMbEdgeKltTracker::loadConfigFile() - vpXmlParser::cleanup(); -#endif return 0; #endif diff --git a/mbt/sample-vpMbEdgeKltTracker.cpp b/mbt/sample-vpMbEdgeKltTracker.cpp index 7b00de7..b3d7622 100644 --- a/mbt/sample-vpMbEdgeKltTracker.cpp +++ b/mbt/sample-vpMbEdgeKltTracker.cpp @@ -8,7 +8,7 @@ int main() { -#if defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION < 0x030000) +#if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) vpMbEdgeKltTracker tracker; // Create an hybrid model based tracker. vpImage I; vpHomogeneousMatrix cMo; // Pose computed using the tracker. @@ -22,9 +22,7 @@ int main() display.init(I,100,100,"Mb Hybrid Tracker"); #endif -#if defined VISP_HAVE_XML2 tracker.loadConfigFile("cube.xml"); // Load the configuration of the tracker -#endif tracker.getCameraParameters(cam); // Get the camera parameters used by the tracker (from the configuration file). tracker.loadModel("cube.cao"); // Load the 3d model in cao format. No 3rd party library is required tracker.initClick(I, "cube.init"); // Initialise manually the pose by clicking on the image points associated to the 3d points containned in the cube.init file. @@ -39,11 +37,6 @@ int main() vpDisplay::flush(I); } -#if defined VISP_HAVE_XML2 - // Cleanup memory allocated by xml library used to parse the xml config file in vpMbEdgeKltTracker::loadConfigFile() - vpXmlParser::cleanup(); -#endif - return 0; #endif } diff --git a/mbt/sample-vpMbEdgeTracker-1.cpp b/mbt/sample-vpMbEdgeTracker-1.cpp index 48d1ff2..fb50e5f 100644 --- a/mbt/sample-vpMbEdgeTracker-1.cpp +++ b/mbt/sample-vpMbEdgeTracker-1.cpp @@ -13,9 +13,7 @@ int main() //acquire an image vpImageIo::read(I, "cube.pgm"); // Example of acquisition -#if defined VISP_HAVE_PUGIXML tracker.loadConfigFile("cube.xml"); // Load the configuration of the tracker -#endif // load the 3d model, to read .wrl model coin is required, if coin is not installed .cao file can be used. tracker.loadModel("cube.cao"); tracker.initFromPose(I, cMo); // initialize the tracker with the given pose. diff --git a/mbt/sample-vpMbEdgeTracker-2.cpp b/mbt/sample-vpMbEdgeTracker-2.cpp index 5d9d59d..6bf2ca7 100644 --- a/mbt/sample-vpMbEdgeTracker-2.cpp +++ b/mbt/sample-vpMbEdgeTracker-2.cpp @@ -20,9 +20,7 @@ int main() display.init(I,100,100,"Mb Edge Tracker"); #endif -#if defined VISP_HAVE_PUGIXML tracker.loadConfigFile("cube.xml"); // Load the configuration of the tracker -#endif tracker.getCameraParameters(cam); // Get the camera parameters used by the tracker (from the configuration file). // load the 3d model, to read .wrl model coin is required, if coin is not installed // .cao file can be used. diff --git a/mbt/sample-vpMbKltTracker-1.cpp b/mbt/sample-vpMbKltTracker-1.cpp index 93d2112..954ba0d 100644 --- a/mbt/sample-vpMbKltTracker-1.cpp +++ b/mbt/sample-vpMbKltTracker-1.cpp @@ -6,28 +6,23 @@ int main() { -#if defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION < 0x030000) +#if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) vpMbKltTracker tracker; // Create a model based tracker via Klt Points. vpImage I; - vpHomogeneousMatrix cMo; // Pose used in entry (has to be defined), then computed using the tracker. - + vpHomogeneousMatrix cMo; // Pose used in entry (has to be defined), then computed using the tracker. + //acquire an image vpImageIo::readPGM(I, "cube.pgm"); // Example of acquisition -#if defined VISP_HAVE_XML2 tracker.loadConfigFile("cube.xml"); // Load the configuration of the tracker -#endif tracker.loadModel("cube.cao"); // load the 3d model, to read .wrl model coi is required, if coin is not installed .cao file can be used. tracker.initFromPose(I, cMo); // initialise the tracker with the given pose. while(true){ // acquire a new image tracker.track(I); // track the object on this image - tracker.getPose(cMo); // get the pose + tracker.getPose(cMo); // get the pose } - - // Cleanup memory allocated by xml library used to parse the xml config file in vpMbKltTracker::loadConfigFile() - vpXmlParser::cleanup(); return 0; #endif diff --git a/mbt/sample-vpMbKltTracker-2.cpp b/mbt/sample-vpMbKltTracker-2.cpp index 73b4870..207d304 100644 --- a/mbt/sample-vpMbKltTracker-2.cpp +++ b/mbt/sample-vpMbKltTracker-2.cpp @@ -7,23 +7,21 @@ int main() { -#if defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION < 0x030000) +#if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) vpMbKltTracker tracker; // Create a model based tracker via Klt Points. vpImage I; - vpHomogeneousMatrix cMo; // Pose used to display the model. + vpHomogeneousMatrix cMo; // Pose used to display the model. vpCameraParameters cam; - + // Acquire an image vpImageIo::readPGM(I, "cube.pgm"); - + #if defined VISP_HAVE_X11 vpDisplayX display; display.init(I,100,100,"Mb Klt Tracker"); #endif -#if defined VISP_HAVE_XML2 tracker.loadConfigFile("cube.xml"); // Load the configuration of the tracker -#endif tracker.getCameraParameters(cam); // Get the camera parameters used by the tracker (from the configuration file). tracker.loadModel("cube.cao"); // load the 3d model, to read .wrl model coi is required, if coin is not installed .cao file can be used. @@ -34,11 +32,6 @@ int main() tracker.display(I, cMo, cam, vpColor::darkRed, 1, true); // Display the model at the computed pose. vpDisplay::flush(I); } - -#if defined VISP_HAVE_XML2 - // Cleanup memory allocated by xml library used to parse the xml config file in vpMbKltTracker::loadConfigFile() - vpXmlParser::cleanup(); -#endif return 0; #endif diff --git a/mbt/sample-vpMbKltTracker.cpp b/mbt/sample-vpMbKltTracker.cpp index 77e2ab4..20305df 100644 --- a/mbt/sample-vpMbKltTracker.cpp +++ b/mbt/sample-vpMbKltTracker.cpp @@ -8,7 +8,7 @@ int main() { -#if defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION < 0x030000) +#if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)) vpMbKltTracker tracker; // Create a model based tracker via KLT points. vpImage I; vpHomogeneousMatrix cMo; // Pose computed using the tracker. @@ -22,9 +22,7 @@ int main() display.init(I,100,100,"Mb Klt Tracker"); #endif -#if defined VISP_HAVE_XML2 tracker.loadConfigFile("cube.xml"); // Load the configuration of the tracker -#endif tracker.getCameraParameters(cam); // Get the camera parameters used by the tracker (from the configuration file). tracker.loadModel("cube.cao"); // Load the 3d model in cao format. No 3rd party library is required tracker.initClick(I, "cube.init"); // Initialise manually the pose by clicking on the image points associated to the 3d points containned in the cube.init file. @@ -39,11 +37,6 @@ int main() vpDisplay::flush(I); } -#if defined VISP_HAVE_XML2 - // Cleanup memory allocated by xml library used to parse the xml config file in vpMbKltTracker::loadConfigFile() - vpXmlParser::cleanup(); -#endif - return 0; #endif }