Ejemplo n.º 1
0
def test_zip_to_coord(filename):
    if (image_restriction_main.check_image(filename)):
        imagedata = Data(filename)
        exifData = imagedata.get_exif(filename, True, False)
        coords = location.get_coord(exifData)
        zipcode = location.coord_to_zip(coords, Google_API)
        print "\tOriginal image data: (" + exifData['gps gpslatitude'][
            1:-1] + "," + exifData['gps gpslongitude'][1:-1] + ")\n"
        secondcoords = location.zip_to_coord(zipcode, Google_API)
        print "\tOriginal Coordinates: (" + str(coords[0]) + "," + str(
            coords[1]) + ")\n"
        print "\tFetched Coordinates: (" + str(secondcoords[0]) + "," + str(
            secondcoords[1]) + ")\n"
        if (secondcoords == (0.0, 0.0)):
            print "\tError fetching Coordinates\n"
            return 0
        else:
            if (((coords[0] >
                  (secondcoords[0] + 0.5)) | (coords[0] <
                                              (secondcoords[0] - 0.5))) &
                ((coords[1] >
                  (secondcoords[1] + 0.5)) | (coords[1] <
                                              (secondcoords[1] - 0.5)))):
                print "\tFetched Coordinates are not within +-0.5 accuracy to Original Coordinates"
                return 0
            else:
                print "\tFetched Coordinates are within +-0.5 accuracy to Original Coordinates"
                return 1
    else:
        print "Image failed a restriction test.\n"
        return 0
Ejemplo n.º 2
0
def main():
'''
Purpose:        The purpose of this main function is to check all image restrictions and
                produce the correct error message should one occur.
Inputs:         string image (as sys.argv[1])
Outputs:        None
Returns:        N/A
Assumptions:    N/A
'''
    #instantiate classes
    fxn     = Fxn()

    #Retrieve exif data
    if(len(sys.argv) < 2):
        #use default image
        data    = Data("./images/good-images/1484949760_19_2615.jpg")
        exifData = data.get_exif("./images/good-images/1484949760_19_2615.jpg", True, True)
        program(fxn, data, exifData, "./images/good-images/1484949760_19_2615.jpg")
    elif(len(sys.argv) == 2):
        data    = Data(sys.argv[1])
        exifData = data.get_exif(sys.argv[1], True, False)
        program(fxn, data, exifData, sys.argv[1])
    elif(len(sys.argv) > 2):
        #error
        print "Please pass only 1 image to this program as an argument"
Ejemplo n.º 3
0
def check_image(filename):
    #instantiate classes
    fxn = Fxn()
    #Retrieve exif data
    data = Data(filename)
    exifData = data.get_exif(filename, True, False)
    isVerified = program(fxn, data, exifData, filename)
    return isVerified
Ejemplo n.º 4
0
def test_sun_position(filename):
    if (image_restriction_main.check_image(filename)):
        imagedata = Data(filename)
        exifData = imagedata.get_exif(filename, True, False)
        print "\tThe sun's position indicates it's : " + location.sun_position(
            exifData)
        return 1
    else:
        print "\tImage failed a restriction test.\n"
        return 0
Ejemplo n.º 5
0
def is_sky(a, path):
    # Create a mask
    data = Data(path)
    img = data.get_rgb(path)
    tags = data.get_exif(path, True, True)
    mask = np.zeros(img.shape[:2], np.uint8)
    mask[0:(img.shape[0] / 2), 0:img.shape[1]] = 255
    masked_img = cv2.bitwise_and(img, img, mask = mask)

    # Create histograms with 16 bins in range 0-255
    color = ('b', 'g', 'r')
    b, g, r = cv2.split(img)
    dimy, dimx = img.shape[:2]

    largest = [0, 0]
    it = dimy / 200 #iterations = total number of rows(pixels) / 200
    for i in range(dimy / 4, (dimy / 4) * 3, it):   #only looking at the middle half of the image
        ravg = (sum(r[i]) / float(len(r[i])))
        gavg = (sum(g[i]) / float(len(g[i])))
        bavg = (sum(b[i]) / float(len(b[i])))
        avg = (ravg + gavg + bavg) / 3
        pravg = (sum(r[i - it]) / float(len(r[i - it])))
        pgavg = (sum(g[i - it]) / float(len(g[i - it])))
        pbavg = (sum(b[i - it]) / float(len(b[i - it])))
        pavg = (pravg + pgavg + pbavg) / 3
        diff = pavg - avg
        if diff > largest[0]:   #only getting the largest intensity drop.
            largest = [diff,i-(it/2)]
    if largest[0] >= 11:
        sky = img[0:largest[1],0:dimx]#cropping out landscape
        h1 = sky[0:(sky.shape[0] / 2),0:dimx]#top half of sky
        h2 = sky[(sky.shape[0] / 2):(sky.shape[0]), 0:dimx]#bottom half

        mask = np.zeros(h1.shape[:2], np.uint8)
        mask[0:(h1.shape[0] / 2), 0:h1.shape[1]] = 255

        for i,col in enumerate(color):
            histr = cv2.calcHist([h1], [i], mask, [255], [0, 255])
            plt.plot(histr, color = col)
            plt.xlim([0,255])

        mask = np.zeros(h2.shape[:2], np.uint8)
        mask[0:(h2.shape[0] / 2), 0:h2.shape[1]] = 255

        for i,col in enumerate(color):
            histr = cv2.calcHist([h2], [i], mask, [255], [0, 255])
            plt.plot(histr, color = col)
            plt.xlim([0, 255])
        return True

    else:
        return False
