- (不稳定、受光照影响大)
利用颜色范围过滤
标注与测量 - 基于颜色跟踪实现步骤
①inRange过滤
②形态学操作
③轮廓查找(也可以根据矩检测跟踪)
④外接矩形获取
⑤位置标定
#include <opencv2/opencv.hpp>
#include <iostream>
using namespace cv;
using namespace std;
void detectROI(Mat& mask, Rect& rect);//获取轮廓 与 绘制矩形
Rect rect;
int main(int argc, char** argv)
{
VideoCapture capture;
capture.open("../path.mp4");
if (!capture.isOpened())
{
cout << "could not load video..." << endl;
return -1;
}
Mat frame, gray, mask;
Mat kernel = getStructuringElement(MORPH_RECT, Size(3