Hi
I have problem with getting values for magnitude all other things is more then well, so here
i normalize my magnitude and i receive that its -nan(ind), if i remove this line all values are 0, but i start to code this in my laptop and all working well before, when i shift this project it to my office PC magnitude dissapear.
Thanks for any help
This is my mai function
[code]def onCook(scriptOp):
scriptOp.clear()
topRef = scriptOp.par.Top1.eval()
topRef2 = scriptOp.par.Top2.eval()
# default values
angle = []
magnitude = []
flowXY = []
hsv = np.zeros((op('img1').height, op('img1').width, 3))
one = topRef.numpyArray()
two = topRef2.numpyArray()
one_g = cv2.cvtColor(one, cv2.COLOR_RGB2GRAY)
two_g = cv2.cvtColor(two, cv2.COLOR_RGB2GRAY)
hsv[:,:,1] = cv2.cvtColor(two, cv2.COLOR_RGB2HSV)[:,:,1]
if topRef:
#//////////////////
# read top as numpyArray
#parametres = (prev, next, pyr_scale (current:None), levels, winsize, iterations, poly_n, poly_sigma, flags[, flow]) → flow
flowXY = cv2.calcOpticalFlowFarneback(one_g, two_g, None, 0.1, 10, 15 , 15, 5, 1.2, 1)
# setup the scriptOp with 2 channels
# also set length to number of features that were detected
scriptOp.rate = me.time.rate
scriptOp.numSamples = (len(flowXY[:]))*(len(flowXY[1]))
an = scriptOp.appendChan('angle')
mg = scriptOp.appendChan('magnitude')
mag, ang = cv2.cartToPolar(flowXY[..., 0], flowXY[..., 1])
hsv[:,:,0] = ang * (180/ np.pi / 2)
hsv[:,:,2] = cv2.normalize(mag,None,0,255,cv2.NORM_MINMAX)
hsv = np.asarray(hsv, dtype= np.float32)
rgb_flow = cv2.cvtColor(hsv,cv2.COLOR_HSV2RGB)
for row in range(len(hsv)):
for col in range(len(hsv[0])):
angle.append(hsv[row][col][0])
magnitude.append(hsv[row][col][2])
an.vals = angle
mg.vals = magnitude
return[/code]