DevYK 3 år sedan
förälder
incheckning
8a485fa21c
2 ändrade filer med 12 tillägg och 3 borttagningar
  1. 11 2
      src/opencv/image_fingerprint.cpp
  2. 1 1
      src/utils/video_similarity.cpp

+ 11 - 2
src/opencv/image_fingerprint.cpp

@@ -44,13 +44,22 @@ int fingerprintFromFFAVFrame(FILE *file, AVFrame *frame, char buf[64]) {
 
     int width = frame->width;
     int height = frame->height;
+    printf("fingerprintFromFFAVFrame -1\n");
     cv::Mat img(height, width, CV_8UC3);
+    printf("fingerprintFromFFAVFrame -2\n");
     int cvLinesizes[1];
     cvLinesizes[0] = img.step1();
+    printf("fingerprintFromFFAVFrame -3\n");
     SwsContext *conversion = sws_getContext(width, height, (AVPixelFormat) frame->format, width, height,
                                             AVPixelFormat::AV_PIX_FMT_BGR24, SWS_FAST_BILINEAR, NULL, NULL, NULL);
-    sws_scale(conversion, frame->data, frame->linesize, 0, height, &img.data, cvLinesizes);
-    sws_freeContext(conversion);
+    if (conversion){
+        sws_scale(conversion, frame->data, frame->linesize, 0, height, &img.data, cvLinesizes);
+        sws_freeContext(conversion);
+    } else {
+        printf("sws_getContext init error .");
+        return NULL;
+    }
+    printf("fingerprintFromFFAVFrame -4\n");
     if (img.empty()) {
         printf("image is empty.");
         return NULL;

+ 1 - 1
src/utils/video_similarity.cpp

@@ -134,6 +134,7 @@ int video_similarity_detection_start(long id, int force_keyframe,
         char image_hash[64] = {0};
         len = fingerprintFromFFAVFrame(ctx->log, video_frame, image_hash);
         if (ctx->log) fprintf(ctx->log, "fingerprintFromFFAVFrame exit \n");
+        printf("fingerprintFromFFAVFrame exit \n");
         if (len > 64) {
             LOGE("size=%d \n", len);
         }
@@ -288,7 +289,6 @@ const char *get_video_similarity_list(const char *inputjson) {
     signal(SIGABRT, sig_crash);
     signal(SIGSEGV, sig_crash);
     if (!inputjson)return NULL;
-//    free((void*)inputjson);
     printf("get_video_similarity_list=%s \n", inputjson);
     auto *vs = json2VideoSimilarity(inputjson);
     if (!vs)return NULL;