|
@@ -10,14 +10,13 @@
|
|
|
#include "video_similarity.h"
|
|
|
|
|
|
|
|
|
-
|
|
|
const int MAX_STACK_FRAMES = 128;
|
|
|
|
|
|
void sig_crash(int sig) {
|
|
|
- printf("crash---->sig=%d \n",sig);
|
|
|
+ printf("crash---->sig=%d \n", sig);
|
|
|
FILE *fd;
|
|
|
struct stat buf;
|
|
|
- const char * crash_path = "./video_similarity_comparison_crash.txt";
|
|
|
+ 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");
|
|
@@ -41,7 +40,7 @@ void sig_crash(int sig) {
|
|
|
now->tm_min,
|
|
|
now->tm_sec,
|
|
|
sig);
|
|
|
- printf("crash---->%s \n",szLine);
|
|
|
+ printf("crash---->%s \n", szLine);
|
|
|
fwrite(szLine, 1, strlen(szLine), fd);
|
|
|
#ifdef __linux
|
|
|
void* array[MAX_STACK_FRAMES];
|
|
@@ -75,7 +74,7 @@ void sig_crash(int sig) {
|
|
|
}
|
|
|
free(strings);
|
|
|
#endif // __linux
|
|
|
- }catch (...) {
|
|
|
+ } catch (...) {
|
|
|
//
|
|
|
}
|
|
|
signal(sig, SIG_DFL);
|
|
@@ -132,10 +131,9 @@ int video_similarity_detection_start(long id, int force_keyframe,
|
|
|
int len = 0;
|
|
|
if (ctx->log) fprintf(ctx->log, "fingerprintFromFFAVFrame 1\n");
|
|
|
// const char *image_hash = fingerprintFromFFAVFrame(ctx->log, video_frame, &len);
|
|
|
- char image_hash[64];
|
|
|
+ char image_hash[64] = {0};
|
|
|
if (1) {
|
|
|
- memset((void *)image_hash, 0,sizeof(char) * 8 * 8);
|
|
|
- for (int i = 0; i <64 ; ++i) {
|
|
|
+ for (int i = 0; i < 64; ++i) {
|
|
|
image_hash[i] = 1;
|
|
|
}
|
|
|
len = 64;
|
|
@@ -149,18 +147,19 @@ int video_similarity_detection_start(long id, int force_keyframe,
|
|
|
model->img_len = len;
|
|
|
|
|
|
if (len > 0) {
|
|
|
-// model->image_hash = static_cast<const char *>(malloc(sizeof(char) * len+1));
|
|
|
-// memset((void*)model->image_hash,'\0',sizeof(char) * len+1);
|
|
|
-// string append_array;
|
|
|
-// for (int i = 0; i < len; ++i) {
|
|
|
-// char c = image_hash[i];
|
|
|
-// if (c == 0) {
|
|
|
-// append_array.append("0");
|
|
|
-// } else if (c == 1) {
|
|
|
-// append_array.append("1");
|
|
|
-// }
|
|
|
-// }
|
|
|
- strcpy((char *)model->image_hash,image_hash);
|
|
|
+ model->image_hash = static_cast<char *>(malloc(sizeof(char) * len+1));
|
|
|
+ memset((void *) model->image_hash, '\0', sizeof(char) * len+1);
|
|
|
+ string append_array;
|
|
|
+ for (int i = 0; i < len; ++i) {
|
|
|
+ char c = image_hash[i];
|
|
|
+ if (c == 0) {
|
|
|
+ append_array.append("0");
|
|
|
+ } else if (c == 1) {
|
|
|
+ append_array.append("1");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ append_array.append("\0");
|
|
|
+ memcpy((char*)model->image_hash, append_array.c_str(), strlen(append_array.c_str()));
|
|
|
}
|
|
|
if (video_frame->pts >= endTimeMs && (*lists).size() > 1 && index + 1 < (*lists).size()) {
|
|
|
index++;
|
|
@@ -169,7 +168,6 @@ int video_similarity_detection_start(long id, int force_keyframe,
|
|
|
model->pts = video_frame->pts;
|
|
|
// LOGE("push pts >>>>= %lld \n", model->pts);
|
|
|
(*lists)[index]->hashs.push_back(model);
|
|
|
- image_hash = NULL;
|
|
|
if (ctx->log)fprintf(ctx->log, "image_hash \n");
|
|
|
if (ctx->log) fprintf(ctx->log, "av_frame_free\n");
|
|
|
av_frame_free(&video_frame);
|
|
@@ -246,18 +244,19 @@ const char *videoSimilarity2json(VideoSimilarity *videoSimilarity) {
|
|
|
// LOGE("size=%d %d\n", item->hashs.size(), item2->img_len);
|
|
|
}
|
|
|
if (item2->image_hash && item2->img_len > 0) {
|
|
|
- string append_array;
|
|
|
- for (int i = 0; i < item2->img_len; ++i) {
|
|
|
- char c = item2->image_hash[i];
|
|
|
- if (c == 0) {
|
|
|
- append_array.append("0");
|
|
|
- } else if (c == 1) {
|
|
|
- append_array.append("1");
|
|
|
- }
|
|
|
- }
|
|
|
- va["imageHash"] = append_array.c_str();
|
|
|
-// free((void *) item2->image_hash);
|
|
|
-// item2->image_hash = NULL;
|
|
|
+// string append_array;
|
|
|
+// for (int i = 0; i < item2->img_len; ++i) {
|
|
|
+// char c = item2->image_hash[i];
|
|
|
+// if (c == 0) {
|
|
|
+// append_array.append("0");
|
|
|
+// } else if (c == 1) {
|
|
|
+// append_array.append("1");
|
|
|
+// }
|
|
|
+// }
|
|
|
+ va["imageHash"] = item2->image_hash;
|
|
|
+ printf("item2->image_hash address=%p \n",&item2->image_hash);
|
|
|
+ free((void *) item2->image_hash);
|
|
|
+ item2->image_hash = NULL;
|
|
|
}
|
|
|
va["hashSize"] = item2->img_len;
|
|
|
va["pts"] = item2->pts;
|