Example #1
0
def auto(f,args):
	"""
	Input:
		f -- PIL Image file
		args -- arg parsed arguments
	Action:
		Based on file type, checks for trailing information in file. Print and save if found.
	Returns:
		Nothing
	"""
	
	try:
		if f.format == "JPEG":
			jpeg(f,args)
		elif f.format == "TIFF":
			tiff(f,args)
		elif f.format == "PNG":
			png(f,args)
		elif f.format == "BMP":
			bmp(f,args)
		elif f.format == "GIF":
			gif(f,args)
		else:
			print("Image Trailing: No support yet for format {0}".format(f.format))
			return
	except:
		print("Image Trailing: Something went wrong... please submit a bug report")
Example #2
0
def auto(f, args):
    """
	Input:
		f -- PIL Image file
		args -- arg parsed arguments
	Action:
		Based on file type, checks for trailing information in file. Print and save if found.
	Returns:
		Nothing
	"""

    try:
        if f.format == "JPEG":
            jpeg(f, args)
        elif f.format == "TIFF":
            tiff(f, args)
        elif f.format == "PNG":
            png(f, args)
        elif f.format == "BMP":
            bmp(f, args)
        elif f.format == "GIF":
            gif(f, args)
        else:
            print("Image Trailing: No support yet for format {0}".format(
                f.format))
            return
    except:
        print(
            "Image Trailing: Something went wrong... please submit a bug report"
        )
Example #3
0
def hello_world():
    term=request.args.get('text')
    if term:
        imglink=gif(term)
    else:
        imglink=gif("failure")
    response = { 
    "response_type" : "in_channel",
    "attachments" : [
        {"fallback": "Image search found "+imglink,
        "image_url":imglink }
        ]
    } 
    if len(imglink) > 5:
        return jsonify(**response)
    else:
        return "No gif found :("
Example #4
0
def crescendostats(user,action,parameter):
    print "Action! " + action
    if action == 'tenants':
        return listAllTenants()
    elif action == 'help':
        return getHelp()
    elif action == 'metrics over time':
        return gif.gif('funny graph')
    elif action == 'tenant count':
        return tenantCount()
    elif action == 'users':
        return listAllUsers()
    elif action == 'user count':
        return userCount()
    elif action == 'people count':
        return peopleCount()
    elif action == 'total signups':
        return gif.gif("not done yet")
    elif action == 'onboarded':
        return gif.gif("not done yet")
    elif action == 'summary':
        return summary()
    elif action == 'get blacklist':
        return getBlackList()
    elif action == 'blacklist tenant':
        print 'param'
        print parameter
        if parameter is not None and parameter != "":
            blackListTenant(parameter)
            return getBlackList()
        else:
            return "YOU SHALL NOT PASS! (without a tenant id)"
    elif action == 'unblacklist tenant':
        if parameter is not None and parameter != "":
            unBlackListTenant(parameter)
            return getBlackList()
        else:
            return gif.gif("YOU SHALL NOT PASS")
    else:
        print 'BAD THINGS BILL BAD BAD THINGS'
        return gif.gif('you done f****d up')
Example #5
0
def gif(f,args):
	from gif import gif
	
	# Load up the gif
	g = gif(fileName=f.filename)
	
	# Parse it
	g.parse()
	
	# Check for excess info
	if len(g.gif) > 0:
		print("Discovered trailing data: {0}".format(g.gif))
		with open(os.path.join(args.outDir,"trailing_data.bin"),"wb") as outFile:
			outFile.write(g.gif)
Example #6
0
def gif(f, args):
    from gif import gif

    # Load up the gif
    g = gif(fileName=f.filename)

    # Parse it
    g.parse()

    # Check for excess info
    if len(g.gif) > 0:
        print("Discovered trailing data: {0}".format(g.gif))
        with open(os.path.join(args.outDir, "trailing_data.bin"),
                  "wb") as outFile:
            outFile.write(g.gif)
Example #7
0
    def dfs(self, gr: Graph, v: int):
        self.marked[v] = True
        for w in gr.adjlist(v):
            if not self.rmarked(w):
                self.edgeTo[w] = v
                self.dfs(gr, w)

    def hasPathTo(self, v: int) -> bool:
        return self.marked[v]

    def pathTo(self, v: int) -> list:
        if not self.hasPathTo(v):
            return None

        path = []
        path.append(v)
        x = self.edgeTo[v]

        while x != v:
            x = self.edgeTo[x]
            path.append(x)
        path.append(self.s)
        return path


if __name__ == "__main__":
    gr = getGr()
    df = DFS(gr, 0)
    gif()
    pass
