Code covered by the BSD License  

Highlights from
ICAAM - Inverse compositional Active Appearance Models

5.0

5.0 | 1 rating Rate this file 102 Downloads (last 30 days) File Size: 60.8 KB File ID: #32704
image thumbnail

ICAAM - Inverse compositional Active Appearance Models

by

 

26 Aug 2011 (Updated )

An implementation of inverse-compositional Active Appearance Models capable of real-time performance

| Watch this File

File Information
Description

This is an implementation of real-time inverse compositional Active Appearance Models (AAMs), as described in the "Active Appearance Models Revisited" paper by Iain Matthews and Simon Baker.

Experimental support is provided for the 3D extensions to inverse compositional AAMs, also developed by Matthews and Baker in their "2D vs. 3D Deformable Face Models" and "Real-Time Combined 2D+3D Active Appearance Models" papers.

As an aid to ease the task of building the 3D shape model needed by the 3D extensions, an implementation of the closed-form shape-from-motion algorithm by Jing Xiao and Takeo Kanade is provided. And while I can't guarantee the quality of the results given by this latter implementation, it shouldn't be far from correct as it's heavily based on Xiao's implementation.

Look up "icaam" on Sourceforge.net to get the latest release, the data required by the examples and more!

Required Products Image Processing Toolbox
Statistics Toolbox
MATLAB release MATLAB 7.7 (R2008b)
Other requirements C++ compiler for building mex-file (the one included in MATLAB should work).
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (43)
16 Apr 2014 Luca Vezzaro

@Elaungkumaran:

1. This is creating the annotations variable:

load(sprintf('cootes/%s', training_files(i).name));

Use the build_model_2d_from_files to not be exposed to such intricacies.

2. What do you mean? fit_2d is the function to fit. You need to provide a shape to start the fit. As AAMs don't do face detection you need to first apply a face detection algorithm to detect the approximate location of the face and use that to fit your AAM to the detected face.

15 Apr 2014 Elangkumaran

I have a couple of queries:
1. The examples/fit2d_test.m loads shape using
shapes(:,:,i) = xy2ij(annotations, size(app,1));
but the variable 'annotations' is not declared previously. Where do you get the annotations and load to 'shapes'?

2. How do I fit the AAM to a file with an initial shape? (i.e. a non-annotated image). I am a beginner in this area and can't seem to make it work

21 Jun 2013 Luca Vezzaro

I'll try to fix the issue, but first I need to get MATLAB 2012b. I'll see what I can do.

21 Jun 2013 Luca Vezzaro

Please use a older MATLAB version, if you can.

18 Jun 2013 Anika

Hi Luca,
I am using MATLAB 2012b at the moment (sorry for the typo). I just tried icaam-1.0-r17 with 2013-04-23 as last update, which is the latest version accoring to sourceforge. However, I still get the same error with PCA as before.

I also tried to replace princomp() with pca(), but this causes another error later in the code, so I assume that these two methods have different outputs.

17 Jun 2013 Luca Vezzaro

Anika, do you mean Matlab R2011b?

Are you sure you're using the latest version from here? http://sourceforge.net/projects/icaam/files/

17 Jun 2013 Anika

When I try to run the code with MATLAB 1021b, I run into problems with PCA. the following error message pops up, when running tesi_train.m

Error using pca
Too many input arguments.

Error in princomp (line 29)
[varargout{1:nargout}]=pca(varargin{1},'Algorithm','svd','Economy',fEconomy);

