def search(): if request.method == 'POST': results_arr = [] img_path = request.form.get('img') try: import cv2 d = Descriptor((8, 12, 3)) query = cv2.imread('static/images/' + img_path) features = d.describe(query) searcher = Searcher('index.csv') results = searcher.search(features) for (score, id) in results: results_arr.append({'image': str(id), 'score': str(score)}) return jsonify(results=(results_arr[::-1][:5])) except: return jsonify( {'sorry': 'Sorry, something went wrong! Please try again.'})
default=20, type=int) # analizer related options analizer = parser.add_argument_group('analizer') analizer.add_argument("-k", "--keyword", dest="keyword", required=True, help="Sentence to search on the web") analizer.add_argument("-e", "--engine", dest="engine", type=str, help="Engine to use for searching." " Defaults to google ", default="google") analizer.add_argument("-l", "--num-links", dest="number_of_links", help="Number of links to return. " "Defaults to 20", default=20, type=int) args = parser.parse_args() g = Searcher(args.keyword, engine=args.engine, number_of_links=args.number_of_links) print args links = g.get_links()