Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7517843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:34:52+00:00 2026-05-30T01:34:52+00:00

have this problem with PCACompute in Android Opencv2.3.1 because when i call PCACompute my

  • 0

have this problem with PCACompute in Android Opencv2.3.1 because when i call PCACompute my eigenvectors are all 0. So, i take 10 photos for each people and i save it into a Mat of 100X100.
After that, i convert my 100X100 Mat in one Mat 1X10000 with this code:

double [] elem = null; 
 for(int riga=0;riga<m.rows();riga++)
  {
   for(int colonna=0;colonna<m.cols();colonna++)
   {
    elem = m.get(riga, colonna);
      mrow.put(0,((riga*100)+colonna), elem[0]);
    }//for colonna
 }//for riga

After that, when i take 10 photos, i insert all Mat of the photos into one mat with this code:

double b[] = null;
  for (int i = 0; i< listafoto.size(); i++)
   {
    Mat t = listafoto.get(i);
      for(int riga = 0;riga<t.rows();riga++)
       {
        for(int colonna =0;colonna<t.cols();colonna++)
        {
           b = t.get(riga, colonna);
           datiOriginali.put(i, colonna, b[0]);
        }//for colonna
    }//for riga
 }//for lista e contemporaneamente riga datiOriginali

After that, i call PCACompute with this code: `

 org.opencv.core.Core.PCACompute(datiOriginali,mean, eigenvectors, 10);`

So, datiOriginali is the input Mat of 10 rows and 10000 cols, mean and eigenvectors are the output matrix. mean matrix give me a result, but eigenvectors give me all 0. Can you help me to resolve this problem?
Thanks in advance.MArco

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T01:34:54+00:00Added an answer on May 30, 2026 at 1:34 am

    I based my code on the example at http://www.bytefish.de/blog/pca_in_opencv.
    Here’s how I did this:

        Vector trainingImages = new Vector();;
        trainingImages.add(Highgui.imread("/sdcard/facedatabase/s1/1.pgm",0));
        trainingImages.add(Highgui.imread("/sdcard/facedatabase/s1/2.pgm",0));
    
        Mat x = (Mat) trainingImages.get(0);
        int total = x.rows() * x.cols();
    
        // build matrix (column)
        // This matrix will have one col for each image and imagerows x imagecols rows
            Mat mat = new Mat(total, trainingImages.size(), CvType.CV_32FC1);
            for(int i = 0; i < trainingImages.size(); i++) {
                Mat X = mat.col(i);
                Mat c = (Mat) trainingImages.get(i);
                c.reshape(1,total).convertTo(X, CvType.CV_32FC1);
            }
    
        Mat eigenVectors = new Mat();
        Mat mean = new Mat();
        Core.PCACompute(mat, mean, eigenVectors);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this problem then I try to float div left, each block contains
I have this problem where I do an .each() on this group of selects,
I have this problem in android. i have a main activity who calls a
I have this problem in my textbook: Given a group of n items, each
I have this problem all the time in my rails apps and I still
I have a problem with opencv2.3 and android 2.2: I have a set of
I have this problem where 2 bars from a different series overlap each other
I have this problem I'm hoping someone knows the answer to. I have an
I have this problem where I open Visual Studio and the internal windows are
i have this problem to find a particular xml node l have post this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.