コード例 #1
0
def multiDecode():
    for i in range(28):
        #picture = str(input("Enter the image with extension (ex: example.png): "))
        print("This is the current path: ", os.getcwd())
        #imgPath = str(input("Enter the path to the image: "))
        #facialFeature = str(input("Enter the facial feature (eyes, mouth, nose): "))
        #we are passing 1 in to the facial_feature_recog function to tell that function to decode
        picture = f'{i}.png'
        imgPath = os.path.join(os.getcwd(), "facial_recog", "dataset", picture)
        toGetPoints = os.path.join(os.getcwd(), "facial_recog", "original_dataset", picture)
        facialFeature = config.facial_feature
        pointsList = facial_features.do_facial_feature_recog(picture, imgPath, 1, facialFeature)
        pointsList = pointsList[1]
        try:
            print("Decoded: {}".format(LSB.decode(picture,imgPath, pointsList)))
            print("Picture: {}".format(picture))
            isMessageEqual = LSB.decode(picture,imgPath, pointsList) == config.message
            if isMessageEqual == True:
                print(f"\033[94m  The message was encoded and decoded correctly. \033[0m")
            else:
                print(f"\033[91m The message was not encoded or decoded correctly. \033[0m")

            #shutil will copy the original file and replace the encoded image with the original copy of the image
            # shutil.copyfile(toGetPoints, imgPath)  
        except StopIteration:
            print("Exception")
            shutil.copyfile(toGetPoints, imgPath)
コード例 #2
0
def menuEncode():
    picture, imgPath = facial_features.select_image()
    chosenFeature, pointsList, pixelsList = facial_features.do_facial_feature_recog(
        picture, imgPath)
    print(
        "The important information: \n Picture chosen: {} \n Chosen feature: {} "
        .format(picture, chosenFeature))
    try:
        LSB.encode(picture, imgPath, pointsList, pixelsList)
    except ValueError:
        print("The message is too large to be encoded.")
コード例 #3
0
def menuEncode():
    picture, imgPath = facial_features.select_image()
    chosenFeature, pointsList, pixelsList = facial_features.do_facial_feature_recog(picture, imgPath)
    print("The important information: \n Picture chosen: {} \n Chosen feature: {} ".format(picture, chosenFeature))
    time.sleep(2)
    facial_features.kill_example_pictures()
    LSB.encode(picture,imgPath,pointsList,pixelsList)
    with open('key.txt', 'w+') as file:
        file.write(picture + '\n')
        file.write(imgPath + '\n')
        file.write(repr(pointsList) + '\n')
コード例 #4
0
def menuEncode():
    picture, imgPath = facial_features.select_image(
    )  #select_image() function is called
    chosenFeature, pointsList, pixelsList, fullFacePoints = facial_features.do_facial_feature_recog(
        picture, imgPath)  #do_facial_feature_recog() function
    print(
        "The important information: \n Picture chosen: {} \n Chosen feature: {} "
        .format(picture, chosenFeature))
    try:
        LSB.encode(picture, imgPath, pointsList, pixelsList, chosenFeature,
                   fullFacePoints)
    except ValueError:
        print(
            "Function menuEncode(): There was an error while trying to encode a message."
        )
コード例 #5
0
def menuDecode():
    #picture = str(input("Enter the image with extension (ex: example.png): "))
    print("This is the current path: ", os.getcwd())
    #imgPath = str(input("Enter the path to the image: "))
    #facialFeature = str(input("Enter the facial feature (eyes, mouth, nose): "))
    #we are passing 1 in to the facial_feature_recog function to tell that function to decode
    picture = '1.png'
    imgPath = '/home/pranmar123/Facial-Feature-Based-Image-Steganography//facial_recog/dataset/1.png'
    toGetPoints = '/home/pranmar123/Facial-Feature-Based-Image-Steganography//facial_recog/original_dataset/1.png'
    facialFeature = 'nose'
    pointsList = facial_features.do_facial_feature_recog(
        picture, toGetPoints, 1, facialFeature)
    pointsList = pointsList[1]
    try:
        print("Decoded: {}".format(LSB.decode(picture, imgPath, pointsList)))
        #shutil will copy the original file and replace the encoded image with the original copy of the image
        shutil.copyfile(toGetPoints, imgPath)
    except StopIteration:
        print("Exception")
        shutil.copyfile(toGetPoints, imgPath)
