android opencv PCA (face recognition)

298 views
Skip to first unread message

mustafa

unread,
Sep 18, 2012, 9:56:54 AM9/18/12
to android...@googlegroups.com
hi i want to implement an android app to handle face recogniton using PCA and my steps :
1- i have 3 images (100 * 100) built from them the matrix (10000 * 3) each image in column
Mat first = (Mat) this.trainImages.get(0);
            this.total = first.cols() * first.rows();

            // this matrix will have one column for each image
             this.matrix = new Mat(this.total, this.trainImages.size(),
                    CvType.CV_32FC1);
            for (int i = 0; i < this.trainImages.size(); i++) {
                Mat matrixCol = this.matrix.col(i);
                Mat trainImage = (Mat) this.trainImages.get(i);
                trainImage.reshape(1, this.total).col(0).convertTo(matrixCol,
                        CvType.CV_32FC1);
            }

2- calling Core.PCACompute(this.matrix, this.mean, this.eigenvectors,12);
3- now (here i have exception ) i want to project a new image onto the pca subspace by calling Core.PCAProject(m, this.mean, this.eigenvectors, projected);
where m is (10000 * 1) matrix it always give me an exception but when i projected my training 3 images matrix by this Core.PCAProject(this.matrix, this.mean, this.eigenvectors, this.projectedMatrix);
it didn't give an exception and return the projectedMatrix (10000 * 3) and where the calculated mean is (1*3) and the eigenvectors (3*3)
so where is the problem how i project new images to compute the similarity
thank
Reply all
Reply to author
Forward
0 new messages