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 7665575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:36:21+00:00 2026-05-31T14:36:21+00:00

I’m having trouble in calculating Eigen Vectors, Values in OpenCV . I have done

  • 0

I’m having trouble in calculating Eigen Vectors, Values in OpenCV. I have done the same in Python (SciPy) but I’m having trouble in porting my code.

I have a 2 Matrices Sw, Sb whose values are:

Sw:[0.0112962962962963, 0.00675925925925926;
  0.00675925925925926, 0.007962962962962963]
Sb:[0.0530787037037037, 0.01657407407407407;
  0.01657407407407407, 0.004606481481481482]

For above values of Sw, Sb, computing Eigen Values, Eigen Vectors in SciPy (Python) using the following:

from numpy import *
from scipy import linalg as la
evals,evecs = la.eig(Sw,Sb)

yields the following:

evals:
[ 0.17299805+0.j -8.47412141+0.j]
evecs:
[[ 1.         -0.31926401]
 [-0.54311321  1.        ]]

I’m trying to port the above code to OpenCV (C++ API)

For the same values of Sw, Sb, computing Eigen Values and Eigen Vectors in OpenCV using

cv::eigen(Sb,Sb_Eig_Val,Sb_Eig_Vec);

yields different values which is:

Sb_Eig_Val
[0.05820394496612978; -0.0005187597809445917]
Sb_Eig_Vec
[0.9553644860284983, 0.2954296850952915;
  -0.2954296850952915, 0.9553644860284983]

Am I missing something here?

  • 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-31T14:36:23+00:00Added an answer on May 31, 2026 at 2:36 pm

    You’re solving two different linear algebra problems! Consider:

    from scipy import linalg as la
    sw=[[0.0112962962962963, 0.00675925925925926],[0.00675925925925926, 0.007962962962962963]]
    sb=[[0.0530787037037037, 0.01657407407407407],[0.01657407407407407, 0.004606481481481482]]
    print la.eig(sb)
    

    Which gives:

    (array([ 0.05820394+0.j, -0.00051876+0.j]), array([[ 0.95536449, -0.29542969],
       [ 0.29542969,  0.95536449]]))
    

    exactly as openCV. In the scipy case with two input arguments you are solving the generalized eigenvalue problem, but with only one argument it assumes the other matrix is the identity (this is typically what we mean when we say diagonalization)

    Since the matrices are symmetric, you should be using eigh in scipy. Real symmetric matrices give real eigenpairs, and it will stop returning a complex number.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have this code to decode numeric html entities to the UTF8 equivalent character.

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.