|
@@ -141,13 +141,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));
|
|
|
- memset((void*)model->image_hash,'\0',sizeof(char) * len);
|
|
|
- strcpy((char *)model->image_hash,image_hash);
|
|
|
- if (image_hash)
|
|
|
- free((void *) image_hash);
|
|
|
+ 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,append_array.c_str());
|
|
|
}
|
|
|
-
|
|
|
if (video_frame->pts >= endTimeMs && (*lists).size() > 1 && index + 1 < (*lists).size()) {
|
|
|
index++;
|
|
|
endTimeMs = (*lists)[index]->endTimeMs;
|
|
@@ -155,9 +161,8 @@ 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);
|
|
|
- if (ctx->log)fprintf(ctx->log, "image_hash \n");
|
|
|
-
|
|
|
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);
|
|
|
if (ctx->log) fprintf(ctx->log, "av_frame_free 2\n");
|
|
@@ -233,16 +238,7 @@ 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();
|
|
|
+ va["imageHash"] = item2->image_hash;
|
|
|
free((void *) item2->image_hash);
|
|
|
item2->image_hash = NULL;
|
|
|
}
|