2017年5月22日 星期一

Install opencv3.2.0 and opencv_contrib3.2.0 with CUDA7.5

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install build-essential cmake pkg-config
sudo apt-get install libjpeg8-dev libtiff5-dev libjasper-dev libpng12-dev
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
sudo apt-get install libxvidcore-dev libx264-dev
sudo apt-get install libgtk-3-dev
sudo apt-get install libatlas-base-dev gfortran

download:

https://github.com/opencv/opencv/releases
https://github.com/opencv/opencv_contrib/releases

確保兩個版本一致都是3.2

cd ~/opencv-3.2.0
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_OPENGL=ON -D ENABLE_FAST_MATH=1 -D CUDA_FAST_MATH=1 -D WITH_CUBLAS=1 -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.2.0/modules ..
make -j8
sudo make install
sudo ldconfig

======================================================================
install opencv from pip
sudo pip install opencv-python
sudo pip install opencv-contrib-python:
======================================================================
issus:

fata error: LAPACKE_H_PATH-NOTFOUND when building OpenCV 3.2
sudo apt-get install liblapacke-dev checkinstall

If use nvidia-docker to install opencv with cuda, the issue is following
linked by target "example_gpu_alpha_comp" in directory /home/image/opencv-3.2.0/samples/gpu
-- Configuring incomplete, errors occurred!

Don't forget add
-DCMAKE_LIBRARY_PATH=/usr/local/cuda/lib64/stubs
after cmake
refference:
https://github.com/opencv/opencv/issues/6577

If using python don't forget install numpy
pip install numpy

2015年3月22日 星期日

opencv with cuda error

when i test my opencv package in c file by using the command
$ gcc cvtest.c -o cvtest  `pkg-config opencv --cflags --libs`
There are with some error

/usr/bin/ld: cannot find -lcufft
/usr/bin/ld: cannot find -lnpps
/usr/bin/ld: cannot find -lnppi
/usr/bin/ld: cannot find -lnppc
/usr/bin/ld: cannot find -lcudart

According to this post in stackoverflow
http://stackoverflow.com/questions/24322466/makefile-opencv-stopped-working

i change the command with -L to my cuda lib path
$gcc -L /usr/local/cuda/lib64 cvtest.c -o cvtest  `pkg-config opencv --cflags --libs`

it's working

or put the cuda lib path in LIBRARY_PATH
export LIBRARY_PATH=/usr/local/cuda/lib64

2015年3月16日 星期一

WIN7 + UBUNTU Installtation

先裝win7後裝UBUNTU14.04 直接進入UBUNTU的解決方式

sudo update-grub

sudo gedit /etc/default/grub


將 GRUB_HIDDEN_TIMEOUT=0註解

#GRUB_HIDDEN_TIMEOUT=0

sudo update-grub

sudo reboot

2015年1月14日 星期三

R tm

when using



library(tm)
library(tm.plugin.mail)

#'corpus' folder in current path, 'SPAM' folder in 'corpus'
cname <- file.path(".", "corpus","SPAM")

# readMail from "tm.plugin.mail" can remove some heads of email
docs <- Corpus(DirSource(cname),readerControl = list(reader = readMail))

#docs <- Corpus(DirSource(cname)) #read mail as text

for (j in seq(docs))
{
    #change encoding from "iso-8859-1" to "UTF-8"
    docs[[j]]<- iconv(docs[[j]],"iso-8859-1","UTF-8")

    # Transforms
    docs[[j]] <- gsub("/", " ", docs[[j]])                      #transform "/" to " "
    docs[[j]] <- gsub("@", " ", docs[[j]])
    docs[[j]] <- gsub("\\|", " ", docs[[j]])
    docs[[j]] <- gsub("specific transform", "ST", docs[[j]])
    docs[[j]] <- gsub("other specific transform", "OST", docs[[j]])
}

docs <- tm_map(docs, tolower, iconv(enc2utf8(docs), sub = "byte"))  #lowercase
docs <- tm_map(docs, removeNumbers)
docs <- tm_map(docs, removePunctuation)
docs <- tm_map(docs, removeWords, stopwords("english"))
docs <- tm_map(docs, removeWords, c("own", "stop", "words", "oil"))
docs <- tm_map(docs, stripWhitespace)
docs <- tm_map(docs, stemDocument) #stemming
# Document term matrix.
dtm <- DocumentTermMatrix(docs) # documents as the rows,  terms as the columns
#dtm <- DocumentTermMatrix(docs, control=list(weighting = weightTfIdf))     # tfidf

opencv anaconda error

when import cv2, there is an error

ImportError: /anaconda/bin/../lib/libm.so.6: version `GLIBC_2.15' not found (required by /usr/lib/x86_64-linux-gnu/libxvidcore.so.4)

just copy libm.so.6 from '/usr/lib/x86_64-linux-gnu' to '/home/username/anaconda/lib/'
then it can work

2015年1月4日 星期日

install error on rnnlib

rnnlib source
http://sourceforge.net/p/rnnl/wiki/Home/

refer to
http://sourceforge.net/p/rnnl/discussion/1183966/thread/84f2025b/#742b/f9c9/c849/5687

error message:
Helpers.hpp:311:41: error: ‘range_min_size’ was not declared in this scope
Container.hpp:157:24: error: ‘resize’ was not declared in this scope

Helpers.hpp:
Moving the 4 templates for range_min_size to the top of the file fixed all the issues.

move line 532 ~ 547 to line 163

 template<class R1, class R2> static size_t range_min_size (const R1& a, const R2& b)
{
    return min(boost::size(a), boost::size(b));
}
template<class R1, class R2, class R3> static size_t range_min_size (const R1& a, const R2& b, const R3& c)
{
    return min(min(boost::size(a), boost::size(b)), boost::size(c));
}
template<class R1, class R2, class R3, class R4> static size_t range_min_size (const R1& a, const R2& b, const R3& c, const R4& d)
{
    return min(min(min(boost::size(a), boost::size(b)), boost::size(c)), boost::size(d));
}
template<class R1, class R2, class R3, class R4, class R5> static size_t range_min_size (const R1& a, const R2& b, const R3& c, const R4& d, const R5& e)
{
    return min(min(min(min(boost::size(a), boost::size(b)), boost::size(c)), boost::size(d)), boost::size(e));
}

Container.hpp:
On line 157, revise "resize" instead of "this->resize."


2014年12月7日 星期日

Installing UBUNTU without finding SATA HD

Installing UBUNTU without finding SATA HD
Reference from
http://www.pendrivelinux.com/ubuntu-installer-cant-find-my-sata-drive/

How I made Ubuntu Installer detect my SATA drive

Boot Ubuntu from a Live CD or Live USB
Open a Terminal (Applications > Accessories > Terminal) and type sudo su
Type fdisk -l (note which device is your SATA drive)
Type dmraid -E -r /dev/sdX
(Replacing X with your actual device found in step 3)
Confirm that yes, you wish to remove the dmraid information
Return to the desktop and proceed to run the Ubuntu Installer