Commit 4ecd2107 authored by 郝文豪's avatar 郝文豪

1.新增一次上传3张图片接口。2.新增上传视频流物品进入3张图片和物品离开3张图片。

parent 7dff47ea
No preview for this file type
......@@ -138,7 +138,7 @@ int CommonTools::upload_file(const char* url, const char* fileName, string& resp
//return 0;
}
int CommonTools::upload_file1(const char* url, const char* fileName1, const char* fileName2, const char* fileName3, string& response) {
int CommonTools::upload_file1(const char* url, const char* fileName1, const char* fileName2, const char* fileName3,vector<string>&res, string& response) {
CURL* curl;
CURLcode ret;
curl = curl_easy_init();
......@@ -148,9 +148,10 @@ int CommonTools::upload_file1(const char* url, const char* fileName1, const char
{
curl_easy_setopt(curl, CURLOPT_URL, url); //指定url
curl_formadd(&post, &last, CURLFORM_PTRNAME, "path", CURLFORM_PTRCONTENTS, "device_cover", CURLFORM_END);//form-data key(path) 和 value(device_cover)
curl_formadd(&post, &last, CURLFORM_PTRNAME, "file", CURLFORM_FILE, fileName1, CURLFORM_FILENAME, "hello.jpg", CURLFORM_END);// form-data key(file) "./test.jpg"为文件路径 "hello.jpg" 为文件上传时文件名
curl_formadd(&post, &last, CURLFORM_PTRNAME, "file2", CURLFORM_FILE, fileName2, CURLFORM_FILENAME, "hello.jpg", CURLFORM_END);
curl_formadd(&post, &last, CURLFORM_PTRNAME, "file3", CURLFORM_FILE, fileName3, CURLFORM_FILENAME, "hello.jpg", CURLFORM_END);
curl_formadd(&post, &last, CURLFORM_PTRNAME, "file", CURLFORM_FILE, fileName1, CURLFORM_FILENAME,res[0].c_str(), CURLFORM_END);// form-data key(file) "./test.jpg"为文件路径 "hello.jpg" 为文件上传时文件名
curl_formadd(&post, &last, CURLFORM_PTRNAME, "file2", CURLFORM_FILE, fileName2, CURLFORM_FILENAME, res[1].c_str(), CURLFORM_END);
curl_formadd(&post, &last, CURLFORM_PTRNAME, "file3", CURLFORM_FILE, fileName3, CURLFORM_FILENAME, res[2].c_str(), CURLFORM_END);
curl_formadd(&post, &last, CURLFORM_PTRNAME,"type", CURLFORM_PTRCONTENTS, res[3].c_str(), CURLFORM_END);
curl_easy_setopt(curl, CURLOPT_HTTPPOST, post); //构造post参数
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 3);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data); //绑定相应
......
......@@ -32,5 +32,5 @@ public:
// htpp put 请求
static CURLcode HttpPut(const std::string& strUrl, std::string szJson, std::string& strResponse, int nTimeout);
static CURLcode HttpDelete(const std::string& strUrl, std::string& strResponse, int nTimeout);
static int upload_file1(const char* url, const char* fileName1, const char* fileName2, const char* fileName3, string& response);
static int upload_file1(const char* url, const char* fileName1, const char* fileName2, const char* fileName3,vector<string>& res, string& response);
};
\ No newline at end of file
No preview for this file type
No preview for this file type
......@@ -8,45 +8,46 @@ C:\Users\1\Desktop\fresh-plug-ins\CharacterConversion.cpp(29,10): warning C4244:
CppSQLite3.cpp
dllmain.cpp
WmAceKG-x86.cpp
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(541,17): warning C4244: “=”: 从“double”转换到“float”,可能丢失数据
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(911,20): warning C4244: “=”: 从“double”转换到“float”,可能丢失数据
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(921,18): warning C4244: “初始化”: 从“clock_t”转换到“float”,可能丢失数据
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(938,16): warning C4244: “初始化”: 从“clock_t”转换到“float”,可能丢失数据
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(1034,20): warning C4244: “初始化”: 从“int”转换到“float”,可能丢失数据
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(542,17): warning C4244: “=”: 从“double”转换到“float”,可能丢失数据
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(912,20): warning C4244: “=”: 从“double”转换到“float”,可能丢失数据
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(922,18): warning C4244: “初始化”: 从“clock_t”转换到“float”,可能丢失数据
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(939,16): warning C4244: “初始化”: 从“clock_t”转换到“float”,可能丢失数据
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(1035,20): warning C4244: “初始化”: 从“int”转换到“float”,可能丢失数据
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(1125,17): warning C4244: “初始化”: 从“time_t”转换到“long”,可能丢失数据
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(1189,22): warning C4477: “sprintf”: 格式字符串“%lld”需要类型“__int64”的参数,但可变参数 1 拥有了类型“int”
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(1189,22): message : 请考虑在格式字符串中使用“%d”
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(1189,22): message : 请考虑在格式字符串中使用“%Id”
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(1189,22): message : 请考虑在格式字符串中使用“%I32d”
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(1250,45): warning C4244: “return”: 从“double”转换到“float”,可能丢失数据
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(1439,18): warning C4477: “sprintf”: 格式字符串“%d”需要类型“int”的参数,但可变参数 1 拥有了类型“const _Elem *”
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(1036,20): warning C4244: “初始化”: 从“int”转换到“float”,可能丢失数据
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(1126,17): warning C4244: “初始化”: 从“time_t”转换到“long”,可能丢失数据
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(1190,22): warning C4477: “sprintf”: 格式字符串“%lld”需要类型“__int64”的参数,但可变参数 1 拥有了类型“int”
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(1190,22): message : 请考虑在格式字符串中使用“%d”
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(1190,22): message : 请考虑在格式字符串中使用“%Id”
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(1190,22): message : 请考虑在格式字符串中使用“%I32d”
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(1251,45): warning C4244: “return”: 从“double”转换到“float”,可能丢失数据
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(1440,18): warning C4477: “sprintf”: 格式字符串“%d”需要类型“int”的参数,但可变参数 1 拥有了类型“const _Elem *”
with
[
_Elem=char
]
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(1439,18): warning C4477: “sprintf”: 格式字符串“%d”需要类型“int”的参数,但可变参数 8 拥有了类型“const _Elem *”
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(1440,18): warning C4477: “sprintf”: 格式字符串“%d”需要类型“int”的参数,但可变参数 8 拥有了类型“const _Elem *”
with
[
_Elem=char
]
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(1607,23): warning C4018: “<”: 有符号/无符号不匹配
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(1682,34): warning C4244: “参数”: 从“double”转换到“float”,可能丢失数据
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(1868,34): warning C4244: “参数”: 从“double”转换到“float”,可能丢失数据
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(2124,22): warning C4018: “<”: 有符号/无符号不匹配
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(2169,27): warning C4244: “=”: 从“double”转换到“float”,可能丢失数据
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(2352,27): warning C4244: “=”: 从“double”转换到“float”,可能丢失数据
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(2964,21): warning C4018: “<”: 有符号/无符号不匹配
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(3052,20): warning C4018: “<”: 有符号/无符号不匹配
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(3205,21): warning C4244: “参数”: 从“float”转换到“DWORD”,可能丢失数据
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(3232,33): warning C4018: “>”: 有符号/无符号不匹配
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(3266,34): warning C4018: “<”: 有符号/无符号不匹配
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(3366,37): warning C4018: “<”: 有符号/无符号不匹配
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(3379,36): warning C4018: “<”: 有符号/无符号不匹配
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(3420,15): warning C4244: “初始化”: 从“clock_t”转换到“float”,可能丢失数据
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(3430,34): warning C4018: “>”: 有符号/无符号不匹配
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(3439,26): warning C4244: “=”: 从“UINT64”转换到“unsigned long”,可能丢失数据
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(3460,13): warning C4244: “初始化”: 从“clock_t”转换到“float”,可能丢失数据
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(1608,23): warning C4018: “<”: 有符号/无符号不匹配
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(1683,34): warning C4244: “参数”: 从“double”转换到“float”,可能丢失数据
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(1869,34): warning C4244: “参数”: 从“double”转换到“float”,可能丢失数据
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(2125,22): warning C4018: “<”: 有符号/无符号不匹配
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(2170,27): warning C4244: “=”: 从“double”转换到“float”,可能丢失数据
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(2353,27): warning C4244: “=”: 从“double”转换到“float”,可能丢失数据
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(2965,21): warning C4018: “<”: 有符号/无符号不匹配
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(3053,20): warning C4018: “<”: 有符号/无符号不匹配
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(3206,21): warning C4244: “参数”: 从“float”转换到“DWORD”,可能丢失数据
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(3233,33): warning C4018: “>”: 有符号/无符号不匹配
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(3267,34): warning C4018: “<”: 有符号/无符号不匹配
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(3315,20): warning C4018: “<”: 有符号/无符号不匹配
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(3416,37): warning C4018: “<”: 有符号/无符号不匹配
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(3429,36): warning C4018: “<”: 有符号/无符号不匹配
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(3470,15): warning C4244: “初始化”: 从“clock_t”转换到“float”,可能丢失数据
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(3480,34): warning C4018: “>”: 有符号/无符号不匹配
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(3489,26): warning C4244: “=”: 从“UINT64”转换到“unsigned long”,可能丢失数据
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(3510,13): warning C4244: “初始化”: 从“clock_t”转换到“float”,可能丢失数据
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\type_traits(1534,98): warning C4244: “参数”: 从“double”转换到“float”,可能丢失数据
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\thread(51): message : 查看对正在编译的函数 模板 实例化“int std::invoke<int(__cdecl *)(std::string,int,float,float,std::string,std::string,std::string,std::string),std::basic_string<char,std::char_traits<char>,std::allocator<char>>,int,int,double,std::basic_string<char,std::char_traits<char>,std::allocator<char>>,std::basic_string<char,std::char_traits<char>,std::allocator<char>>,std::basic_string<char,std::char_traits<char>,std::allocator<char>>,std::basic_string<char,std::char_traits<char>,std::allocator<char>>>(_Callable &&,_Ty1 &&,int &&,int &&,double &&,std::basic_string<char,std::char_traits<char>,std::allocator<char>> &&,std::basic_string<char,std::char_traits<char>,std::allocator<char>> &&,std::basic_string<char,std::char_traits<char>,std::allocator<char>> &&,std::basic_string<char,std::char_traits<char>,std::allocator<char>> &&) noexcept(false)”的引用
with
......@@ -66,7 +67,7 @@ C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.2
_Ty=int,
_Fn=int (__cdecl &)(std::string,int,float,float,std::string,std::string,std::string,std::string)
]
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(1785): message : 查看对正在编译的函数 模板 实例化“std::thread::thread<int(__cdecl &)(std::string,int,float,float,std::string,std::string,std::string,std::string),std::string&,int,int,double&,std::string,std::string,std::string,std::string,0>(_Fn,std::string &,int &&,int &&,double &,std::string &&,std::string &&,std::string &&,std::string &&)”的引用
C:\Users\1\Desktop\fresh-plug-ins\WmAceKG-x86.cpp(1786): message : 查看对正在编译的函数 模板 实例化“std::thread::thread<int(__cdecl &)(std::string,int,float,float,std::string,std::string,std::string,std::string),std::string&,int,int,double&,std::string,std::string,std::string,std::string,0>(_Fn,std::string &,int &&,int &&,double &,std::string &&,std::string &&,std::string &&,std::string &&)”的引用
with
[
_Fn=int (__cdecl &)(std::string,int,float,float,std::string,std::string,std::string,std::string)
......
......@@ -71,7 +71,8 @@
//纠错存 code和id
unordered_map<string, int>reassion;
string realProductCodes[10];
int rest = 0;
int rest_in = 0;
int rest_out = 0;
using namespace std;
using namespace cv;
using namespace rapidjson;
......@@ -3292,23 +3293,40 @@ void save_in_image()
char name2[128] = {};
char name3[128] = {};
char name4[128] = {};
vector<string>res;
string pre1;
string pre2;
string pre3;
sprintf(name2, path, dir.c_str(), time.c_str(), time.c_str(), i++);
pre1 = pre1 + time.c_str() + "-" + "1" + ".jpg";
res.push_back(pre1);
cv::imwrite(name2, param_in.back);
sprintf(name3, path, dir.c_str(), time.c_str(), time.c_str(), i++);
pre2 = pre2 + time.c_str() + "-" + "2" + ".jpg";
res.push_back(pre2);
cv::imwrite(name3, param_in.frame_out[3].img);
sprintf(name4, path, dir.c_str(), time.c_str(), time.c_str(), i++);
pre3 = pre3 + time.c_str() + "-" + "3" + ".jpg";
res.push_back(pre3);
cv::imwrite(name4, param_in.frame_out[4].img);
if (rest < 10)
char in[10] = "IN";
res.push_back(in);
for (int i = 0; i < res.size(); i++)
{
logger->info("res:{}", res[i].c_str());
}
if (rest_in < 10)
{
rest++;
rest_in++;
Document d;
string response;
char uploadUrl[200];
string tenantStrs = "0";
sprintf(uploadUrl, upload_file1_url, dev.c_str(), tenantStrs.c_str());
logger->info("upload url is {}, imagePath is {}", uploadUrl, name2);
logger->info("upload url is {}, imagePath is {}", uploadUrl, name4);
int curlCode = CommonTools::upload_file1(uploadUrl,name2,name3,name4, response);
int curlCode = CommonTools::upload_file1(uploadUrl,name2,name3,name4,res,response);
//logger->info("response is {},curl code is {}", response.c_str(), curlCode);
string rrr= UTF_82ASCII(response);
logger->info("rrr is {}",rrr);
......@@ -3331,14 +3349,46 @@ void save_out_image()
int i = 1;
const char* path = "%s/%s/%s-%d.jpg";
char name[128] = {};
sprintf(name, path, dir.c_str(), time.c_str(), time.c_str(), i++);
cv::imwrite(name, param_in.back);
sprintf(name, path, dir.c_str(), time.c_str(), time.c_str(), i++);
cv::imwrite(name, param_in.frame_out[3].img);
sprintf(name, path, dir.c_str(), time.c_str(), time.c_str(), i++);
cv::imwrite(name, param_in.frame_out[4].img);
char name5[128] = {};
char name6[128] = {};
char name7[128] = {};
vector<string>res1;
string buf1, buf2, buf3;
sprintf(name5, path, dir.c_str(), time.c_str(), time.c_str(), i++);
buf1 = buf1 + time.c_str() + "-" + "1" + ".jpg";
res1.push_back(buf1);
cv::imwrite(name5, param_in.back);
sprintf(name6, path, dir.c_str(), time.c_str(), time.c_str(), i++);
buf2 = buf2 + time.c_str() + "-" + "2"+".jpg";
res1.push_back(buf2);
cv::imwrite(name6, param_in.frame_out[3].img);
sprintf(name7, path, dir.c_str(), time.c_str(), time.c_str(), i++);
buf3 = buf3 + time.c_str() + "-" + "3" + ".jpg";
res1.push_back(buf3);
cv::imwrite(name7, param_in.frame_out[4].img);
string out = "OUT";
res1.push_back(out);
if (rest_out < 10)
{
rest_out++;
Document d;
string response;
char uploadUrl[200];
string tenantStrs = "0";
sprintf(uploadUrl, upload_file1_url, dev.c_str(), tenantStrs.c_str());
logger->info("upload url is {}, imagePath is {}", uploadUrl, name5);
int curlCode = CommonTools::upload_file1(uploadUrl, name5, name6, name7,res1, response);
//logger->info("response is {},curl code is {}", response.c_str(), curlCode);
string rrr = UTF_82ASCII(response);
logger->info("rrr is {}", rrr);
logger->info("response is {}", response.c_str());
if (curlCode != 0) {
logger->info("上传图片失败,退出");
return;
}
}
}
void video_trace_result_callback(const char* data, int len, void* user)
......@@ -3374,8 +3424,8 @@ void video_trace_result_callback(const char* data, int len, void* user)
if (output->status == libvideopipe::MOTION_STATUS_TYPES::MOTION_OUT)
{
logger->info("检测到物品离开"); logger->info("{}", __LINE__);
//thread t_(save_out_image);
//t_.detach();
thread t_(save_out_image);
t_.detach();
if (param_in.result_queue.size() < param_in.queue_max)
{
DETECT_RESULT tem = result;
......
No preview for this file type
No preview for this file type
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment