Skip to content

cv2.PCAComputeVar's parameter 'mean' takes no effect on the result in opencv-python v2.4.13.2 ! #10433

Closed

Description

@HawkRong
System information (version)
  • OpenCV => 2.4.13.2
  • Operating System / Platform => Windows 64 Bit
  • Compiler => ( installed from compiled '.whl' file )
Detailed description
'cv2.PCAComputeVar' 's parameter 'mean' takes no effect; given the same 'data', whether or not the parameter 'mean' is specified, the function returns the same result; however, 'cv2.PCACompute' gives response to the parameter 'mean'.
Steps to reproduce

import numpy
import cv2

data = numpy.random.rand( 10, 5 )
mean = numpy.arange( 0, 5 ).reshape( 1, 5 )
result_1 = cv2.PCAComputeVar( data, 0.9 ) # 'mean' not specified.
result_2 = cv2.PCAComputeVar( data, 0.9, mean ) # 'mean' specified.
print 'cv2.PCAComputeVar'
print 'without prior mean : ', result_1
print 'with prior mean : ', result_2
result_3 = cv2.PCACompute( data ) # 'mean' not specified.
result_4 = cv2.PCACompute( data, mean ) # 'mean' specified.
print 'cv2.PCACompute'
print 'without prior mean : ', result_3
print 'with prior mean : ', result_4

Activity

  1. alalek commented on Dec 27, 2017

    @alalek
    Member

    Thank you for the report!

    Looks like there is missing "covar_flags |= CV_COVAR_USE_AVG;" statement after "_mean.convertTo(mean, ctype);" line in computeVar() method (see corresponding "PCA::operator()" lines).

    The same bug exists in master branch too.

    BTW, Need to add simple regression test for this (check that "mean" value is used and returned).

  2. added a commit that references this issue on Jan 29, 2018
    a57beb3
  3. added a commit that references this issue on Jul 30, 2026
    0cea720
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    affected: 2.4affected: 3.4bugcategory: coregood first issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions