opencv提取目标质心

本文介绍了使用OpenCV库在实际应用中如何提取目标质心,并详细探讨了minAreaRect函数在计算旋转矩形中心时的效果。通过对图像处理的理解,揭示了质心与旋转矩形中心在目标检测中的重要性。
摘要由CSDN通过智能技术生成
//---------------------------------【头文件、命名空间包含部分】----------------------------
//		描述:包含程序所使用的头文件和命名空间
//------------------------------------------------------------------------------------------------
#include <opencv2/opencv.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include<iostream>
using namespace cv;
using namespace std;


//-----------------------------------【main( )函数】------------------------------------------
//		描述:控制台应用程序的入口函数,我们的程序从这里开始
//-----------------------------------------------------------------------------------------------

int g_nMedianBlurValue=2;
Mat element = getStructuringElement(MORPH_RECT, Size(3, 3));
vector<Point> point_seq;

Mat selectChannel(Mat src, int channel);
bool objectDetection(Mat  src, int threshold_vlaue, int areasize, int channel)
{/*
  @param[out] success or fail.
  @param[in]  threshold  threshold for segmentation.
  @param[in]  areasize   threshold for selecting large-enough object.
  @param[in]  channel 1(B), 2(G), 3(R), 4(H), 5(S), 6(V), other(GRAY)  
  */
	int i;
	//cvCopy(src,displayImage,NULL);
	Mat displayImage=src.clone();
    //cvClearSeq(point_seq);
	//cvClearSeq(contour);
	//cvClearMemStorage(storage);

	Mat imageSC=selectChannel(src,channel);
	//smooth(imageSC,imageSC,CV_MEDIAN);//图像中值滤波
	medianBlur( imageSC, imageSC, g_nMedianBlurValue*2+1 );//中值滤波
	//cvAd
  • 15
    点赞
  • 84
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值