Visualizzazione post con etichetta api. Mostra tutti i post
Visualizzazione post con etichetta api. Mostra tutti i post

lunedì 4 maggio 2009

Numpy for Matlab users: getting in touch with Numpy!!!!

http://www.scipy.org/NumPy_for_Matlab_Users
On the link above the official documentation about compairisons between Matlab and Numpy: bloody interesting and usefull!

From MATLAB to PYTHON!!!!

http://vnoel.wordpress.com/2008/05/03/bye-matlab-hello-python-thanks-sage/
On the link above, I've found an interesting article about migrating from closed source Matlab to very very open source Python...thanks God, Guido has done that snake!

lunedì 27 aprile 2009

SVD algorithm in Numpy

http://www.scipy.org/doc/numpy_api_docs/numpy.linalg.linalg.html#svd

Numpy routine implementing svd operation, usefull for triangulating points.svd(a, full_matrices = 1, compute_uv = 1)
Singular Value Decomposition.

u,s,vh = svd(a)

If a is an M x N array, then the svd produces a factoring of the array
into two unitary (orthogonal) 2-d arrays u (MxM) and vh (NxN) and a
min(M,N)-length array of singular values such that

a == dot(u,dot(S,vh))

where S is an MxN array of zeros whose main diagonal is s.

if compute_uv == 0, then return only the singular values
if full_matrices == 0, then only part of either u or vh is
returned so that it is MxN

sabato 25 aprile 2009

Face detection with openCV python bindings

http://eclecti.cc/olpc/face-detection-on-the-olpc-xo

http://blog.jozilla.net/2008/06/27/fun-with-python-opencv-and-face-detection/

On the link above you can find the following code:

#!/usr/bin/python

# Face Detection using OpenCV. Based on sample code by Roman Stanchak
# Nirav Patel http://eclecti.cc 5/20/2008

import sys, os
from opencv.cv import *
from opencv.highgui import *

def detectObject(image):
grayscale = cvCreateImage(cvSize(640, 480), 8, 1)
cvCvtColor(image, grayscale, CV_BGR2GRAY)
storage = cvCreateMemStorage(0)
cvClearMemStorage(storage)
cvEqualizeHist(grayscale, grayscale)
cascade = cvLoadHaarClassifierCascade('haarcascade_frontalface_alt.xml',
cvSize(1,1))
faces = cvHaarDetectObjects(grayscale, cascade, storage, 1.2, 2,
CV_HAAR_DO_CANNY_PRUNING, cvSize(100,100))

if faces:
for i in faces:
cvRectangle(image, cvPoint( int(i.x), int(i.y)),
cvPoint(int(i.x+i.width), int(i.y+i.height)),
CV_RGB(0,255,0), 3, 8, 0)

def displayObject(image):
cvNamedWindow("face", 1)
cvShowImage("face", image)
cvWaitKey(0)
cvDestroyWindow("face")

def main():
# Uses xawtv. Gstreamer can be used instead, but I found it much slower
os.system("v4lctl snap jpeg 640x480 /tmp/face.jpg")
image = cvLoadImage("/tmp/face.jpg")
detectObject(image)
displayObject(image)
cvSaveImage("/tmp/face.jpg", image)

if __name__ == "__main__":
main()

Experimental funcionalities in openCV

http://www710.univ-lyon1.fr/~bouakaz/OpenCV-0.9.5/docs/ref/OpenCVRef_Experimental.htm#decl_cvFindStereoCorrespondence

On the link above some information about experimental openCV's functionalities in stereo-matching and object recognition.

OpenCV: Effort for 3D reconstruction

http://opencv.willowgarage.com/wiki/EffortFor3dReconstruction

On the link above, some documentation about openCV api's routines for 3D reconstructing processes.

giovedì 23 aprile 2009

VTK: Delaunay triangulation

http://www.vtk.org/doc/release/5.0/html/c2_vtk_e_1.html#c2_vtk_e_vtkDelaunay3D

vtk: triangulation and texturizing

http://www.kino3d.com/forum/viewtopic.php?t=4705&postdays=0&postorder=asc&start=60&sid=56ed646e2abdf2c07ee06da807f2cace

Interesting link where you can find some vtk(python) code for triangulation and meshing operations.

Image to Array with numpy.asarray()

http://docs.scipy.org/doc/numpy/reference/index.html
At the link above you can find a sort of reference manual of Numpy.
Here some sample code from: http://stackoverflow.com/questions/524930/numpy-pil-adding-an-image

from PIL import Image
from numpy import *

im1
= Image.open('/Users/rem7/Desktop/_1.jpg')
im2
= Image.open('/Users/rem7/Desktop/_2.jpg')


im1arr
= asarray(im1)
im2arr
= asarray(im2)

Image to Array, array to Image

http://mail.python.org/pipermail/python-list/2000-August/046892.html

These are code and comments from the code above:


It is straightforward to convert Numeric arrays into PIL images:
#--------------------
from Numeric import *
from Pil import Image

# construct an arbitrary Numeric matrix
dims = (256,256)
arr = zeros(dims,Int8)
for i in xrange(dims[0]):
arr[i,i] = 255

# and convert it to an Image
img = Image.fromstring('L',dims,arr.tostring())
img.save('foo.gif')
#--------------------

or to convert from a PIL image back to a Numeric array:

#--------------------
from Numeric import *
from Pil import Image

newImg = Image.open('foo.gif')
newArr = fromstring(newImg.tostring(),Int8)
newArr = reshape(newArr,newImg.size)
#-------------------

If you are constructing images from Numeric arrays, don't forget that
the Image values should run from 0-255, so you'll need to scale your
data in the Numeric array before creating the image.

mercoledì 22 aprile 2009

SIFT Python Implementation

http://jesolem.blogspot.com/2009/02/sift-python-implementation.html

This is the text and the code from the link above:

I'd like to share a Python interface I wrote for David Lowe's Scale Invariant Feature Transform (SIFT) implementation. David, the inventor of SIFT, has since several years generously shared binaries with a Matlab interface on his website. Inspired by the Matlab files for reading keypoint descriptor files and for matching between images, I decided to write a Python version. Here it is: sift.py.

The file itself should be self-explanatory, especially together with the documentation that comes with Lowe's zip-file. Anyway, here's an example:

>>>from PIL import Image
>>>from numpy import *
>>>import sift

>>>sift.process_image('basmati.pgm', 'basmati.key')
>>>l1,d1 = sift.read_features_from_file('basmati.key')
>>>im = array(Image.open('basmati.pgm'))
>>>sift.plot_features(im,l1)



Gandalf Computer Vision Api

This is the link to library documentation:http://gandalf-library.sourceforge.net/tutorial/report/report.html