def test_video(vid, sc):
    '''
        calls all methods to test the given video
        
    '''
    MotionInfOfFrames, rows, cols = mig.getMotionInfuenceMap(vid, sc)
    megaBlockMotInfVal = cmb.createMegaBlocks(MotionInfOfFrames, rows, cols)

    codewords = np.load("/home/yash/work/project/unusual/code/codewords.npy")
    #print("codewords",codewords)
    listOfUnusualFrames = constructMinDistMatrix(megaBlockMotInfVal, codewords,
                                                 rows, cols, vid)
    return
def train_from_video(vid):
    '''
        calls all methods to train from the given video
        May return codewords or store them.
    '''
    print("Training From ", vid)
    MotionInfOfFrames, rows, cols = mig.getMotionInfuenceMap(vid)
    print("Motion Inf Map", len(MotionInfOfFrames))
    #numpy.save("MotionInfluenceMaps", np.array(MotionInfOfFrames), allow_pickle=True, fix_imports=True)
    megaBlockMotInfVal = cmb.createMegaBlocks(MotionInfOfFrames, rows, cols)
    np.save(r"C:\Users\user\Downloads\Unusual-Human-Activity-Detection-master\Unusual-Human-Activity-Detection-master\Dataset\videos\scene1\megaBlockMotInfVal_set1_p1_train_40-40_k5.npy",megaBlockMotInfVal)
    print(np.amax(megaBlockMotInfVal))
    print(np.amax(reject_outliers(megaBlockMotInfVal)))
    
    codewords = cmb.kmeans(megaBlockMotInfVal)
    np.save(r"C:\Users\user\Downloads\Unusual-Human-Activity-Detection-master\Unusual-Human-Activity-Detection-master\Dataset\videos\scene1\codewords_set1_p1_train_40-40_k5.npy",codewords)
    print(codewords)
    return
def train_from_video(vid):
    '''
        calls all methods to train from the given video
        May return codewords or store them.
    '''
    print "Training From ", vid
    MotionInfOfFrames, rows, cols = mig.getMotionInfuenceMap(vid)
    print "Motion Inf Map", len(MotionInfOfFrames)
    #numpy.save("MotionInfluenceMaps", np.array(MotionInfOfFrames), allow_pickle=True, fix_imports=True)
    megaBlockMotInfVal = cmb.createMegaBlocks(MotionInfOfFrames, rows, cols)
    np.save("videos\scene1\megaBlockMotInfVal_set1_p1_train_40-40_k5.npy",
            megaBlockMotInfVal)
    print(np.amax(megaBlockMotInfVal))
    print(np.amax(reject_outliers(megaBlockMotInfVal)))

    codewords = cmb.kmeans(megaBlockMotInfVal)
    np.save("videos\scene1\codewords_set1_p1_train_40-40_k5.npy", codewords)
    print codewords
    return
예제 #4
0
def label_video(vid):
    '''
        calls all methods to test the given video
       
    '''
    print "Labelling video ", vid
    MotionInfOfFrames, rows, cols = mig.getMotionInfuenceMap(vid)
    #np.save("videos\scene1\rows_cols_set1_p1_test_20-20_k5.npy",np.array([rows,cols]))
    #######print "Motion Inf Map ", len(MotionInfOfFrames)
    #numpy.save("MotionInfluenceMaps", np.array(MotionInfOfFrames), allow_pickle=True, fix_imports=True)
    megaBlockMotInfVal = cmb.createMegaBlocks(MotionInfOfFrames, rows, cols)
    ######rows, cols = np.load("rows_cols__set3_p2_test_40_k3.npy")
    #print(megaBlockMotInfVal)
    np.save("megaBlockMotInfVal_set1_p1_test_20-20_k5.npy",megaBlockMotInfVal)
    ######megaBlockMotInfVal = np.load("megaBlockMotInfVal_set3_p2_train_40_k7.npy")
    codewords = np.load("codewords_set2_p1_train_20-20_k5.npy")
    print("codewords",codewords)
    listOfUnusualFrames = constructMinDistMatrix(megaBlockMotInfVal,codewords,rows, cols, vid)
    return
def train_from_video(vid, sc):
    '''
        calls all methods to train from the given video
        May return codewords or store them.
    '''
    print "Training From ", vid
    MotionInfOfFrames, rows, cols = mig.getMotionInfuenceMap(vid, sc)
    #print "Motion Inf Map", len(MotionInfOfFrames)
    #numpy.save("MotionInfluenceMaps", np.array(MotionInfOfFrames), allow_pickle=True, fix_imports=True)
    megaBlockMotInfVal = cmb.createMegaBlocks(MotionInfOfFrames, rows, cols)
    #np.save("/home/yash/work/project/unusual/code/videos/scene1/megaBlockMotInfVal_set1_p1_train_40-40_k5.npy",megaBlockMotInfVal)  
    
    # write_mega_block_to_file(megaBlockMotInfVal)
    codewords = cmb.kmeans_map_reduce(megaBlockMotInfVal, sc)
    #cmb.kmeans(megaBlockMotInfVal)

    #sc.stop()
    #sys.exit()

    np.save("/codewords.npy",codewords)
    return