12/29/2016

How to build CloudCompare

To build on Mac:
Use CMake GUI tool.
Source code: /Users/liangzou/gitcloudcompare/trunk
/Users/liangzou/gitcloudcompare/build

Then click Configure

Manually fix the QT5_ROOT_PATH fields:
/Users/liangzou/Qt/5.7/clang_64/lib/cmake/Qt5

Then choose what to install under INSTALL. Check INSTALL_QANIMATION_PLUGIN

Set variables for FFMPEG:
/usr/local/Cellar/ffmpeg/3.1.4/include

Click the Configure again.


Then click Generate.

In addition, I need to do a code change in file:
QVideoEncoder.cpp. Add function call "avcodec_register_all()" before avcodec_find_encoder(codec_id).

Then make install

To build on Linux:
Use CMake GUI tool:
cmake-gui

Install Qt5. Download QT installer and run it.
Set:
QT5_ROOT_PATH: /opt/Qt/5.10.1/gcc_64/include
Qt5Concurrent_DIR: /opt/Qt/5.10.1/gcc_64/lib/cmake/Qt5Concurrent
...

With PDAL to support LAS files.
Download and build https://github.com/LASzip/LASzip
Download and build https://github.com/PDAL/PDAL
Check the OPTION_PDAL_LAS option
PDAL_DIR should be set correctly if it was installed correctly. e.g. /usr/local/lib/cmake/PDAL

Download and build https://github.com/open-source-parsers/jsoncpp
Set JSON_ROOT_DIR to: /usr/local/lib/cmake/jsoncpp/

To install the QANIMATION_PLUGIN, FFMPEG needs to be installed.
https://github.com/FFmpeg/FFmpeg
To install FFMPEG:
git checkout n4.1
./configure --disable-x86asm --prefix=/opt/ffmpeg --enable-shared --enable-pic

make
sudo make install