コード例 #6
0
def menuEncode():
    picture, imgPath = facial_features.select_image(config.picture)
    chosenFeature, pointsList, pixelsList = facial_features.do_facial_feature_recog(picture, imgPath)
    print("The important information: \n Picture chosen: {} \n Chosen feature: {} ".format(picture, chosenFeature))
    LSB.encode(picture,imgPath,pointsList,pixelsList,config.picture)
コード例 #7
0
def multiEncode():
    for i in range(28):
        picture, imgPath = facial_features.select_image(f'{i}.png')
        chosenFeature, pointsList, pixelsList = facial_features.do_facial_feature_recog(picture, imgPath)
        print("The important information: \n Picture chosen: {} \n Chosen feature: {} ".format(picture, chosenFeature))
        LSB.encode(picture,imgPath,pointsList,pixelsList,f'{i}.png')
コード例 #8
0
def menuDecode():

    script_location = Path(__file__).absolute().parent
    picture = str(input("Enter the image with extension (ex: example.png): "))
    flag = True
    imgPath = str(script_location) + "/dataset/" + picture
    facialFeature = None
    facialFeature1 = []
    facialFeature2 = []
    #this list is so the program will check the first feature, and remove it form the list, and then apply the list to the formatted string
    #when it asks for a secondary feature. So the user doesn't have an option to type nose and nose
    facialFeaturesList = ['nose', 'eyes', 'mouth']
    if os.path.isfile(imgPath) == False:
        while flag:
            picture = str(
                input(
                    "This image doesn't exist, please enter a correct image name: "
                ))
            imgPath = str(script_location) + "/dataset/" + picture
            if os.path.isfile(imgPath) == True:
                flag = False
    howManyFeatures = str(
        input("How many facial features to be decoded? (1 or 2): "))
    while howManyFeatures != '1' and howManyFeatures != '2':
        howManyFeatures = str(
            input("Error: How many facial features to be decoded? (1 or 2): "))
    print("This is the current path: ", os.getcwd())

    if (howManyFeatures == "1"):
        #if one feature
        facialFeature = str(
            input("Enter the facial feature (eyes, mouth, nose, face): ")
        ).lower()
        while facialFeature != 'nose' and facialFeature != 'mouth' and facialFeature != 'eyes' and facialFeature != 'face':  #check for correct input
            facialFeature = str(
                input(
                    "Please enter a correct facial feature (eyes, mouth, nose, face): "
                )).lower()
    else:
        #if two features
        facialFeature1 = str(
            input("Enter the first facial feature (eyes, mouth, nose): ")
        ).lower()
        while facialFeature1 != 'nose' and facialFeature1 != 'mouth' and facialFeature1 != 'eyes':  #check for correct input
            facialFeature1 = str(
                input(
                    "Please enter a correct facial feature (eyes, mouth, nose): "
                )).lower()
        facialFeaturesList.remove(
            facialFeature1
        )  #remove from list, to show user which options remain.
        facialFeature2 = str(
            input("Enter the second facial feature ({}, {}): ".format(
                *facialFeaturesList)))
        while facialFeature2 != facialFeaturesList[
                0] and facialFeature2 != facialFeaturesList[
                    1]:  #check for correct input
            facialFeature2 = str(
                input(
                    "Please enter a correct secondary facial feature ({}, {}): "
                    .formar(*facialFeaturesList))).lower()

    pointsList = []

    toGetPoints = str(script_location) + "/original_dataset/" + picture
    if howManyFeatures == "1":
        xx, pointsList, pixel_list, faceLength = facial_features.do_facial_feature_recog(
            picture, toGetPoints, 1, facialFeature)
    else:
        xx, pointsListFeature1, xxx, faceLength = facial_features.do_facial_feature_recog(
            picture, toGetPoints, 1, facialFeature1)
        zzzz, pointsListFeature2, xxxx, faceLength = facial_features.do_facial_feature_recog(
            picture, toGetPoints, 1, facialFeature2)
        pointsList = pointsListFeature1 + pointsListFeature2

    try:
        print("Decoded: {}".format(LSB.decode(picture, imgPath, pointsList)))
        #shutil will copy the original file and replace the encoded image with the original copy of the image
        shutil.copyfile(toGetPoints, imgPath)
    except StopIteration:
        print("Error: Could not decode message.")
        shutil.copyfile(toGetPoints, imgPath)