Error in var_pca (line 32)
[pc, score, eiv_] = princomp(data', 'econ');

Error in build_model_2d_from_files (line 230)
[pc eiv] = var_pca(shape_matrix, 0.98);

20 Nov 2012 Luca Vezzaro

Thanks for the feedback Sid Rajaram. Good to know!

20 Nov 2012 Sid Rajaram

Just to mention - I have all the examples working just fine on 64-bit Ubuntu 12.04...

17 Nov 2012 SURUMI J

can any one give the matlab code for 'facial feature extraction with DEPTH AAM algorithm'....

20 Sep 2012 Luca Vezzaro

If you just consider each frame of the video as a separate image you shouldn't have any trouble

20 Sep 2012 ka

thank you and if i need to use your project on video , i have to fix or add anything??

i'm a beginner so sorry for any question

19 Sep 2012 Luca Vezzaro

Yes, but you'll probably need to do some additional processing on the data as AAMs only give you the position of the recognized features.

19 Sep 2012 ka

can I use your project for facial expression recognition ??

19 Aug 2012 Luca Vezzaro

I'm using the exact same version of Matlab, but my procrustes.m does not contain that line.
Please tell me where your procrustes.m is located (mine is at: C:\Program Files\MATLAB\R2011a\toolbox\stats\stats).

Check the Matlab path (File->Set Path...) to make sure you don't have a file named procustes.m that is being used instead of the one provided by the statistics toolbox.

As a last resort you could try reinstalling the statistics toolbox...

17 Aug 2012 Mahmood Khoeini

Thanks for the quick reply.
I use matlab 7.12.0(R2011a) and my OS is win 7 64bit. I am using the package that download from sourceforge and it contain all of files (codes and datasets).
Image processing toolbox works well.
At line 25 of procrustes.m file value of data(1) is 125.7963 and it does not contain marks property, so matlab throw error.

17 Aug 2012 Luca Vezzaro

First of all what version of Matlab are you using, and what is your operating system?

Are you using the package from this site or the "official" one from sourceforge? The one on this site does not include the image files for the examples, so that may be your problem.

Also make sure you've installed the statistics and image processing toolbox as they are required.

17 Aug 2012 Mahmood Khoeini  
17 Aug 2012 Mahmood Khoeini

Hi Mr Luca Vezzaro,
I try to use this codes but I catch this error in procrustes.m, when run example files (such as annotate_test.m, fit2d_test.m and etc):

??? Improper index matrix reference.

Error in ==> procrustes at 25
p = size(data(1).marks,2);

Error in ==> build_model_2d at 182
[ D Y ] = procrustes(mean_shape, aligned_data(:,:,i));

Error in ==> annotate_test at 29
AAM = build_model_2d(shapes, appearances, 'triangulation', triangulation);

that i think that marks is unknown.

02 Apr 2012 Luca Vezzaro

What version are you using? Make sure you're using the latest version. Also please tell me if you're using Windows or Linux Matlab (no one ever really tested this under Linux).
To understand how to use the 3D algorithms, look at the tesi_train.m and tesi_sfm.m examples. The motion dataset has some low quality data (the files with the exclamation marks), and I don't remember if those should be used or not.
Finally, I never really got fantastic results with that algorithm and that data. Your best shot is to either run the shape-from-motion a lot of time (as it's randomized) or to use your own 2D motion data.

30 Mar 2012 sohaib azed

thankyou for the project. i was able to train my data with the help of examples in the project. but i am having problem with the fitting algorithm fit_3d(). the function either gives an error or gives an output with high error(the model does not fit on the face) when i provide my own pic.

i have tried 'tesi/motion' to make the shape model as well. still i get incorrect results.

when i give (dataset/IMM) to make the shape model. i get an error

""Number of landmarks in init_shape and/or number of colors in image_data are not consistent with the model.""

30 Mar 2012 sohaib azed

i have tried 'tesi/motion' to make the shape model as well. still i get incorrect results.

when i give (dataset/IMM) to make the shape model. i get an error

""Number of landmarks in init_shape and/or number of colors in image_data are not consistent with the model.""

09 Mar 2012 Luca Vezzaro

That could be caused by a lot of reasons.
The only way to find out is by trial and error, unfortunately...

Try using smaller training sets and try using images from the training set to do the fitting, instead of doing leave-one-out trials.

09 Mar 2012 Fatima laghrafi

hello,
i can't not compile the fit2d_test.m using my own data annotated to fit AAM ,he always do the catch : Fitting diverged..
what i should do please.
thanks a lot

02 Mar 2012 Fatima laghrafi

Thanks a lot Mr Luca Vezzaro.

02 Mar 2012 Luca Vezzaro

Firstly, make sure all your images are annotated and use the same amount of landmarks.

I recommend that after you create the first annotation file, to use that as a start for annotating the other images.

If you are sure the annotations are consistent, see the example "fit2d_test.m". It shouldn't be hard to understand how to use build_model_2d.

02 Mar 2012 Fatima laghrafi

it's the function ij2xy(in, maxy) ? because i have some compilation error so i don't know if my steps are correcte or no.
thanks a lot

02 Mar 2012 Fatima laghrafi

hello,
to constructe AAM model we use function build_model_2d(shape_data, app_data)it's right ? i don't understand how to compute shape data and app-data from my Data set.
Tanks a lot for help.

01 Mar 2012 Fatima laghrafi

Perfect, it work now with gray scale images and png form.
Thanks a lot

29 Feb 2012 Luca Vezzaro

I fixed the bug in the latest release (r17). You can download it here: https://sourceforge.net/projects/icaam/files/

29 Feb 2012 Fatima laghrafi

perfect, it's work now, after converting images. i will try after that to annotate my data , and constructe AAM model.
Thanks a lot

29 Feb 2012 Luca Vezzaro

Ok now I understand. The image command is interpreting the gray scale image as color indexed images!
When I get back from work I'll fix this bug.
In the meantime, you can use this work-around to convert single-channel gray scale images to RGB gray scale images (assuming I still remember well how repmat works):

img = imread('image_path_gray_scale')
img_rgb = repmat(img, [1 1 3])
imwrite(img_rgb, 'image_path_rgb')

29 Feb 2012 Fatima laghrafi

class(img)
ans =
uint8
min(min(img))
ans =
0
max(max(img))
ans =
255

Thanks a lot.

29 Feb 2012 Luca Vezzaro

As I expected, the gray scale PNG image data is not in range 0-255.
Please copy and paste the output of the following commands:

img = imread('image_path_gray_scale')

class(img)

min(min(img))

max(max(img))

Sorry I'm at work and I don't have MATLAB here so I can't do this myself.

29 Feb 2012 Fatima laghrafi

images are .png format (cohen kanade data).
if i do image(imread('image_path_gray_scale')) i get a good picture with some color for face, but if i do image(double(imread('image_path_gray_scale')) / 255) the out put is different , is a blue window with nothing.
thanks a lot

29 Feb 2012 Luca Vezzaro

It's strange, annotate should work with gray scale images... In what kind of format are your images stored?

If you type:

image(imread('image_path_gray_scale'))

What do you see?

What if you type:

image(double(imread('image_path_gray_scale')) / 255)

Is the output the same, or different?

29 Feb 2012 Fatima laghrafi

Thanks for your answer,
But my data set is a gray scale images, and i wan't to annotate it. when i use annotate('image_path_gray_scale')it give me a blue window, without any image.
Thanks a lot
fati

29 Feb 2012 Luca Vezzaro

You can annotate the images anyway, just use rgb2gray (http://www.mathworks.it/help/toolbox/images/ref/rgb2gray.html) after imread to convert the image data to gray scale. You don't need to change the annotation data.

29 Feb 2012 Fatima laghrafi

hello, all
i've tried your code. thanks for the project . i would like to train my data set in gray scale, i want to know if it's possible, because i cant not do the annotation.m with gray scale image. thanks a lot.
fati

17 Jan 2012 Luca Vezzaro

Have you tried the suggestions I gave to mashmallows (second comment)?
Please try that and also try to read the documentation.
If after that you still can't manage to build the training set I'll be happy to help.

17 Jan 2012 Fatima laghrafi

hello,

I've tried you code. Thanks for the project.I would like to train my own data set (gris scay image . png)in order to extract my facial features. How should I do? How could I generate my photos to the .mat and the triangulation.mat?
Tnanks a lot
fati

07 Dec 2011 Luca Vezzaro

Hello! Thanks for your interest in the project. First of all, be sure to use the latest version from sourceforge (http://sourceforge.net/projects/icaam/) as there has been recent bug fixes.
Also reading the README.txt file inside the package should give you a start.
Anyway, you generate the annotation data using the annotate.m script (type 'help annotate'). The triangulation.mat is not mandatory, but you can generate it using delaunay ('help delaunay'), that's what the training code uses anyway.

07 Dec 2011 marshmallow

Hello, I've tried you code. Thanks for the project. You have done a great job! I would like to train my own data set in order to extract my facial features. How should I do? How could I generate my photos to the .mat and the triangulation.mat? Thanks

Updates
29 Feb 2012

Update to latest revision, adding optimizations and fixing bugs.

Contact us