我的硬盘中包含从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
,它们应该就是相似的。