opencv 基于内容的视频关键帧提取(以HSV总量为特征量)

该博客介绍了一种基于OpenCV的内容识别方法,通过计算视频帧的HSV总量来提取关键帧。代码实现中,首先将RGB颜色转换为HSV,然后计算每帧的平均HSV值,通过比较相邻帧的HSV总量差异来判断是否为关键帧。阈值设置为2,用于决定帧间变化是否足够显著。最终,程序展示了提取的关键帧。
摘要由CSDN通过智能技术生成
#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  
	
  • 1
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 6
    评论
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值