Example #1
0
def getFeatureByFireLaneMapFromFileList(CID, fileList, showStatus = True):
    
    Opt_Dmtler = Option_Dismantler(isTrain = False)
    Dmtler = Dismantler(Opt_Dmtler)
    
    data = np.zeros([len(fileList), 2 + CID.division[1] * CID.division[0]])
    for (i,filename) in enumerate(fileList):
        
        img = cv.imread(filename)
        if len(img.shape) == 3:
            img = cv.cvtColor(img, cv.COLOR_BGR2GRAY)

        first_vertical, fire_lane_map_vertical, count_standalone_first_vertical = Dmtler.split(img, 0)
        first_horizontal, fire_lane_map_horizontal, count_standalone_first_horizontal = Dmtler.split(img, 1)
        map = fire_lane_map_vertical + fire_lane_map_horizontal
#         Dmtler.showImg(fire_lane_map_vertical)
#         Dmtler.showImg(fire_lane_map_horizontal)
#         Dmtler.showImg(map)
        
        data[i, :] = CID.getFeatureByFireLaneMap(map)
        
        if showStatus:
            print '%d / %d images has been collected' %(i, len(fileList))
        
    print '%d images has been collected.' %len(fileList)
    return data
Example #2
0
for dirPath, dirNames, fileNames in os.walk(corpusPath):
    for f in fileNames:
        fname, suffix = Common.getFileNameAndSuffix(f)
        if suffix in Opt_dmtler.validImageFormat:

            filename = os.path.join(dirPath, f)
            # Loading Images
            img = cv.imread(filename)
            print filename

            if len(img.shape) == 3:
                img = cv.cvtColor(img, cv.COLOR_BGR2GRAY)

            subStartTime = time.time()

            first_vertical, fire_lane_map_vertical, count_standalone_vertical = Dmtler.split(
                img, 0)
            first_horizontal, fire_lane_map_horizontal, count_standalone_horizontal = Dmtler.split(
                img, 1)

            spendTime = time.time()
            countSplitTime += spendTime - subStartTime
            subStartTime = spendTime
            print countSplitTime
            #             print count_standalone_vertical, count_standalone_horizontal
            first_vertical = Dmtler.merge(img, first_vertical)
            first_horizontal = Dmtler.merge(img, first_horizontal)

            spendTime = time.time()
            countMergeTime += time.time() - subStartTime
            subStartTime = spendTime
            print countMergeTime
Example #3
0
    for f in fileNames:
        fname, suffix = Common.getFileNameAndSuffix(f)
        if suffix in Opt_dmtler.validImageFormat:
            
            filename = os.path.join(dirPath, f)
            # Loading Images
            img = cv.imread(filename)
            print filename

            
            if len(img.shape) == 3:
                img = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
                
            subStartTime = time.time()
            
            first_vertical, fire_lane_map_vertical, count_standalone_vertical = Dmtler.split(img, 0)
            first_horizontal, fire_lane_map_horizontal, count_standalone_horizontal = Dmtler.split(img, 1)
    
            spendTime = time.time()
            countSplitTime += spendTime - subStartTime
            subStartTime = spendTime
            print countSplitTime
#             print count_standalone_vertical, count_standalone_horizontal
            first_vertical = Dmtler.merge(img, first_vertical)
            first_horizontal = Dmtler.merge(img, first_horizontal)
            
            spendTime = time.time()
            countMergeTime += time.time() - subStartTime
            subStartTime = spendTime
            print countMergeTime
            
Example #4
0
for dirPath, dirNames, fileNames in os.walk(corpusPath):   
    for f in fileNames:
        fname, suffix = Common.getFileNameAndSuffix(f)
        if suffix in Opt_dmtler.validImageFormat:
            
            filename = os.path.join(dirPath, f)
            # Loading Images
            img = cv.imread(filename)
            print filename
#             node_list = Dmtler.dismantle(img)
            
            if len(img.shape) == 3:
                img = cv.cvtColor(img, cv.COLOR_BGR2GRAY)

        
            root0, count_standalone = Dmtler.split(img, 0)
            map0 = Dmtler.getSalientMap(img, root0)
            
            root1, count_standalone = Dmtler.split(img, 1)
            map1 = Dmtler.getSalientMap(img, root1)
            
            map = (map0 + map1) / 2
            
#             Dismantler.showImg(map)
            savePath = os.path.join(resultPath, f)
#             print savePath
            cv.imwrite(savePath, map)
            
            nImageAll += 1 
            if nImageAll % 100 == 0:
                print '%d images have been mapped.' % nImageAll