-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