Ejemplo n.º 6
0
def test_get_coord(filename):
    if (image_restriction_main.check_image(filename)):
        imagedata = Data(filename)
        exifData = imagedata.get_exif(filename, True, False)
        coords = location.get_coord(exifData)
        print "\tOriginal image data: (" + exifData['gps gpslatitude'][
            1:-1] + "," + exifData['gps gpslongitude'][1:-1] + ")\n"
        print "\tConverted image data: (" + str(coords[0]) + "," + str(
            coords[1]) + ")\n"
        return 1

    else:
        print "\tImage failed a restriction test.\n"
        return 0
Ejemplo n.º 7
0
def check_image(filename):
'''
Purpose:        The purpose of this main function is to check all image restrictions
                for use in the Aerolyzer app.
Inputs:         string filename of image locally
Outputs:        None
Returns:        isVerified
Assumptions:    N/A
'''
    #instantiate classes
    fxn     = Fxn()
    #Retrieve exif data
    data    = Data(filename)
    exifData = data.get_exif(filename, True, False)
    isVerified = program(fxn, data, exifData, filename)
    return isVerified
Ejemplo n.º 8
0
def test_coord_to_zip(filename):
    if (image_restriction_main.check_image(filename)):
        imagedata = Data(filename)
        exifData = imagedata.get_exif(filename, True, False)
        coords = location.get_coord(exifData)
        zipcode = location.coord_to_zip(coords, Google_API)
        print "\tOriginal image data: (" + exifData['gps gpslatitude'][
            1:-1] + "," + exifData['gps gpslongitude'][1:-1] + ")\n"
        if (zipcode == "99999"):
            print "\tError fetching ZIP Code\n"
            return 0
        else:
            print "\tFetched image data: ZIP = " + zipcode + "\n"
            return 1
    else:
        print "\tImage failed a restriction test.\n"
        return 0
def main():
    #instantiate classes
    fxn = Fxn()

    #Retrieve exif data
    if (len(sys.argv) < 2):
        #use default image
        data = Data("images/img3.jpg")
        exifData = data.get_exif("images/img2.jpg")
        program(fxn, data, exifData, "images/img3.jpg")
    elif (len(sys.argv) == 2):
        data = Data(sys.argv[1])
        exifData = data.get_exif(sys.argv[1])
        program(fxn, data, exifData, sys.argv[1])
    elif (len(sys.argv) > 2):
        #error
        print "Please pass only 1 image to this program as an argument"
Ejemplo n.º 10
0
def main():
    #instantiate classes
    fxn = Fxn()

    #Retrieve exif data
    if (len(sys.argv) < 2):
        #use default image
        data = Data("./phones/s3mini/20140419_182512.jpg")
        exifData = data.get_exif("./phones/s3mini/20140419_182512.jpg", True,
                                 True)
        program(fxn, data, exifData, "./phones/s3mini/20140419_182512.jpg")
    elif (len(sys.argv) == 2):
        data = Data(sys.argv[1])
        exifData = data.get_exif(sys.argv[1], True, False)
        program(fxn, data, exifData, sys.argv[1])
    elif (len(sys.argv) > 2):
        #error
        print "Please pass only 1 image to this program as an argument"
Ejemplo n.º 11
0
import os
from retrieve_image_data import RtrvData

test = RtrvData("./images/img6.jpg")
test.get_rgb("./images/img6.jpg")