Now,
EDIT: Main goal, capture an image, wait some time, capture another image, add the two images together and show it :END EDIT
I run the program and can see the webcam feed, I then press a key capturing an image as img1, then again but as img2, and again img3. Now when the final image displays (img2+img3) it just shows img3 added to itself, i.e. as though I coded Add(img3,img3,img1). I have also tried AddWeighted and AND functions.
I have tried and tried and cannot find the problem, is it the Add function that is not reading img2, or could img2 not be saved properly? or what is going on!!
Any help would be great,
Cheers,
Dan.
# Daniel Myers
# cvTest.py
# 18 Feb 13
from cv import *
SIZE=(HEIGHT,WIDTH)=(640,480) # Image capture size
CAMERA_INDEX=-1 # -1 means any camera attached
def TakePic(cam):
NamedWindow('cvTest',CV_WINDOW_AUTOSIZE)
while True:
img=QueryFrame(cam)
ShowImage('cvTest',img)
k=WaitKey(2)
if k>=0:
return img
cam=CaptureFromCAM(CAMERA_INDEX) # Initializes capturing a video from a camera
SetCaptureProperty(cam,CV_CAP_PROP_FRAME_WIDTH,WIDTH) # Set the capture image width
SetCaptureProperty(cam,CV_CAP_PROP_FRAME_HEIGHT,HEIGHT) # Set the capture image height
img1=TakePic(cam)
ShowImage('img1',img1)
img2=TakePic(cam)
ShowImage('img2',img2)
img3=TakePic(cam)
ShowImage('img3',img3)
AddWeighted(img2,0.4,img3,0.6,20,img1)
ShowImage('img2+img3',img1)
k=WaitKey(100000)
DestroyAllWindows()
del(cam)




