Tuesday, July 04, 2006

Updates

It has been awhile since I last blog here.
The past 3 months, I was working on deformation (rigid, affine and non-rigid), Linear Discriminant Analysis and Statistical Analysis. I know I should upload these details but I have not gotten the time to do so yet. Furthermore, I have been too engrossed blogging on the World Cup 2006, in which I must refrain myself from doing so in here too.

This week's objectives:
1. Continue my reading on Singular Value Decomposition and start svd programming
2. MUST complete the svd program by the end of Friday
3. Concurrently, understand on how multilinear works
4. And finally, semi-final football is on Wednesday. I want Germany and France to be in the final, and Germany to win!

Thursday, March 23, 2006

Display 3D face with texture

/*
Decription: display vtk + texture
*/
#include "vtkActor.h"
#include "vtkActor2D.h"
#include "vtkBMPReader.h"
#include "vtkCamera.h"
#include "vtkCommand.h"
#include "vtkDataSetMapper.h"
#include "vtkDataSetWriter.h"
#include "vtkFloatArray.h"
#include "vtkPointData.h"
#include "vtkPolyData.h"
#include "vtkPolyDataMapper.h"
#include "vtkPolyDataReader.h"
#include "vtkPolyDataWriter.h"
#include "vtkProperty.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkTextMapper.h"
#include "vtkTextSource.h"
#include "vtkTexture.h"
#include "vtkTextProperty.h"
#include
#include
#include

void usage()
{
cerr << "Display VTK " < cerr << "Usage: display [source]" << endl;
exit(1);
}

vtkPolyData *faceOutput, *originalface;
vtkActor *faceActor;
vtkTextMapper *textmapper;
vtkPolyDataMapper *faceMapper;

std::string strg;
char *face, *bitmapfile;

int main (int argc, char **argv)
{
if (argc < 2) {
usage();
}

face = new char[200];
bitmapfile = new char[200];

vtkRenderer *renderer = vtkRenderer::New();
vtkRenderWindow *renWin = vtkRenderWindow::New();
renWin->AddRenderer(renderer);

vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
iren->SetRenderWindow(renWin);

// read face file
vtkPolyDataReader *facefile = vtkPolyDataReader::New();
facefile->SetFileName(argv[1]);
strg = argv[1];
argv++; argc--;

//locate the texture of the face
strcpy(face, strg.c_str());
strg.replace(strg.find(".vtk"), 4, ".bmp");
strcpy(bitmapfile, strg.c_str());

facefile->Update();
facefile->Modified();
faceOutput = facefile->GetOutput();
facefile->Update();
facefile->Modified();
cout << "Opening file: " << face << "(" << facefile->GetOutput()->GetNumberOfPoints() << " points)" << endl;
originalface = vtkPolyData::New();

//map texture
originalface->DeepCopy(faceOutput);
vtkBMPReader *_texture_BMP = vtkBMPReader::New();
vtkTexture *_texture = vtkTexture::New();
_texture->SetInput(_texture_BMP->GetOutput());
_texture_BMP->SetFileName(bitmapfile);
faceMapper = vtkPolyDataMapper::New();
faceMapper->SetInput(faceOutput);
faceActor = vtkActor::New();
faceActor->SetMapper(faceMapper);
faceActor->SetTexture(_texture);

//display text
vtkActor2D *textactor = vtkActor2D::New();
textmapper = vtkTextMapper::New();
textactor->SetMapper(textmapper);
vtkTextProperty *textproperty = vtkTextProperty::New();
textproperty->SetFontSize(18);
textproperty->BoldOn();
textmapper->SetTextProperty(textproperty);
textmapper->SetInput("Face data from ");

//display output
renderer->AddActor(textactor);
renderer->AddActor(faceActor);
renderer->SetBackground(0,0,0);
renWin->SetSize(400,400);

// interact with data
double *xyz;
xyz = facefile->GetOutput()->GetCenter();
renderer->GetActiveCamera()->SetFocalPoint(*xyz, *(xyz+1), *(xyz+2));
renWin->Render();
iren->Start();

//delete
renderer->Delete();
renWin->Delete();
iren->Delete();
facefile->Delete();
faceMapper->Delete();
faceActor->Delete();
}

Wednesday, February 15, 2006

when setting environment in ~/.cshrc

Make sure there is no space in between argument in $PATH, otherwise you will get an error msg that says 'setenv : too many argument'

This will lead to unable to locate the libvtk***.so libraries

Monday, February 13, 2006

Jacey's emacs

% emacs ~/.cshrc
******************************************

alias pd pushpd
alias e emacs -geometry 81x71+380+0

setenv PROJECT_DIR $HOME/projectCVS
setenv QTDIR /homes/jl/qt4
#setenv VTKDIR /vol/vtk/vtk-4.5.0
setenv VTKDIR /homes/jl/vtk/VTK
setenv CMAKEDIR /homes/jl/Cmake

setenv PATH $PROJECT_DIR/linux/bin:$QTDIR/bin:$CMAKEDIR/bin:$VTKDIR/bin:
/homes/jl/tmp/vtkqt:/homes/jl/include/vtk:$QTDIR/include:$PATH
setenv LD_LIBRARY_PATH $QTDIR/lib:/homes/jl/tmp/vtqt:/homes/jl/lib/vtk
setenv MANPATH $QTDIR/doc/man
#setenv QMAKESPEC $QTDIR/mkspecs

**********************************************************************

QT installation

Reference:
www.doc.trolltech.com

Installation steps in Linux:
1) download QT
2) gunzip (qt-XXXX.tar.gz)
3) tar xvf (qt-XXXX.tar)
4) ./configure --prefix=/homes/jl
5) make
6) make install


At last!!!

CMake

Reference:
www.cmake.org

Installation steps in Linux (only):
1) download CMake in www.cmake.org/HTML/Download.html
e.g. cmake-2.0.6-x86-linux.tar.gz
2) cd (to $HOME)
3) mkdir cmake
4) cd cmake
5) gunzip cmake-2.0.6-x86-linux.tar.gz
6) tar xvf cmake-2.0.6-x86-linux.tar
7) tar xvf cmake-2.0.6-x86-linux-files.tar
8) download source code, cmake-2.0.6.tar.gz
9) tar xvfz cmake-2.0.6.tar.gz
10) mkdir cmake-bin
11) cd cmake-bin
12) ../cmake-bin/boostrap --prefix=($HOME)/cmake
13) make
14) make install

At last!!!!!!

CMake, VTK, QT Installation

For the last 2 weeks (excluding this week), I have been spending most of my time installing, building opensource programs - CMake, VTK and QT! Many problems arised were mainly due to my typical laziness and inefficiency in organising and managing my work.

Last Thursday night, I've decided (as advised by Raj, as usual) to manage all the programs in one workstation. Well, I was stubborned in the beginning, but now I am left with no choice but to proceed with his "brilliant' suggestion. ;(

Today, Geoff from CSG came to reinstall my windows and Linux! Managed to install CMake (hopefully I did it correctly), now QT..later tonight, VTK.

More Infor:
CMake infor can be found in www.cmake.org
VTK in www.vtk.org
QT in www.trolltech.com

This page is powered by Blogger. Isn't yours?