opencv教程(五)c++

这篇博客主要介绍了如何使用OpenCV库在C++环境中进行行驶车辆的识别。内容涵盖Blob检测技术的应用,通过解析`Blob.h`和`main.cpp`文件来实现车辆检测。
摘要由CSDN通过智能技术生成

opencv教程(五)行驶车辆识别c++

Blob.h

#ifndef BLOB_H  //先测试BLOB_H是否被宏定义过
#define BLOB_H   //如果x没有被宏定义过,定义x,并编译程序段

#include<opencv2/core/core.hpp>
#include<opencv2/imgproc/imgproc.hpp>
#include<opencv2/highgui/highgui.hpp>
using namespace cv;
using namespace std;
class Blob{
public:
    vector<Point> currentContour;
    Rect  currentBoundingRect;
    double dblCurrentDiagonalSize;
    double dblCurrentAspectRatio;
    bool blnStillBeingTracked;

    Blob(vector<Point> contour);

};

#endif
Blob::Blob(vector<Point> contour){
    currentContour = contour;
    //boundingRect()方法计算点集的边界矩阵
    currentBoundingRect = cv::boundingRect(currentContour);
    dblCurrentAspectRatio = (float)currentBoundingRect.width / (float)currentBoundingRect.height;
    dblCurrentDiagonalSize = sqrt(pow(currentBoundingRect.width, 2) + pow(currentBoundingRect.height, 2));
    blnStillBeingTracked = true;
}

main.cpp

#include "blob.h"
  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值