|
@@ -2,9 +2,6 @@
|
|
|
// Created by 阳坤 on 2022/3/2.
|
|
|
//
|
|
|
|
|
|
-extern "C"{
|
|
|
-#include <libavcodec/avcodec.h>
|
|
|
-}
|
|
|
#include "image_fingerprint.h"
|
|
|
#include "../utils/yuv_convert.h"
|
|
|
|
|
@@ -14,11 +11,10 @@ int avframeToCvmat(cv::Mat &image, const AVFrame *frame) {
|
|
|
int height = frame->height;
|
|
|
int cvLinesizes[1];
|
|
|
cvLinesizes[0] = image.step1();
|
|
|
- int size = avpicture_get_size(AV_PIX_FMT_BGR24, width, height);
|
|
|
+ printf("cvmatToAvframe width=%d height=%d linesize[0]=%d linesize[1]=%d linesize[2]=%d \n",width,height,frame->linesize[0],frame->linesize[1],frame->linesize[2]);
|
|
|
SwsContext *conversion = sws_getContext(width, height, (AVPixelFormat) frame->format, width, height,
|
|
|
AVPixelFormat::AV_PIX_FMT_BGR24, SWS_FAST_BILINEAR, NULL, NULL, NULL);
|
|
|
- if (conversion)
|
|
|
- {
|
|
|
+ if (conversion) {
|
|
|
sws_scale(conversion, frame->data, frame->linesize, 0, height, &image.data, cvLinesizes);
|
|
|
sws_freeContext(conversion);
|
|
|
conversion = NULL;
|
|
@@ -67,7 +63,6 @@ AVFrame *cvmatToAvframe(cv::Mat *image, AVFrame *frame) {
|
|
|
frame = av_frame_alloc();
|
|
|
av_image_alloc(frame->data, frame->linesize, width, height, AVPixelFormat::AV_PIX_FMT_YUV420P, 1);
|
|
|
}
|
|
|
- printf("cvmatToAvframe width=%d height=%d linesize[0]=%d linesize[1]=%d linesize[2]=%d \n",width,height,frame->linesize[0],frame->linesize[1],frame->linesize[2]);
|
|
|
SwsContext *conversion = sws_getContext(width, height, AVPixelFormat::AV_PIX_FMT_BGR24, width, height,
|
|
|
(AVPixelFormat) frame->format, SWS_FAST_BILINEAR, NULL, NULL, NULL);
|
|
|
sws_scale(conversion, &image->data, cvLinesizes, 0, height, frame->data, frame->linesize);
|
|
@@ -87,7 +82,7 @@ int fingerprintFromFFAVFrame(FILE *file, AVFrame *frame, char buf[64]) {
|
|
|
printf("fingerprintFromFFAVFrame -2\n");
|
|
|
int ret = avframeToCvmat(img, frame);
|
|
|
if (ret < 0) {
|
|
|
- printf("sws_getContext init error .");
|
|
|
+ printf("sws_getContext init error .\n");
|
|
|
return -1;
|
|
|
}
|
|
|
printf("fingerprintFromFFAVFrame -6\n");
|