Example #8
0
def main():

    #command line argument
    parser = argparse.ArgumentParser()
    parser.add_argument("-p",
                        "--plot",
                        default="no_img",
                        help="Either no_img, or plot_img")
    args = parser.parse_args()
    PLOT = args.plot

    # load images, which are stored in a folder named 'rectified' in the same directory as this file
    data_dir = os.path.dirname(os.path.abspath(__file__))
    ic = io.collection.ImageCollection(data_dir + '/rectified/*.png')
    half_idx = len(ic) // 2
    #load a few frames for testing
    '''
	left_ic = ic[0+513:500+513]
	right_ic = ic[half_idx+513:half_idx+500+513]
	ic = None
	'''
    left_ic = ic[:half_idx]
    right_ic = ic[half_idx:]
    # images have shape (480, 640, 3)
    csv_file = open("points.csv", mode='w')
    csv_features_file = open("features.csv", mode='w')
    csv_writer = csv.writer(csv_file,
                            delimiter=',',
                            quotechar='"',
                            quoting=csv.QUOTE_MINIMAL)
    csv_feature_writer = csv.writer(csv_features_file,
                                    delimiter=',',
                                    quotechar='"',
                                    quoting=csv.QUOTE_MINIMAL)
    # initial camera pose
    C = np.diag(np.ones(4))
    # store the last valid frames in case of skipping frames
    prevl = []
    prevr = []
    pts = np.array([])
    for i in range(len(left_ic) - 1):
        print("Iteration ", i, "/", len(left_ic) - 1)
        # current frame
        imgl1 = left_ic[i]
        imgr1 = right_ic[i]
        imgl2 = left_ic[i + 1]
        imgr2 = right_ic[i + 1]
        if PLOT.lower() == 'no_img':
            matchesl1, matchesr1, matchesl2, matchesr2 = match_features(
                imgl1, imgr1, imgl2, imgr2)
        if PLOT.lower() == 'plot_img':
            matchesl1, matchesr1, matchesl2, matchesr2 = match_features_plot(
                imgl1, imgr1, imgl2, imgr2)
        if (matchesl1.shape[0] >= 3):
            # get matches
            F, inliers_a1, inliers_b1, inliers_a2, inliers_b2, = ransac_F_Matrix(
                matchesl1, matchesr1, matchesl2, matchesr2)
            std_threshold = 2
            # triangulate to find real-world points
            coords3d1 = triangulate(inliers_a1, inliers_b1)
            coords3d2 = triangulate(inliers_a2, inliers_b2)
            if (len(coords3d1) == 0 or len(coords3d2) == 0):
                print("skipping frame \n")
                continue
            z1 = coords3d1[:, 2]
            z2 = coords3d2[:, 2]
            if (i == 0):
                pts = np.append(pts, z1)
            pts = np.append(pts, z2)
            if (len(pts) > 100):
                pts = pts[:100]
            mean = np.mean(pts)
            std = np.std(pts)

            mean1 = np.mean(z1)
            mean2 = np.mean(z2)

            zstd1 = mean1 / std
            zstd2 = mean2 / std

            print("std:", zstd1, zstd2)
            # both frames k and k+1 invalid, skip
            if (zstd1 >= std_threshold and zstd2 >= std_threshold):
                print("skipping frame \n")
                continue
            # frame k invalid, frame k+1 valid
            elif (zstd1 >= std_threshold and zstd2 < std_threshold):
                # use last valid frame if exists, otherwise skip
                if (prevl != [] and prevr != []):
                    matchesl1, matchesr1, matchesl2, matchesr2 = match_features(
                        prevl, prevr, imgl2, imgr2)
                    F, inliers_a1, inliers_b1, inliers_a2, inliers_b2, = ransac_F_Matrix(
                        matchesl1, matchesr1, matchesl2, matchesr2)
                    coords3d1 = triangulate(inliers_a1, inliers_b1)
                    coords3d2 = triangulate(inliers_a2, inliers_b2)
                else:
                    print("skipping frame \n")
                    continue
            # frame k valid, frame k+1 invalid
            elif (zstd1 < std_threshold and zstd2 >= std_threshold):
                prevl = copy.deepcopy(imgl1)
                prevr = copy.deepcopy(imgr1)
                print("skipping frame \n")
                continue
            # both frames valid
            else:
                prevl = []
                prevr = []

            inliers = coords3d1.shape[0]
            coords_abs = C.T @ np.append(
                coords3d1, np.ones((inliers, 1)), axis=1).T
            csv_feature_writer.writerows(coords_abs[0:3, :].T)
            C_new = update_camera_pose(coords3d1, coords3d2, C)
            pose_distance = np.linalg.norm(C_new[0:3, 3] - C[0:3, 3])
            rejection_threshold = 0.5  #meters
            print("Pose", C[0:3, 3])
            print("Pose Distance", pose_distance)
            if (pose_distance < rejection_threshold):
                C = C_new
            else:
                print("pose rejected")

        plot_C[i] = C[0:3, 3].T
        csv_writer.writerow(plot_C[i])
        print("")

    gif(plot_C)