Example #1
0
pyr_blender=pyrMask.pyrMask(frame,True,nlevs,inference_lev)
old_frame[:,:,:]=get_new_frame(frame,inference_lev)
started=False
tle=0
print tot_time
t = t+1



while(cap.isOpened() and ret):
    print t
    cap.set(cv2.CAP_PROP_POS_FRAMES,skip_frames*t);
    ret, frame = cap.read()
    new_frame[:,:,:]=get_new_frame(frame,inference_lev)
    tic=time.time()
    corr_frame[:,:]=corrConv.fastCorr(old_frame,new_frame,corr_support)
    print time.time()-tic
    bitmask[:,:]=np.uint8(corr_frame>confidence)*255
    bitmask[:,:]=cv2.erode(bitmask,np.ones((erode_support,erode_support)))
    #bitmask[:,:]=cv2.morphologyEx(cv2.morphologyEx(bitmask,cv2.MORPH_CLOSE,np.ones((morph_support,morph_support))),cv2.MORPH_OPEN,np.ones((morph_support,morph_support)))
    #bitmask[:,:]=
    for color in range(num_channels):
        mask_frame[:,:,color]=bitmask
    cv2.imshow(str(t),(mask_frame*255)*new_frame)
    out_frame[:,:,:]=pyr_blender.maskOut(frame,mask_frame)
    tle=pyr_blender.get_top_level_energy()
    if not(started):
        bit_frame[:,:]=bit_frame|(bitmask==255)
        if np.product(bit_frame):
            started=True
            print "started"
Example #2
0
import numpy as np
import cv2
import corrConv

im1 = cv2.imread('./slides/no-u-final-slide525.png')
im2 = cv2.imread('./slides/no-u-final-slide648.png')

results = corrConv.fastCorr(im1, im2, 5)
results = results * 255
results = results.astype(np.uint8)

cv2.imshow('results', results)
cv2.waitKey(0)

cv2.imwrite('./results/slide525.png', im1)
cv2.imwrite('./results/slide648.png', im2)
cv2.imwrite('./results/correlation.png', results)
#cv2.imshow('image', im1)
#cv2.waitKey(0)
Example #3
0
sad=0
while(sad<thresh):
    cap.set(cv2.CAP_PROP_POS_FRAMES,t*skip_frames);
    ret,frame=cap.read()
    this_frame[:,:,:]=frame
    print t
    print sad
    sad=np.sum(np.abs(this_frame-last_frame))
    t = t+1
print "out"
last_frame[:,:,:]=frame
#pyr_blender=pyrMaskiir.pyrMaskiir(frame,True,nlevs,inference_lev,r)
curr_frame[:,:,:]=frame
now_frame[:,:,:]=get_new_frame(frame,inference_lev)
corr_frame[:,:]=corrConv.fastCorr(old_frame,now_frame,corr_support)
bit_back[:,:]=corr_frame>confidence
tle=0
print tot_time
bounce=False


while(cap.isOpened() and ret):
    print t
    #cap.set(cv2.CAP_PROP_POS_FRAMES,skip_frames*t);
    #ret, frame = cap.read()
    sad=0
    while(sad<thresh):
        cap.set(cv2.CAP_PROP_POS_FRAMES,t*skip_frames);
        ret,frame=cap.read()
        this_frame[:,:,:]=frame
Example #4
0
import numpy as np
import cv2
import corrConv
import pyrTest

nums=[77,199,321,369,463,581,684,794,860]
old=cv2.pyrDown(cv2.imread("./correlate/slidetest/fs4.png"))
otle=pyrTest.abs_tle_im(old)
resultsdir='./slide_debug/'

for num in nums:
    new=cv2.pyrDown(cv2.imread("./correlate/slidetest/fs"+str(num)+".png"))
    corrpic=corrConv.fastCorr(old,new,13)
    cp=np.dstack((corrpic,corrpic,corrpic))
    print cp.shape
    ntle=pyrTest.abs_tle_im(new)
    info_kept=np.multiply(otle,np.float64(cp>0.8))
    p=pyrTest.rep_3d_name(np.subtract(otle,info_kept),'ilost'+str(num))
    cv2.imwrite(resultsdir+'ilost'+str(num)+'.png',p)
    info_lost=np.sum(np.subtract(otle,info_kept))
    print info_lost
    info_retained=np.multiply(ntle,np.float64(cp>0.8))
    info_gained=np.sum(np.subtract(ntle,info_retained))
    p=pyrTest.rep_3d_name(np.subtract(ntle,info_retained),'igained'+str(num))
    cv2.imwrite(resultsdir+'igot'+str(num)+'.png',p)
    print info_gained
    if info_gained<info_lost:
        print "better "+str(num)