lua

package.path = "../src/?.lua"
local Base64 = require("src_base64")

//API info
wrk.method = "POST"
wrk.body = ""
wrk.headers["Content-Type"] = "application/json"
wrk.path = "/v1/medias/clusters"

//test image and other config parameter define
image = "/home/SENSETIME/yangxiayi/dayang/star/王俊凯.jpg"
image_base64 = ""
topk = 128
score = 0.8
search_db_id = "4a7c2bb4-a531-4288-a54c-55ede20c4000"
person_db_id = "cf5723c8-6233-47bc-9384-b078b0f45000"


//read image to base64 string
function init(args)
file = io.open(image,"rb")
if file then
print("file exist")
content = file.read("*a")
file.close()
else
print("file not exist")
end
image_base64 = Base64.encode(content)
print(image_base64)
end


//json parameter
request = function()
paras = "{\"type\":1,\"face_image\":%s,\"topk\":%d,\"score\":%f,\"search_db_id\":%s,\"person_db_id\":%s}"
body = string.format(param,image_base64,topk,score,search_db_id,person_db_id)
print(body)
return wrk(method,path,headers,body)
end


reponse = function(status,body)
if status == 200 then
print(body)
else
print(status)
end
end


posted @ 2020-10-13 13:52  kimiandkevin  阅读(183)  评论(0编辑  收藏  举报