当前位置:网站首页>Opencv learning log 32 edge extraction

Opencv learning log 32 edge extraction

2022-07-06 15:43:00 @Spring sauce

Preface

This article focuses on opencv Application of edge extraction algorithm in image processing .

One 、 Edge extraction

// Fourth question   Edge extraction 
#include <opencv2/opencv.hpp>
#include <iostream>
using namespace cv;
int main()
{
    
	VideoCapture cap;

	cap.open("C://Users//john//Desktop//VID.mp4");
	cv::Size rect;
	rect.width = 5;
	rect.height = 5;
	if (!cap.isOpened())
	{
    
		std::cout << " Cannot open video file " << std::endl;
		return -1;
	}

	double fps = cap.get(CAP_PROP_FPS);
	std::cout << "fps" << fps << std::endl;
	while (1)
	{
    
		cv::Mat frame;
		cv::Mat grayframe;
		cv::Mat resframe;
		cap.read(frame);
		cvtColor(frame, grayframe, CV_RGB2GRAY);
		cv::imshow("grayframe", grayframe);
		Sobel(grayframe, resframe, CV_8UC1,0,1);
		cv::imshow("resframe", resframe);
		waitKey(0);



	}
}

summary

1. The code can run directly , If you don't understand, please leave a message .

原网站

版权声明
本文为[@Spring sauce]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202131317244684.html