使用OpenCV比较存储在文件中的两张图片

我的硬盘中包含从2分钟视频中提取的3380帧。

  1. 我想将相似的帧分组,并从每个组中选出一到两帧作为该组的代表,概括整个组的帧内容。

  2. 我尝试过使用直方图比较,但直方图只能提供图形表示,

我正在进行视频摘要工作

这是我的代码:

#include <stdio.h>#include <iostream>#include <conio.h>#include <opencv2/core/core.hpp>#include <opencv2/highgui/highgui.hpp>#include <opencv2/imgproc/imgproc.hpp>using namespace cv;int main(int argc, char** argv){    // Read a video file from file    CvCapture* capture = cvCaptureFromAVI("C:\\Users\\Pavilion\\Documents\\Visual Studio 2013\\Projects\\video\\optical illusions.avi");    int loop = 0;    IplImage* frame = NULL;    Mat matframe;    Mat img_hsv, img_rgb;    char fname[20];    do    {        // capture frames from video        frame = cvQueryFrame(capture);        matframe = cv::cvarrToMat(frame);        // create a window to show frames        cvNamedWindow("video_frame", CV_WINDOW_AUTOSIZE);        // Display images in a window        cvShowImage("video_frame", frame);        sprintf(fname, "C:\\Users\\Pavilion\\Documents\\Visual Studio 2013\\Projects\\video\\video\\frames\\frame%d.jpg", loop);        // write images to a folder        imwrite(fname, matframe);        // Convert RGB to HSV        cvtColor(img_rgb, img_hsv, CV_RGB2HSV);        loop++;        cvWaitKey(10);    } while (frame != NULL);    return 0;    /*    // read and process frames from file    char name[50];    int i = 0;    Mat output_image;    while (1){    sprintf(name, "frame%d.jpg", i);    //Load the image    Mat input_image = imread(name, 1);    if (!input_image.data) break;    //Image RGB to Grayscale    cvtColor(input_image, output_image, CV_RGB2GRAY);    //Applying Gaussian    GaussianBlur(output_image, output_image, Size(21.0, 21.0), 50.0);    //applying adaptive threshold    adaptiveThreshold(output_image, output_image, 255, ADAPTIVE_THRESH_MEAN_C, THRESH_BINARY_INV, 111, -20);    sprintf(name, "frame%d-bin.jpg", i);    //save the image    imwrite(name, output_image);    i++;    }    */}

有人能帮帮我吗?我是OpenCV的新手。


回答:

你可以使用特征检测来对相似的图像进行分组。如果从frame1frame2中获得足够的matches,它们应该就是相似的。

Related Posts

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注