2015年5月22日 星期五

Use OpenCV & OpenMP on OSX Yosemite 10.10.3 GNU GCC or LLVM/Clang ?

筆記文..

在遇到這問題之前,我已成功編譯且灌好歐噴屎V,直到昨天需要編譯一個使用了 OpenCV 和 OpenMP 的專案,問題就產生了!

我無法成功使用 gcc 在 osx 上編譯 OpenCV..所以之前是用系統預設的 clang,但 Yosemite 底下的 clang 似乎沒有支援 OpenMP 了,導致專案編譯時無法成功(即使灌了 OpenMP)

目前解法:

  1. 重新安裝 gcc 和 OpenMP
  2. brew uninstall gcc
    brew install open-mpi
    
    先移除原有的 gcc,brew install open-mpi 會安裝 gcc 和 openmp。

     
  1. 重新編譯  OpenCV
  2. 修改 path to opencv-2.4.10/cmake/OpenCVCompilerOptions.cmake
    set(OPENCV_EXTRA_FLAGS " -stdlib=libstdc++")
    set(OPENCV_EXTRA_C_FLAGS " -stdlib=libstdc++")
    set(OPENCV_EXTRA_CXX_FLAGS " -stdlib=libstdc++")
    set(OPENCV_EXTRA_EXE_LINKER_FLAGS " -stdlib=libstdc++")
    
    加上 -stdlib=libstdc++ 原因是現在 calng 預設使用 libc++,但 g++ 是 libstdc++,應該很清楚為何這麼做了!之後編譯專案時為了能用 OpemMP,選擇使用 g++ 那麼編譯 OpenCV 當然要選 g++ 用的 libstdc++ 囉!(改完後安裝方式應該都很清楚就不多說了,記得編譯使用 tbb 就不能用 OpenMP!我是選 tbb..)

     
  1. 修改專案使用的預設編譯器(CMakeLists.txt)
  2. set(CMAKE_C_COMPILER "/usr/local/Cellar/gcc/4.9.2_1/bin/gcc-4.9")
    set(CMAKE_CXX_COMPILER "/usr/local/Cellar/gcc/4.9.2_1/bin/g++-4.9")
    

2015年3月12日 星期四

Install OpenNI2 on Ubuntu 14.04 with Xtion(PrimeSense)

First i've try OpenNI 2 SDK Binaries unfortunately it can't find my device so i install it like i did before.. 1. compile driver 2. install openni2
  1. create OpenNI2 folder
  2. mkdir OpenNI2 && cd OpenNI2
    
  3. compile driver
  4. git clone git@github.com:PrimeSense/Sensor.git
    cd Sensor
    cd Platform/Linux/CreateRedist
    ./RedistMaker
    cd ../../..
    
    cd Platform/Linux/Redist
    cd Sensor-Bin-*
    sudo ./install.sh
    
    # back to OpenNI2 folder
    cd ../../../../../
    
  5. install openni2
  6. # or you can get develop branch
    # git clone -b develop git@github.com:occipital/OpenNI2.git
    git clone  git@github.com:occipital/OpenNI2.git
    cd OpenNI2 && make -j8 && cd ..
    
  7. now plug in Xtion
  8. cd OpenNI2/Bin/x64-Release && ./NiViewer
    # will see the result like below press ESC to exit
    

2015年1月9日 星期五

Use minicom to connect Raspberry PI

  1. Prepare
  2. a. A USB to TTL Serial
    b. Install minicom
    sudo apt-get install minicom
    
  3. Connect
  4. a. connect TTL to GPIO like below

    b. find the port on your PC
    ls -l /dev/ttyUSB0
    
    the output will like "crw-rw---- 1 root dialout...", means it's character device
    sudo minicom -b 115200 -o -D /dev/ttyUSB0
    
    Then you'll coneect to RPI !

2015年1月8日 星期四

Easily Stream your Camera on Ubuntu 14.04

  1. Install dependent lib
  2. sudo apt-get install imagemagick
    sudo apt-get install libjpeg8-dev
    sudo apt-get install libjpeg-dev
    sudo apt-get install libv4l-dev
    
  3. Download MJPG-Streamer and Install
  4. svn checkout svn://svn.code.sf.net/p/mjpg-streamer/code/ mjpg-streamer-code
    cd mjpg-streamer-code/mjpg-streamer
    make
    sudo make install
    
  5. Start the Server!
  6. mjpg_streamer -i "/usr/local/lib/input_uvc.so -f 15 -r 640x480" -o "/usr/local/lib/output_http.so -w /usr/local/www -p 8080"
    

2014年12月15日 星期一

