Sunday, September 10, 2017



Frustrated with phpmyadmin setup in Ubuntu 16.04?


After spending about 5 hours trying to get phpmyadmin to work with mysql on ubuntu I finally switched gears and started looking at an alternative - mywebsql

This link below explains step by step how to install this lightweight web interface to the mysql and the configuration is much simpler than phpmyadmin. So bye-bye phpmyadmin and hello mywebsql


https://www.linuxhelp.com/how-to-install-mywebsql-on-ubuntu/

Friday, August 25, 2017

OpenCV 3.1 Build commands

OpenCV 3.1

sudo apt-get update -y

sudo apt-get upgrade -y

sudo apt-get install build-essential cmake pkg-config  -y

sudo apt-get install libjpeg8-dev libtiff5-dev libjasper-dev libpng12-dev -y

sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev -y

sudo apt-get install libxvidcore-dev libx264-dev -y

sudo apt-get autoclean

sudo apt-get install libgtk-3-dev -y

sudo apt-get install libatlas-base-dev gfortran -y

sudo apt-get install python2.7-dev -y

sudo apt-get install tree unzip -y

sudo apt-get install python-pip -y

sudo -H pip install pip -U

sudo apt-get remove python3 --purge -y

sudo -H pip install numpy -U

sudo  apt-get install --upgrade ipython

sudo -H pip install jupyter -U



##############################################################
cd ~
wget -O opencv.zip https://github.com/Itseez/opencv/archive/3.1.0.zip
rm -rf ~/opencv-3.1.0
unzip opencv.zip
rm -rf ~/opencv_contrib-3.1.0
wget -O opencv_contrib.zip https://github.com/Itseez/opencv_contrib/archive/3.1.0.zip
unzip opencv_contrib.zip


#########################################################
cd ~/opencv-3.1.0/
rm -rf build
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE \
    -D CMAKE_INSTALL_PREFIX=/usr/local \
    -D INSTALL_PYTHON_EXAMPLES=ON \
    -D INSTALL_C_EXAMPLES=OFF \
    -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.1.0/modules \
    -D PYTHON_EXECUTABLE=/usr/bin/python \
    -D BUILD_EXAMPLES=OFF  ..


###############################################################

make -j4

sudo make install

sudo ldconfig

sudo ln -sf /home/ubuntu/opencv-3.1.0/build/lib/cv2.so  /usr/local/lib/python2.7/site-packages/cv2.so


Monday, July 31, 2017

Python and OpenCV 3.1


First you need Jupyter and AWS ubuntu 16.04
https://www.rosehosting.com/blog/how-to-install-jupyter-on-an-ubuntu-16-04-vps/

All the powerful feature descriptors are 3rd party extensions which need special build of OpenCV

Prior to installing OpenCV, resolve some dependencies like Tesseract, PyVTK etc.,
https://medium.com/@lucas63/installing-tesseract-3-04-in-ubuntu-14-04-1dae8b748a32
https://lucacerone.net/2017/install-tesseract-3-0-5-in-ubuntu-16-04/

Then proceed with OpenCV build
http://www.pyimagesearch.com/2016/10/24/ubuntu-16-04-how-to-install-opencv/

You will run into a snag with the OpenCV build. Here is how to resolve it:
https://github.com/opencv/opencv/issues/6016

locate the file:modules/python/common.cmake and append 2 lines of code 
find_package(HDF5)

include_directories(${HDF5_INCLUDE_DIRS})


The way to access the features has changed from OpenCV 2.4 days to OpenCV 3.1
Reference: http://www.pyimagesearch.com/2015/07/16/where-did-sift-and-surf-go-in-opencv-3/#comment-431206


Some great descriptors are DCT, GLCM, FLANN, LUCID, ORB, BRIEF, SURF and SIFT, Gabor

https://www.researchgate.net/post/I_want_to_extract_Haralick_texture_features_in_openCV2
https://stackoverflow.com/questions/19556538/how-to-find-glcm-of-an-image-in-opencv-or-numpy
http://docs.opencv.org/3.0-beta/doc/py_tutorials/py_feature2d/py_orb/py_orb.html
http://docs.opencv.org/3.1.0/d5/d51/group__features2d__main.html
http://docs.opencv.org/3.0-beta/doc/py_tutorials/py_feature2d/py_matcher/py_matcher.html
http://answers.opencv.org/question/63517/how-to-successfully-implement-a-gabor-filtering/
http://docs.opencv.org/3.0-beta/modules/imgproc/doc/filtering.html
https://gist.github.com/odebeir/5237529

