|
@@ -4,87 +4,9 @@
|
|
|
|
|
|
#include <json/reader.h>
|
|
|
#include <json/writer.h>
|
|
|
-#include <sys/stat.h>
|
|
|
-#include <signal.h>
|
|
|
-#include <execinfo.h>
|
|
|
#include "video_similarity.h"
|
|
|
|
|
|
|
|
|
-const int MAX_STACK_FRAMES = 128;
|
|
|
-
|
|
|
-void sig_crash(int sig) {
|
|
|
- printf("crash---->sig=%d \n", sig);
|
|
|
- FILE *fd;
|
|
|
- struct stat buf;
|
|
|
- const char *crash_path = "./video_similarity_comparison_crash.txt";
|
|
|
- stat(crash_path, &buf);
|
|
|
- if (buf.st_size > 10 * 1000 * 1000) { // 超过10兆则清空内容
|
|
|
- fd = fopen(crash_path, "w");
|
|
|
- } else {
|
|
|
- fd = fopen(crash_path, "at");
|
|
|
- }
|
|
|
-
|
|
|
- if (NULL == fd) {
|
|
|
- exit(0);
|
|
|
- }
|
|
|
- try {
|
|
|
- char szLine[512] = {0,};
|
|
|
- time_t t = time(NULL);
|
|
|
- tm *now = localtime(&t);
|
|
|
- int nLen1 = sprintf(szLine,
|
|
|
- "#########################################################\n[%04d-%02d-%02d %02d:%02d:%02d][crash signal number:%d]\n",
|
|
|
- now->tm_year + 1900,
|
|
|
- now->tm_mon + 1,
|
|
|
- now->tm_mday,
|
|
|
- now->tm_hour,
|
|
|
- now->tm_min,
|
|
|
- now->tm_sec,
|
|
|
- sig);
|
|
|
- printf("crash---->%s \n", szLine);
|
|
|
- fwrite(szLine, 1, strlen(szLine), fd);
|
|
|
-#ifdef __linux
|
|
|
- void* array[MAX_STACK_FRAMES];
|
|
|
- size_t size = 0;
|
|
|
- char** strings = NULL;
|
|
|
- size_t i, j;
|
|
|
- signal(sig, SIG_DFL);
|
|
|
- size = backtrace(array, MAX_STACK_FRAMES);
|
|
|
- strings = (char**)backtrace_symbols(array, size);
|
|
|
- //fprintf(stderr, "oncrash;\n");
|
|
|
- for (i = 0; i < size; ++i)
|
|
|
- {
|
|
|
- char szLine[512] = {0, };
|
|
|
- sprintf(szLine, "%d %s\n", i, strings[i]);
|
|
|
- fwrite(szLine, 1, strlen(szLine), fd);
|
|
|
- std::string symbol(strings[i]);
|
|
|
- size_t pos1 = symbol.find_first_of("[");
|
|
|
- size_t pos2 = symbol.find_last_of("]");
|
|
|
- std::string address = symbol.substr(pos1 + 1, pos2 - pos1 -1);
|
|
|
- char cmd[128] = {0, };
|
|
|
- sprintf(cmd, "addr2line -e /home/libpiaoquan_java_opencv.so %s", address.c_str()); // test为应用程序名称,需要改为用户自己的应用程序名
|
|
|
- FILE *fPipe = popen(cmd, "r");
|
|
|
- if(fPipe != NULL){
|
|
|
- char buff[1024];
|
|
|
- memset(buff, 0, sizeof(buff));
|
|
|
- char* ret = fgets(buff, sizeof(buff), fPipe);
|
|
|
- pclose(fPipe);
|
|
|
- fwrite(ret, 1, strlen(ret), fd);
|
|
|
- }
|
|
|
- }
|
|
|
- free(strings);
|
|
|
-#endif // __linux
|
|
|
- } catch (...) {
|
|
|
- //
|
|
|
- }
|
|
|
- printf("sig_crash fflush \n");
|
|
|
- fflush(fd);
|
|
|
- printf("sig_crash fclose \n");
|
|
|
- fclose(fd);
|
|
|
- fd = NULL;
|
|
|
- exit(0);
|
|
|
- printf("sig_crash exit \n");
|
|
|
-}
|
|
|
-
|
|
|
long video_similarity_detection_init(const char *url, VideoSimilarity **vs) {
|
|
|
auto *ctx = (VideoSimilarityContext *) malloc(sizeof(VideoSimilarityContext));
|
|
|
if (!ctx)return -1;
|
|
@@ -290,8 +212,6 @@ const char *videoSimilarity2json(VideoSimilarity *videoSimilarity) {
|
|
|
* @return
|
|
|
*/
|
|
|
const char *get_video_similarity_list(const char *inputjson) {
|
|
|
- signal(SIGABRT, sig_crash);
|
|
|
- signal(SIGSEGV, sig_crash);
|
|
|
if (!inputjson)return NULL;
|
|
|
printf("get_video_similarity_list=%s \n", inputjson);
|
|
|
VideoSimilarity *vs = NULL;
|