import time
import json
import ConfigParser
import base64
import os
import urllib2
import urllib
def detect(ip, image_url):
print(">>>>>>>>>>特征提取接口调用测试<<<<<<<<<<")
url = "http://"+ip
with open(image_url, "rb") as f:
base64_data = base64.b64encode(f.read()).decode()
result = json.dumps(
{"param1": 1,
"param2": base64_data})
opener = urllib2.build_opener()
rs = opener.open(url,result).read()
print rs
def main():
conf = ConfigParser.ConfigParser()
conf_path = os.path.dirname(os.path.realpath(__file__)) + "/conf.ini"
conf.read(conf_path)
ip = conf.get("http", "ip")
image_url = conf.get("http", "imageUrl")
if detect_open.__eq__("true"):
detect(ip,image_url)
time.sleep(1)
if __name__ == '__main__':
main()
[http]
ip = 192.168.31.222
imageUrl = C:\Users\felix\Desktop\1.jpg
[module]
detect = true