一、代码:
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <cv.h>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace cv;
int numFrames;//记录视频的总帧数
int fps;//记录视频的每秒的帧数
int frameW;//视频的宽度
int frameH;//视频的高度
//将图片sobel化然后保存
int ImagetoSobel(IplImage* img,char image_name[20]){
Mat src(img,0), src_gray;
Mat grad;
char* window_name = "Sobel Demo - Simple Edge Detector";
int scale = 1;
int delta = 0;
int ddepth = CV_16S;
if( !src.data ){ return -1; }
GaussianBlur( src, src, Size(3,3), 0, 0, BORDER_DEFAULT );
/// 转换为灰度图
cvtColor( src, src_gray, CV_RGB2GRAY );
/// 创建显示窗口
namedWindow( window_name, CV_WINDOW_AUTOSIZE );
/// 创建 grad_x 和 grad_y 矩阵
Mat grad_x, grad_y;
Mat abs_grad_