Sunday, April 17, 2016

Get Bash on Windows 10 Build 14316

To get Bash (Ubuntu) as part of Windows 10, you first need to become an 'insider'.
  • Go to Settings > Update & Security > Advanced Options and toggle the Get Insider Preview Builds option with the level to Fast.
  • From Settings > Update & Security > For Developers enable Developer mode.
  • Go to Settings > Update & Security > Advanced Options and in the section Choose how updates are delivered, turn the option for PC's on my local network and the internet on. (This isn't required, but let me download the build immediately after I enabled it).
  • After you get the build, go to Programs and Features from the Control Panel and choose option Turn Windows Features on or off. Enable Windows subsystem for Linux (Beta)
  • Search for bash in the start menu and you're all set!



Saturday, April 16, 2016

IPython freeze on OpenCV destroyAllWindows

If you are running OpenCV on an IPython console, chances are cv2.destroyAllWindows() will freeze your image window and ultimately kill the kernel. To get around this, intersperse your code with the following functions (startWindowThread() and waitKey(1)) :

cv2.namedWindow('image')
cv2.startWindowThread()
.
.
.
cv2.waitKey(1)
cv2.destroyAllWindows()
cv2.waitKey(1)

Should hopefully solve the issue!

OpenCV Error on Anaconda


Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config

Solution:
conda remove opencv
conda update conda
conda install --channel menpo opencv

This installs the opencv from public channel menpo which works fine.

Saturday, March 5, 2016

Convert binaryproto format to numpy (Readable)

To view the values of image-mean data stored in binaryproto format, use the following:

import caffe
import numpy as np
import sys

blob = caffe.proto.caffe_pb2.BlobProto()
data = open( 'YOURBPFILE.binaryproto' , 'rb' ).read()
blob.ParseFromString(data)

arr = np.array( caffe.io.blobproto_to_array(blob) )
print arr


Tuesday, September 15, 2015

Pickled Object Problem

When unpickling an object of some class, if you encounter the error,
AttributeError: 'module' object has no attribute 'classname'
read this.

Insert Code in the 'right format' in Blogger Posts

To insert code into blogger posts, use one of the following :
  1. htmlify
  2. markup
  3. hilite.me

Saturday, February 7, 2015

Building MEX files in MATLAB 2014B on Ubuntu 14.04

Ubuntu 14.04 by default has the compiler GCC 4.8, but Matlab R2014b .mex files require GCC 4.7.x

Error: You are using gcc version '4.8.2'. The version of gcc is not supported.
Solution:

Install GCC 4.7 and G++ 4.7

sudo apt-get install gcc-4.7 g++-4.7

Copy the mex-options file 
cp /usr/local/MATLAB/R2014b/bin/mexopts.sh ~/.matlab/R2014b/mexopts.sh

Provide read permissions
chmod 644 ~/.matlab/R2013b/mexopts.sh

Make edits
vim ~/.matlab/R2013b/mexopts.sh

Change :
CC=’gcc’ to CC=’gcc-4.7′
CCX=’g++’ to CCX=’g++-4.7′