While in general the new python bindings for opencv (cv2) are a beauty, "masks" don't seem to be working properly - unless I really get something wrong:
For example "cv2.add" still works properly without a mask:
import cv2
a = ones((2,2,3), dtype=uint8)
cv2.add(a,a)
correctly gives
array([[[2, 2, 2],
[2, 2, 2]],
[[2, 2, 2],
[2, 2, 2]]], dtype=uint8)
But when you add a mask (and an out array "b" - which is required by for some reason is not assigned either) you get a RANDOM result, i.e. the result changes when you run the command multiple times
myMask = zeros(a.shape[0:2], dtype = uint8)
mask[1,1] = 255
b = zeros(a.shape)
cv2.add(a,a,b,myMask)
cv2.add(a,a,b,myMask)
gives on my machine (Win7, 32bit,Python 2.7, opencv 2.3.1)
In [34]: cv2.add(a,a,b,myMask)
Out[34]:
array([[[ 26, 0, 143],
[ 5, 216, 245]],
[[156, 5, 104],
[ 2, 2, 2]]], dtype=uint8)
In [35]: cv2.add(a,a,b,myMask)
Out[35]:
array([[[35, 0, 0],
[ 0, 3, 0]],
[[ 0, 0, 3],
[ 2, 2, 2]]], dtype=uint8)
... and something new on the next trial. Now either I get something seriously wrong, or there is a serious problem with the cv2 bindings.
Any suggestions?