コード例 #1
0
    try:
        int(s)
        return True
    except ValueError:
        return False

def acquireID():
    inputOk = False
    k = 0
    while inputOk!=True:
        inp = raw_input(MSG_INPUT)
        if isInt(inp):
            k = int(inp)
            if k>=0:
                inputOk=True
            else:
                print MSG_ERRORE_ID_BASSO
        else:
            print MSG_ERRORE_NO_INT
    return k

esci = False
while not esci:
    path = fdb.getPath(acquireID())
    if path!="":
        esci = True
img = cv2.imread(path, cv2.IMREAD_COLOR)
cv2.imshow("pippo", img)
cv2.waitKey(0)
cv2.destroyAllWindows()
コード例 #2
0
    # FOR EVERY FOLD OF THE CROSS-VALIDATION PROCESS

    for i in range(0,totIter):
        
        # TRAINING
        # The training set has the following structure:
        #   [[groupClass, [IDs]], ...]
        # Example:
        #   [["ClassA", [4, 8, 24]], ["ClassB", [15, 29, 1]], ...]
        
        trainingSet = fc.getTrainingSet(i)
        for group in trainingSet:
            groupClass = group[0] # class of the images in this group
            for ID in group[1]:
                imgPath = fdb.getPath(ID)
                # retrieve the image using imgPath and use it to train the model,
                # knowing that its class is groupClass

        #TESTING
        # The test set has the following structure:
        #   [IDs]
        # Example:
        #   [5, 15, 21, ...]
        
        testSet = fc.getTestSet(i)
        rankingList = []
        for ID in testSet:
            imgPath = fdb.getImgPath(ID)
            ranking = # image classification, see the next comment
            rankingList.append(ranking)