opencv 图像检测导出子图像

本文详细介绍了如何利用OpenCV库在Python中进行图像检测,并将检测到的子图像进行保存。通过实例代码展示了从读取图像、应用检测算法到导出子图像的完整流程。
摘要由CSDN通过智能技术生成
 #include "stdafx.h"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/opencv.hpp"
#include "windows.h"
#include <time.h>
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <io.h>
#include <vector>
#include <fstream>
#include <string>
#include <iostream>
#include<sstream>
using namespace std;
using namespace cv;
#pragma warning(disable:4996)
static Mat src, gray_src,drawImg;
static Mat cutSrc;
//src.copyTo(drawImg);
static int threshold_v = 80;
static int threshold_max = 100;
static char * title = "rectAndRound";
static RNG rng(12345);
int nHeight;  //图像宽
int nWidth;   //图像高
int nBufferDist = 100;//图像中心矩形宽和高
Point photoCenterPoint;//图像中心点坐标
Rect  photoCenterRect; //图像中心矩形
string itos(int i) // 将int 转换成string
{
	stringstream s;
	s << i;
	return s.str();
}
static void m_contours(int, void *);
Mat resizeImag(cv::Mat imgSrc,float scale)
{
	int nHeight = imgSrc.rows*scale;
	int nWidth = imgSrc.cols*scale;
	Size ResImgSize = Size(nWidth, nHeight);
	Mat ResImg = Mat(ResImgSize, imgSrc.type());
	resize(imgSrc, ResImg, ResImgSize, CV_INTER_CUBIC);
	return ResImg;
}
void cutGrayImage(cv::Mat im
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值