-1
我的硬盘包含从2分钟视频中提取的3380帧。如何比较使用opencv存储在文件中的两幅图像
我想分组类似的帧,并从每组一个/两个帧作为代表整个帧组的组头。
我试着用直方图比较也不过直方图只给出了图形表示,
我做的视频汇总
这里是我的代码:
#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。
谢谢你的回答大卫。你可以发送代码进行功能检测,我GOOGLE了它,但无法找到答案。 – TJV 2014-12-02 12:30:03
来自OpenCV网站的教程:http://docs.opencv.org/doc/tutorials/features2d/feature_flann_matcher/feature_flann_matcher.html – DavidGSola 2014-12-02 12:36:00
hello davidgsola我尝试过使用flann进行功能匹配。它给了我相似框架的好结果,但是当我比较不同的框架时,它给了我更多的匹配。这里有输出,我得到了1.对于框架203和245,我得到了45个相似的框架,对于框架204和2045我有213场比赛是不同的帧。基于这个结果它不能分组相似的帧。你能帮我找到解决办法吗? – TJV 2014-12-08 06:48:56