Set FFMPEG_INCLUDE_DIR and FFMPEG_LIBRARY_DIR correctly, e.g. /opt/ffmpeg/include/ and /opt/ffmpeg/lib
(VERY IMPORTANT: need to add /opt/ffmpeg/lib to LD_LIBRARY_PATH. Otherwise, the plugin won't show in CloudCompare).

A working build screen:


Common errors:
1. cannot find a so:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/Qt/5.10.1/gcc_64/lib:/usr/local/cuda-9.1/lib64
OR you'll need to run sudo ldconfig

2. CloudCompare crashes when starting:
Delete some pidgin files: e.g. sudo rm -rf /usr/local/lib/cloudcompare/pidgins

3. If installed by using snap, need to follow:
sudo apt update
sudo apt install snapd
sudo snap install cloudcompare



12/26/2016

How to restart Ubuntu cinnamon

pkill -HUP -f "cinnamon --replace"

12/16/2016

Mersenne Twister

The Mersenne Twister is a pseudorandom number generator (PRNG). It is by far the most widely used general-purpose PRNG. Its name derives from the fact that its period length is chosen to be a Mersenne prime.

In mathematics, a Mersenne prime is a prime number that is one less than a power of two.

More generally, numbers of the form Mn = 2n − 1 without the primality requirement are called Mersenne numbers.

Ransac (get planes from point clouds)

Fit Plane Ransac: Random sample consensus (RANSAC) is an iterative method to estimate parameters of a mathematical model from a set of observed data that contains outliers, when outliers are to be accorded no influence on the values of the estimates. Therefore, it also can be interpreted as an outlier detection method.[1] It is a non-deterministic algorithm in the sense that it produces a reasonable result only with a certain probability, with this probability increasing as more iterations are allowed. The algorithm was first published by Fischler and Bolles at SRI International in 1981. They used RANSAC to solve the Location Determination Problem (LDP), where the goal is to determine the points in the space that project onto an image into a set of landmarks with known locations.

12/14/2016

Delaunay Triangulation

In mathematics and computational geometry, a Delaunay triangulation for a set P of points in a plane is a triangulation DT(P) such that no point in P is inside the circumcircle of any triangle in DT(P). Delaunay triangulations maximize the minimum angle of all the angles of the triangles in the triangulation; they tend to avoid skinny triangles.



12/01/2016

Bazel Memo

  • If some weird errors happen, such as some files exist, but bazel complains No file or directory, take a look a the .bazelrc file. See if you're using --spawn_strategy=standalone --genrule_strategy=standalone
  • If you changed a third party package in the WORKSPACE file and bazel build fails, it can likely be fixed by running bazel clean --expunge
  • Don't use copts = ["-Ithirdparty/cc"] to solve "cannot find xxx.h file" errors. Instead, use includes = ["../", "include/../", etc...], to solve the include errors. Reason? See the reason bellow.
    • If you depend on a third party library with copts = [-Ithird_party/cc], all your libraries or binaries that depend on this library must have copts.
  • copts can use Make variable substitutions. For example copts = [-I$(GENFILES)] will add bazel-out/local-fastbuild/genfiles to the include path. For other Make variables: https://bazel.build/versions/master/docs/be/make-variables.html#predefined_variables.genrule.cmd
  • If bazel project A depends on project B (both have WORKSPACE files), only the root project (A)'s WORKSPACE file is used. Project B WORKSPACE won't have affect if the bazel build starts from project A.
  • Use bazel build -s to print out detailed logs
  • genrule meanings:
    •  outs = ["omap_ground_detector_config.cc"], a list of files to be generated
    • tools = [":generate_ground_detector_config"], the binary.
    • cmd = "$(location generate_ground_detector_config) ", the command to run. Flag means: $@, space separated string of outs
  • Options can be put in the ~/.bazelrc file:  build --jobs=4 --local_resources=6144,6,1.0 --experimental_local_memory_estimate=true --worker_max_instances=1 --spawn_strategy=standalone --genrule_strategy=standalone 
  • For linking errors, such as undefined reference to 'cublasCreate_v2', need to know which library it tries to link to, then use linkopts = ["-L/path/to/lib", "-Wl,-rpath,/path/to/lib"] to add the lib search paths. Also in the copts and linkopts, you can use the external folder directly: e.g. "-Wl,-rpath,external/drive_t186ref_linux_aarch64/lib/aarch64-linux-gnu". But this doesn't work with the %package%: -L%package(@cuda_full_aarch64//lib)%
  • What is RPATH and $ORIGIN: RPATH stands for run-time search path. According to Wikipedia, “rpath designates the run-time search path hard-coded in an executable file or library. $ORIGIN is a special variable that indicate actual executable filename. It is resolved to where the executable is at run-time, and can be quite useful when setting RPATH. https://nehckl0.medium.com/creating-relocatable-linux-executables-by-setting-rpath-with-origin-45de573a2e98
  • Build a self-contained python executable: bazel build --build_python_zip
  • Example of a genrule:
    genrule(
        name = "gcc_sh_files",
        srcs = ["wrapper_scripts/wrapper.sh"],
        outs = [
            "gcc_linaro_aarch64_linux_gnu/ar.sh",
            "gcc_linaro_aarch64_linux_gnu/cpp.sh",
            "gcc_linaro_aarch64_linux_gnu/gcc.sh",
            "gcc_linaro_aarch64_linux_gnu/gcov.sh",
            "gcc_linaro_aarch64_linux_gnu/ld.sh",
            "gcc_linaro_aarch64_linux_gnu/nm.sh",
            "gcc_linaro_aarch64_linux_gnu/objdump.sh",
            "gcc_linaro_aarch64_linux_gnu/strip.sh",
        ],
        cmd = ("for i in $(OUTS); do " +
               "/bin/cp $(location wrapper_scripts/wrapper.sh) $$i; done")
    )