Пример #1
0
def hello():
	try:
		if request.method == 'POST':	
		# check if the post request has the file part
			header_req = request.headers.get('x-image-profile-id')
			photo = request.files['photo'] #if photo is present in the request object
			in_memory_file = io.BytesIO()
			photo.save(in_memory_file)
			data = np.fromstring(in_memory_file.getvalue(), dtype=np.uint8)
			color_image_flag = 1

			img = cv2.imdecode(data, color_image_flag) #img is the image
			v = dummy5.image_calc(img)
		
			list1 = v.values()
			if list1[0] == []:
				ret_val={'x-image-profile-id':header_req,'message':'images not found','status':0,'data':list1 }
				return 	jsonify(**ret_val)
			else:	
				ret_val={'x-image-profile-id':header_req,'message':'images found','status':1,'data':list1 }
				return 	jsonify(**ret_val)			
		
	except:
		ret_val={'x-image-profile-id':header_req,'message':'server error.(Load Data first then do the search)','status':0,'data':'No Data' }
		return 	jsonify(**ret_val)
Пример #2
0
def hello():
    print 'HELOO*******'
    try:
        if request.method == 'POST':
            # check if the post request has the file part
            #header_req = request.headers.get('x-image-profile-id')

            photo = request.files[
                'photo']  #if photo is present in the request object

            in_memory_file = io.BytesIO()
            photo.save(in_memory_file)
            data1 = np.fromstring(in_memory_file.getvalue(), dtype=np.uint8)
            color_image_flag = 1

            img = cv2.imdecode(data1, color_image_flag)  #img is the image
            v = dummy5.image_calc(img)

            #list2 = v.values()
            #out = list2[0]
            #new_out = []
            #for x in range(len(out)):
            #print out[x]
            #if out[x] == "None":
            #continue
            #else:
            #new_out.append(out[x])

            #out = str(out)
            #new_out = json.dumps(new_out)
            new_out = v
            print new_out
            print len(new_out)
            if len(new_out) == 0:
                new_out = json.dumps(new_out)
                ret_val = {
                    'message': 'images not found',
                    'status': 0,
                    'data': new_out
                }
                return jsonify(**ret_val)
            else:
                new_out = json.dumps(new_out)
                ret_val = {
                    'message': 'images found',
                    'status': 1,
                    'data': new_out
                }
                return jsonify(**ret_val)

    except:
        ret_val = {
            'message': 'server error. database empty',
            'status': 0,
            'data': 'No Data'
        }
        return jsonify(**ret_val)
Пример #3
0
def hello(post_id):
    try:
        v = dummy5.image_calc(post_id)

        list1 = v.values()
        if list1[0] == []:
            return 'EmptyList'
        else:
            return jsonify(v)

    except:
        print 'Err'
Пример #4
0
def hello():
    try:
        if request.method == 'POST':
            # check if the post request has the file part
            #header_req = request.headers.get('x-image-profile-id')

            photo = request.files[
                'photo']  #if photo is present in the request object

            in_memory_file = io.BytesIO()
            photo.save(in_memory_file)
            data1 = np.fromstring(in_memory_file.getvalue(), dtype=np.uint8)
            color_image_flag = 1

            img = cv2.imdecode(data1, color_image_flag)  #img is the image
            v = dummy5.image_calc(img)
            v = list(set(v))
            print v
            print len(v)
            if len(v) == 0:
                v = json.dumps(v)
                ret_val = {
                    'message': 'images not found',
                    'status': 0,
                    'data': v
                }
                return jsonify(**ret_val)
            else:
                v = json.dumps(v)
                ret_val = {'message': 'images found', 'status': 1, 'data': v}
                return jsonify(**ret_val)

    except:
        ret_val = {
            'message': 'server error. database empty',
            'status': 0,
            'data': 'No Data'
        }
        return jsonify(**ret_val)