c++ alternative to this kind of python cv::Mat operations

asked 2018-07-31 07:28:09 -0600

isra60 gravatar image

Hi i have this code

self.L = (static == 255) * (self.L+1) + ((static == 255)^1) * self.L
self.L = (not_static == 255) * (self.L-self.k) + ((not_static == 255)^1) * self.L
self.L[self.L>self.maxe] = self.maxe
self.L[self.L<0] = 0

my problem is with the two first lines, I get a gemm error with this conversion.

//update static obj likelihood
L = (staticMat == 255) * (L+1) + ((staticMat == 255)^1) * L;
L = (nonStaticMat == 255) * (L-GetAnalyticsParameters()->GetKLikehood()) + ((nonStaticMat == 255)^1) * L;
L.setTo(GetAnalyticsParameters()->GetMaxE(), L > GetAnalyticsParameters()->GetMaxE());
L.setTo(0,L<0);
edit retag flag offensive close merge delete

Comments

yea, * is the "per element" multiplication in python, while it's the "matrix" multiplication in c++ opencv

use cv::multiply() instead.

berak gravatar imageberak ( 2018-08-01 02:42:18 -0600 )edit