Saturday, May 10, 2008

Installing Matlab on Linux

Unfortunately, Matlab is not free!! and i currently only have Matlab 7 R14 student version. In any case we'll install Matlab on linux..

step 1: insert the CD into the CD-ROM
step 2: go to /media/cdrom (that is in ubuntu)
step 3: sudo ./install_unix.sh
this will run a "nice" installer, it'll prompt you for a root directory for matlab files. If you keep your /home partition separate from the / partition then install matlab somewhere in /home so you don't have to install it every time you feel like getting a new linux version, otherwise /usr/local/matlab sounds like a good choice.
The script will also ask you if you want to create symlinks in /usr/local/bin or whatever directory in the $PATH, it is a good idea to say 'y' so that you don't have to put the full path name every time you feel like Matlabing :)
step 4: install gawk so Matlab will hopefully work, and you also should have java installed preferably java-sun, not the gcj; sudo apt-get install gawk
step 5: go to where ever you installed matalb, say /usr/local/matlab and enter the bin directory /usr/local/matlab/bin and run ./matlab this will ask you for the serial number, enter your serial number and enjoy Matlabing for the rest of the night!!
* Notice that a "student license" is only good for one computer :(

Have fun!

Friday, May 9, 2008

OpenCV stuff 0

Hello world,
we'll do opencv cool things running on Linux, as I have no idea how to do any of the stuff with visual studio

we'll start with a very simple example that will draw nice shapes in an image

#include <opencv/cv.h>
#include <opencv/cvaux.h>
#include <opencv/highgui.h>
#include <stdio.h>
#include <l;stdlib.h>

// a simple example that creates an image and fills it up with stuff
int main(int argc, char *argv[])
{
IplImage *img;
int i, j, step, channels, height, width;
uchar *data;

// WxH, depth, channels
img = cvCreateImage(cvSize(640,480), 8, 1);
height = img->height;
width = img->width;
step = img->widthStep;
channels = img->nChannels; // which is 1 (gray image)
data = (uchar *)img->imageData;

for(i=0; i < height; i++)
for(j=0; j < width; j++)
data[i*step + j*channels] = (i*i + j*j) % 256;

// create a window
cvNamedWindow("image", CV_WINDOW_AUTOSIZE);
// show the image
cvShowImage("image", img);
// wait for 'q'
while(cvWaitKey(0) != 'q')
;

// destroy the widnow
cvDestroyWindow("image");
// don't forget to release the image
cvReleaseImage(&img);

return 0;
}

Cool... now to compile the opencv program, it is even easier, we'll use gcc here:

gcc `pkg-config --cflags --libs opencv` -o opencvsimple opencvsimple.c


Done!