Install caffe on ubuntu 14.04 with cuda-6.5.14

My device:

  1. OS: ubuntu 14.04
  2. linux kernel: 3.13.0-39
  3. graphic card: nvidia gtx 660
(I can't promise that this way can do well on laptop which graphic card include nvidia Optimus mechanisum)

  1. Install CUDA (include nvidia driver)
    • Install build essential
    sudo apt-get update && sudo apt-get install build-essential
    
    • Download CUDA and Extract
    wget http://developer.download.nvidia.com/compute/cuda/6_5/rel/installers/cuda_6.5.14_linux_64.run
    
      chmod a+x cuda_6.5.14_linux_64.run
        mkdir nvidia_installer
          ./cuda_6.5.14_linux_64.run -extract=`pwd`/nvidia_installer
          • Press Ctrl-Alt-F1 and login
          Stop the lightdm and remove current nvidia driver
          sudo service lightdm stop
          sudo apt-get remove --purge nvidia-*
          # If it returns there are some process cause it can't be remove, i just kill them all and remove again.

        • Install
        • cd nvidia_installer
          sudo ./NVIDIA-Linux-x86_64-340.29.run
          sudo ./cuda-linux64-rel-6.5.14-18749181.run
          sudo ./cuda-samples-linux-6.5.14-18745345.run
          # restart lightdm and disable nouveaus
          sudo service lightdm start
          
          (I set every settings by default!)
          • Disable nouveau
          • gedit /etc/modprobe.d/blacklist-nouveau.conf
            and add
            blacklist nouveau
            blacklist lbm-nouveau
            options nouveau modeset=0
            alias nouveau off
            alias lbm-nouveau off
            Reboot
            update-initramfs -u
            sudo reboot
          • Other necessary libs.
          • cudnn api download (Login and answer some questions to get the download permission.)
            tar -xzvf cudnn-6.5-linux-R1.tgz
            cd cudnn-6.5-linux-R1
            sudo cp lib* /usr/local/cuda/lib64/
            sudo cp cudnn.h /usr/local/cuda/include/
            
            sudo cp lib* /usr/local/lib
            sudo cp cudnn.h /usr/local/include
            sudo ln -sf /usr/local/lib/libcudnn.so.6.5.18 /usr/local/lib/libcudnn.so.6.5
            
            OpenBLAS
            git clone https://github.com/xianyi/OpenBLAS
            cd OpenBLAS
            make
            mkdir build
            make install PREFIX=build
            leveldb
            git clone https://github.com/google/leveldb
            cd leveldb
            make
            sudo cp --preserve=links libleveldb.* /usr/local/lib
            sudo cp -r include/leveldb /usr/local/include/
            sudo ldconfig
            others
            sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libboost-all-dev libhdf5-serial-dev libgflags-dev libgoogle-glog-dev liblmdb-dev protobuf-compiler
          • Install caffe and testing
          • git clone https://github.com/BVLC/caffe
            cd caffe
            cp Makefile.config.example Makefile.config
            gedit Makefile.config
            edit:
            • USE_CUDNN := 1
            • BLAS := open
            • BLAS_INCLUDE := your-path-to-blas/OpenBLAS/build/include
            • BLAS_LIB := your-path-to-blas/OpenBLAS/build/lib
            install
            #compile
            make all
            # test
            make testexport LD_LIBRARY_PATH=~/Library/OpenBLAS/build/lib/
            make runtest

          2014年3月28日 星期五

          Eclipse 更新 adt 22.6.2

          不知怎麼,最近想更新 adt 22.6.2 ,卻一直出問題,最後是直接上官網下載 ADT-22.6.2.zip,但是更新完變成 sdk 不能更新了,最後是設定 Android SDK Manager 的 proxy,才解決,另外發現用宿舍網路還是有一部份被擋下來,所以改用吃到飽下載.....

          Android SDK Manager => Settings

          HTTP Proxy Server : www.google.com

          HTTP Proxy Port : 80


          2013年11月10日 星期日

          Conversion to Dalvik format failed: Unable to execute dex: java.nio.BufferOverflowException. Check the Eclipse log for stack trace

          如題,Import Android Project 之後 run,有時會出現這問題


          [2013-11-10 17:54:15 - Dex Loader] Unable to execute dex: java.nio.BufferOverflowException. Check the Eclipse log for stack trace.
          [2013-11-10 17:54:15 - testAndroid] Conversion to Dalvik format failed: Unable to execute dex: java.nio.BufferOverflowException. Check the Eclipse log for stack trace.


          此時需要在專案上

          點右鍵 → Build Path 將Android Dependecies Reamove 即可



          Remove Android Dependecies