如何使用 OpenCV 比较存储在文件中的两个图像
how to compare two images stored in a file using opencv
我的硬盘包含从2分钟视频中提取的3380帧。
-
我想对相似的帧进行分组,并且从每个组中将一个/两个帧作为代表整个帧组的组的标题。
-
我也尝试使用直方图比较,但直方图仅提供图形表示,
我正在做视频摘要
这是我的代码:
#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的新手。
您可以使用特征检测对相似图像进行分组。如果你从frame1
和frame2
那里得到足够的matches
,它们应该是相似的。
相关文章:
- 如何使用 OpenCV 解码在两个 UWP 应用之间发送的图像字节?
- SDL GPU 为什么将两个图像分成两个单独的循环更快?
- Qt-grabtoimage()和scale生成两个重叠的图像
- 如何快速创建一组覆盖两个图像的图像
- 有没有办法将两个输入图像堆叠到卤化物发生器中的单个 4 维缓冲区中?
- 如何在OpenCV中减去两个不同尺寸的图像和灰度图像
- 如何使用mingw64 gcc/g 比较两个图像
- OPENCV:如何使用5点算法从来自不同相机的两个图像之间的特征匹配来计算必需矩阵
- 如何比较QT中的两个RGB图像
- 如何在ROS中很好地订阅两个主题(图像和边界框分开发布)
- 在计算机视觉中减去两个图像
- ITK - 如何合并两个图像
- 从两个图像转换的OpenCV
- 使用条款 使用Opencv和Qt减去两个灰度图像
- 如何以相同的比例转换两个视觉上相似的图像
- 将两个图像附加到 FBO 以进行 MRT 渲染
- 如何区分具有对象坐标的两个图像
- 如何在OpenGL中将两个不同的图像渲染为两个不同图元?2D纹理阵列
- OpenCV Mahalanobis函数,用于计算两个图像之间的距离
- 将两个图像堆栈的非电源加载到 3D 纹理 OpenGL C++