Commit 87e93f98 by wangquyuan

change port to 8088

1 parent 28bedfc1
......@@ -2,6 +2,7 @@
method:post
url: /query/feature
url: /resources/query/feature
Content-Type:"application/x-www-form-urlencoded"
参数:
......@@ -26,7 +27,7 @@ Content-Type:"application/x-www-form-urlencoded"
2: 获取情绪
method:post
url: /query/emotion
url: /resources/query/emotion
Content-Type:"application/x-www-form-urlencoded"
......@@ -51,7 +52,7 @@ Content-Type:"application/x-www-form-urlencoded"
3: 获取微表情
method:post
url: /query/action
url: /resources/query/action
Content-Type:"application/x-www-form-urlencoded"
......@@ -78,7 +79,7 @@ Content-Type:"application/x-www-form-urlencoded"
因为视频文件可能比较大,所以采用文件上传的方式来上传视频文件,所以Content-Type采用"multipart/form-data"
method:post
url: /query/video
url: /resources/query/video
Content-Type:"multipart/form-data"
......
{
"bindip":"",
"http_port":4000,
"http_port":8088,
"http_work_threads":5,
"work_timeout":10,
"logpath":"/tmp",
"datapath":"/tmp",
"savevideo":1,
"savevideo":0,
"device":"gpu",
"device":"cpu",
"models": {
"face_detector":"SeetaFaceDetector6.0.IPC.sta",
......
......@@ -111,7 +111,7 @@ include_directories(/usr/local/include)
#target_link_libraries(${PROJECT_NAME} -L/wqy/test/test2/srpc/example -lsrpc -lworkflow -lprotobuf)
target_link_libraries(${PROJECT_NAME} -L/usr/local/lib -lORZ_static)
target_link_libraries(${PROJECT_NAME} -L/usr/local/lib64 -lORZ_static)
#include_directories(/usr/local/include)
#target_link_libraries(${PROJECT_NAME} -L/usr/local/lib -lmysqlcppconn)
......
......@@ -1784,7 +1784,7 @@ void on_http( httpserver *s, websocketpp::connection_hdl hdl )
//std::cout << "post:body:" << strBody << std::endl;
string strContentType = rt.get_header( "Content-Type" );
std::cout << "----ContentType:" << strContentType << std::endl;
if( strUri == "/query/video" )
if( strUri == "/resources/query/video" )
{
string sformdata = "multipart/form-data";
string stype = strContentType.substr( 0, sformdata.length() );
......@@ -2016,23 +2016,23 @@ void on_http( httpserver *s, websocketpp::connection_hdl hdl )
return;
}
if( strUri == "/query/feature" )
if( strUri == "/resources/query/feature" )
{
strresponse = do_query_face_feature( strBody );
create_http_response( con, strresponse, 200 );
}
else if( strUri == "/query/action" )
else if( strUri == "/resources/query/action" )
{
strresponse = do_query_face_action( strBody );
create_http_response( con, strresponse, 200 );
}
else if( strUri == "/query/emotion" )
else if( strUri == "/resources/query/emotion" )
{
strresponse = do_query_face_emotion( strBody );
create_http_response( con, strresponse, 200 );
}
/*
else if( strUri == "/query/pose" )
else if( strUri == "/resources/query/pose" )
{
strresponse = do_query_face_pose( strBody );
create_http_response( con, strresponse, 200 );
......@@ -2068,7 +2068,7 @@ void on_http( httpserver *s, websocketpp::connection_hdl hdl )
std::map<std::string, std::string> params;
geturlparameters( parameters, params );
if( method == "/query/pots" )
if( method == "/resources/query/pots" )
{
//strresponse = do_query_pots( strBody );
create_http_response( con, strresponse, 200 );
......
......@@ -23,8 +23,25 @@ import (
)
type TestJson struct {
Taskid int `json:"taskid"`
//Nodeid int `json:"nodeid"`
Favorite_name string `json:"favorite_name"`
//Gpus []int `json:"gpus"`
//Auto_dispatch int `json:"auto_dispatch"`
Gpu_names []string `json:"gpu_names"`
Image_base64 string `json:"image_base64"`
Image_name string `json:"image_name"`
}
type TestexJson struct {
Token string `json:"token"`
Image_base64 string `json:"image_base64"`
Image_name string `json:"image_name"`
}
type Response struct {
Code int `json:"code"`
......@@ -52,8 +69,9 @@ func get_feature(filename, url string) bool {
data := "imgStr=" + strdata
//seq := "http://192.168.1.33:4000/query/feature"
seq := url + "/query/feature"
//seq := url + "/query/feature"
seq := url + "/resources/query/feature"
//client := &http.Client{}
//request, err := http.NewRequest("POST", seq, strings.NewReader(data))
......@@ -120,8 +138,9 @@ func get_action(filename, url string) bool {
data := "imgStr=" + strdata
//seq := "http://192.168.1.33:4000/query/feature"
seq := url + "/query/action"
//seq := url + "/query/action"
seq := url + "/resources/query/action"
//client := &http.Client{}
//request, err := http.NewRequest("POST", seq, strings.NewReader(data))
......@@ -188,8 +207,9 @@ func get_emotion(filename, url string) bool {
data := "imgStr=" + strdata
//seq := "http://192.168.1.33:4000/query/feature"
seq := url + "/query/emotion"
//seq := url + "/query/emotion"
seq := url + "/resources/query/emotion"
//client := &http.Client{}
//request, err := http.NewRequest("POST", seq, strings.NewReader(data))
......@@ -256,8 +276,9 @@ func get_video(filename, url string) bool {
data += "&frameNum=10"
//seq := "http://192.168.1.33:4000/query/feature"
seq := url + "/query/video"
//seq := url + "/query/video"
seq := url + "/resources/query/video"
client := &http.Client{}
request, err := http.NewRequest("POST", seq, strings.NewReader(data))
......@@ -361,8 +382,9 @@ func get_video2(filename, url string) bool {
data += "&frameNum=10"
*/
//seq := "http://192.168.1.33:4000/query/feature"
seq := url + "/query/video"
//seq := url + "/query/video"
seq := url + "/resources/query/video"
client := &http.Client{}
request, err := http.NewRequest("POST", seq, body)
......@@ -450,6 +472,273 @@ func get_video2(filename, url string) bool {
}
func get_test(filename, url, token string) bool {
//data := `{"check_id":"sJjcUq2CORH8tTjSNJ14","check_code":"97369"}`
//str := sign(data)
data1, err := ioutil.ReadFile(filename)
if err != nil {
fmt.Println("read file failed: ", err.Error())
return false
}
strdata := base64.StdEncoding.EncodeToString(data1)
base := filepath.Base(filename)
var t TestJson
t.Image_name = base
t.Image_base64 = strdata
//t.Gpus = append(t.Gpus, 0)
t.Gpu_names = append(t.Gpu_names, "NVIDIA TITAN Xp")
//t.Taskid = 773
t.Favorite_name = "batchtrain #3"
//t.Nodeid = 3
data, err := json.Marshal(t)
//data := "userVideo=" + strdata
//data += "&frameNum=10"
//seq := "http://192.168.1.33:4000/query/feature"
//seq := url + "/forward"
client := &http.Client{}
request, err := http.NewRequest("POST", url, strings.NewReader(string(data)))
if err != nil {
fmt.Println("create request failed: " , err)
return false
}
//resp, err := http.Post(seq, "application/x-www-form-urlencoded",
// strings.NewReader(data))
//if err != nil {
// fmt.Println("send request error: " , err)
// return false
//}
//request.Header.Add("Authorization","AIPSS1.0 " + str)
request.Header.Add("Content-Type","application/json; charset=utf-8")
request.Header.Add("token",token)
resp, err := client.Do(request)
if err != nil {
fmt.Println("send error: " , err)
return false
}else {
fmt.Println("send ok")
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println("LoginSeetaAuthCenter ReadAll failed: ", err)
return false
}else {
fmt.Println("length:", len(body))
}
fmt.Println(string(body))
/*
var res Response2
err = json.Unmarshal(body, &res)
if err != nil {
fmt.Println("Unmarshal error:", err)
return false
}
if res.Code == 0 {
fmt.Println("face detector ok" )
//bits := base64.StdEncoding.DecodeToString(res.Data)
fmt.Println(res)
}else {
fmt.Println("face detector falied" )
}
*/
return true
}
func get_testex(filename, url, token,containertoken string) bool {
//data := `{"check_id":"sJjcUq2CORH8tTjSNJ14","check_code":"97369"}`
//str := sign(data)
data1, err := ioutil.ReadFile(filename)
if err != nil {
fmt.Println("read file failed: ", err.Error())
return false
}
strdata := base64.StdEncoding.EncodeToString(data1)
base := filepath.Base(filename)
var t TestexJson
t.Image_name = base
t.Image_base64 = strdata
t.Token = containertoken
//t.Gpus = append(t.Gpus, 0)
//t.Taskid = 613
//t.Nodeid = 3
data, err := json.Marshal(t)
//data := "userVideo=" + strdata
//data += "&frameNum=10"
//seq := "http://192.168.1.33:4000/query/feature"
//seq := url + "/forward"
client := &http.Client{}
request, err := http.NewRequest("POST", url, strings.NewReader(string(data)))
if err != nil {
fmt.Println("create request failed: " , err)
return false
}
//resp, err := http.Post(seq, "application/x-www-form-urlencoded",
// strings.NewReader(data))
//if err != nil {
// fmt.Println("send request error: " , err)
// return false
//}
//request.Header.Add("Authorization","AIPSS1.0 " + str)
request.Header.Add("Content-Type","application/json; charset=utf-8")
request.Header.Add("token",token)
resp, err := client.Do(request)
if err != nil {
fmt.Println("send error: " , err)
return false
}else {
fmt.Println("send ok")
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println("LoginSeetaAuthCenter ReadAll failed: ", err)
return false
}else {
fmt.Println("length:", len(body))
}
fmt.Println(string(body))
return true
}
type UploadSdkDatasetJson2 struct {
Name string `json:"name"`
Filename string `json:"filename"`
Data string `json:"data"`
Savepath string `json:"savepath"`
Force int `json:"force"`
}
func get_upload(filename, url, token string) bool {
//data := `{"check_id":"sJjcUq2CORH8tTjSNJ14","check_code":"97369"}`
//str := sign(data)
data1, err := ioutil.ReadFile(filename)
if err != nil {
fmt.Println("read file failed: ", err.Error())
return false
}
strdata := base64.StdEncoding.EncodeToString(data1)
base := filepath.Base(filename)
var t UploadSdkDatasetJson2
t.Filename = base
t.Data = strdata
//t.Gpus = append(t.Gpus, 0)
//t.Gpu_names = append(t.Gpu_names, "NVIDIA TITAN Xp")
t.Name = "Dataset-8"
//t.Favorite_name = "batchtrain #3"
t.Force = 1
t.Savepath = "/upload/images/"
data, err := json.Marshal(t)
//data := "userVideo=" + strdata
//data += "&frameNum=10"
//seq := "http://192.168.1.33:4000/query/feature"
//seq := url + "/forward"
client := &http.Client{}
request, err := http.NewRequest("POST", url, strings.NewReader(string(data)))
if err != nil {
fmt.Println("create request failed: " , err)
return false
}
//resp, err := http.Post(seq, "application/x-www-form-urlencoded",
// strings.NewReader(data))
//if err != nil {
// fmt.Println("send request error: " , err)
// return false
//}
//request.Header.Add("Authorization","AIPSS1.0 " + str)
request.Header.Add("Content-Type","application/json; charset=utf-8")
request.Header.Add("token",token)
resp, err := client.Do(request)
if err != nil {
fmt.Println("send error: " , err)
return false
}else {
fmt.Println("send ok")
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println("LoginSeetaAuthCenter ReadAll failed: ", err)
return false
}else {
fmt.Println("length:", len(body))
}
fmt.Println(string(body))
/*
var res Response2
err = json.Unmarshal(body, &res)
if err != nil {
fmt.Println("Unmarshal error:", err)
return false
}
if res.Code == 0 {
fmt.Println("face detector ok" )
//bits := base64.StdEncoding.DecodeToString(res.Data)
fmt.Println(res)
}else {
fmt.Println("face detector falied" )
}
*/
return true
}
......@@ -457,12 +746,17 @@ func get_video2(filename, url string) bool {
var gname string
var gfilename string
var gurl string
var gtoken string
var gcontainertoken string
func init() {
flag.StringVar(&gname, "t", "", "feature,action,emotion,video")
flag.StringVar(&gname, "t", "", "feature,action,emotion,video,test,testex,upload")
flag.StringVar(&gfilename, "f", "", "image file")
flag.StringVar(&gurl, "h", "http://127.0.0.1:60000", "http url")
flag.StringVar(&gtoken, "k", "", "token")
flag.StringVar(&gcontainertoken, "p", "", "container token")
}
func main() {
......@@ -470,7 +764,9 @@ func main() {
fmt.Println("name:" + gname)
fmt.Println("filename:" + gfilename)
fmt.Println("url:" + gurl)
fmt.Println("token:" + gtoken)
fmt.Println("container token:" + gcontainertoken)
if gname == "feature" {
get_feature(gfilename, gurl)
}else if gname == "action" {
......@@ -479,6 +775,12 @@ func main() {
get_emotion(gfilename, gurl)
}else if gname == "video" {
get_video2(gfilename, gurl)
}else if gname == "test" {
get_test(gfilename, gurl, gtoken)
}else if gname == "testex" {
get_testex(gfilename, gurl, gtoken, gcontainertoken)
}else if gname == "upload" {
get_upload(gfilename, gurl, gtoken)
}else {
fmt.Println("not support type:",gname)
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!