Finding the best features which are rotation invariant, scale invariant, resolution invariant, robust against blurring etc., is a challenge.


Of course going with a deep-learning way of classification would imply that there is no need to explicitly do feature extraction

http://www.wolfib.com/Image-Recognition-Intro-Part-1/
https://research.googleblog.com/2016/03/train-your-own-image-classifier-with.html
https://github.com/rdcolema/tensorflow-image-classification/blob/master/cnn.ipynb

Finally, remember to run Jupyter from this location so that the cv2 version is set to 3.1.0

~/.virtualenvs/cv/lib/python2.7/site-packages$


Tuesday, July 25, 2017

Setting up R Server Connect

R Server Connect is a great piece of software!
It allows data scientists to publish their static or interactive dashboards which might be RMarkdown or Shiny applications

But one is bound to run into installation problems like I did.

Please ensure that the following dependencies are met.

Rstudio IDE:
install.packages('rsconnect')


install.packages("devtools", dependencies=TRUE)

Linux Shell:
sudo apt-get install r-cran-rserve
sudo apt-get install openssl
sudo apt-get install libssl-dev
sudo apt-get install libcurl4-gnutls-dev
sudo apt-get install libxml2-dev


Tuesday, June 13, 2017

Python Threads (lifesaver!)

https://pymotw.com/2/threading/

Monday, June 5, 2017

Gitlab server

This gave me some pain! How to set up gitlab server for my team and then be able to use just the IP address and not the DNS name. I had to use the IP address since the network admin policy was that unless a static ethernet cable-based IP address was allotted to my desk they would not be able to provide me DNS name. So until then I decided to use Virtual Box with Bridged-adapter network configuration and then use the IP address that the network switch would allocate to my virtual machine as though it were a separate node in the network to run my gitlab server on.

There was one little thing that took 2 days to figure out.
Where do you set up the IP address for gitlab server?

Add this following line to the file gitlab.rb:

sudo vim /etc/gitlab/gitlab.rb
external_url 'http://xxx.xxx.xxx.xxx'


VirtualBox VMDK from VMWare


Copy paste the following into a shell script and run:
[Reference: https://github.com/caskroom/homebrew-cask/issues/3333]

Quite useful tips!
http://brianflove.com/2014/06/09/vmware-fusion-to-virtual-box/

(
  cd /tmp;
  vbox_full_version=$(brew cask info virtualbox | head -1 | cut -d' ' -f2);
  vbox_short_version=${vbox_full_version/-*};
  curl -L -O http://download.virtualbox.org/virtualbox/${vbox_short_version}/Oracle_VM_VirtualBox_Extension_Pack-${vbox_full_version}.vbox-extpack;
  sudo VBoxManage extpack install --replace Oracle_VM_VirtualBox_Extension_Pack-${vbox_full_version}.vbox-extpack;
  rm *.vbox-extpack;
)

Monday, May 22, 2017

VirtualBox and networking

Today I had a rather interesting requirement - I needed to run a gitlab instance for my team. I decided I would use one of the servers' hardware and install a virtual machine using VMWare's client for Mac OS called Fusion. In the past I had encountered difficulties in being able to spin up a VM which was visible and ping-able in the intranet using VMWare clients. Yet I tried to go down that path again. It was a bit frustrating and I hopped from one stackoverflow article to another and finally gave up. I switched to VirtualBox and brought up a simple webserver in one line :

python -m SimpleHTTPServer 8000

Once I did this, I made sure this was accessible from browser as http://localhost:8000. I wanted to be able to access this from browser running on another host. So in order to do that I enabled a bridged adapter configuration on the network adapter. Some organizations do not support it. But I was lucky that my organization supported this - awarding an IP address to a VM's network adapter. Then it worked!
On the Mac OS window after launching the VirtualBox go to Machine-> Settings and then choose Network. Select Bridged Adapter and the default settings in Advanced menu. That should do it.

References:
How to set up a firewall  in Ubuntu:
https://www.digitalocean.com/community/tutorials/how-to-set-up-a-firewall-with-ufw-on-ubuntu-16-04