You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cv2.PCAComputeVar's parameter 'mean' takes no effect on the result in opencv-python v2.4.13.2 ! #10433
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
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).
Activity
alalek commentedon Dec 27, 2017
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).
Merge master into fork (#1)
Fixed opencv#10433