//---------------------------------【头文件、命名空间包含部分】----------------------------
// 描述:包含程序所使用的头文件和命名空间
//------------------------------------------------------------------------------------------------
#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
opencv提取目标质心
最新推荐文章于 2024-05-15 20:13:21 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)