#include "stdafx.h"
#include
#include "opencv2/core/core.hpp"
#include
#include
using namespace std;
using namespace cv;
void RGBtoHSV(float b,float g,float r,float &h,float &s,float &v)//将RGB值转化为HSV值
{
float max = (((r > b) ? r : b) > g) ? ((r > b) ? r : b) : g ;
float min = (((r > b) ? b : r) > g) ? g : ((r > b) ? b : r);
if (max == min)
{
h = 0; s = 0; v = max / 255;
}
else if (g >= b)
{
h = (max - r + g - min + b - min) / (max - min) * 60;
s = 1 - min / max;
v = max / 255;
}
else if (g < b)
{
h = 360 - (max - r + g - min + b - min) / (max - min) * 60;
s = 1 - min / max;
v = max / 255;
}
}
//以HSV总量作为特征量提取关键帧
int HSV(Mat img)
{
// IplImage * ipl_img = NULL;
// * ipl_img =img;//将Mat类型转化为IplImage
float B, G, R, H=0, S=0, V=0;
int nr = img.rows; // number of rows
int nc = img.cols; // number of cols
float sumH = 0, sumS = 0, sumV = 0;
CvScalar cs;
//将Mat类型转化为IplImage
I
opencv 基于内容的视频关键帧提取(以HSV总量为特征量)
最新推荐文章于 2022-05-07 22:20:17 发布
该博客介绍了一种基于OpenCV的内容识别方法,通过计算视频帧的HSV总量来提取关键帧。代码实现中,首先将RGB颜色转换为HSV,然后计算每帧的平均HSV值,通过比较相邻帧的HSV总量差异来判断是否为关键帧。阈值设置为2,用于决定帧间变化是否足够显著。最终,程序展示了提取的关键帧。

最低0.47元/天 解锁文章
2472

被折叠的 条评论
为什么被折叠?



