资源简介
积分最低,车标检测,检测轮廓出来,粗定位和精定位提取车标,基于vs2013+opencv的方法
代码片段和文件信息
#include “cv.h“
#include “highgui.h“
#include
#include
#include
using namespace std;
using namespace cv;
Mat src;
Mat src_gray;
int thresh = 100;
int max_thresh = 255;
RNG rng(12345);
void thresh_callback(int void*);
int main(int argc char** argv)
{
src = imread(“1.jpg“ 1);
cvtColor(src src_gray CV_BGR2GRAY);
blur(src_gray src_gray Size(3 3));
char* source_window = “Source“;
namedWindow(source_window CV_WINDOW_AUTOSIZE);
imshow(source_window src);
createTrackbar(“Threshold:“ “Source“ &thresh max_thresh thresh_callback);
thresh_callback(0 0);
waitKey(0);
return 0;
}
void thresh_callback(int void*)
{
Mat threshold_output;
vector> contours;
vector hierarchy;
//Canny(src_gray canny_Mat thresh thresh * 2 3);
/// 使用Threshold检测边缘
threshold(src_gray threshold_output thresh 255 THRESH_BINARY);
findContours(threshold_output contours hierarchyCV_RETR_TREECV_CHAIN_APPROX_SIMPLE Point(0 0));
/// 多边形逼近轮廓 + 获取矩形和圆形边界框
vector>contours_poly(contours.size());
vector bondRect(contours.size());
vectorcenter(contours.size());
vectorradius(contours.size());
vector>::iterator iter = contours.begin();
for (int i = 0; i < contours.size(); i++)
{
approxPolyDP(Mat(contours[i]) contours_poly[i] 3 true);
bondRect[i] = boundingRect(Mat(contours[i]));
minEnclosingCircle(contours[i] center[i] radius[i]);
}
/// 画多边形轮廓 + 包围的矩形框 + 圆形框
Mat drawing = Mat::zeros(threshold_output.size() CV_8UC3);
for (int i = 0; i < contours.size(); i++)
{
Scalar color = Scalar(rng.uniform(0 255) rng.uniform(0 255) rng.uniform(0 255));
drawContours(src contours i color 1 8 hierarchy 0 Point());
drawContours(drawing contours_poly i color 1 8 vector() 0 Point());
if (bondRect[i].area() > 50 && bondRect[i].width < 50 && bondRect[i].height < 50)
{
rectangle(drawing bondRect[i].tl() bondRect[i].br() color 2 8 0);
// circle(drawing center[i] (int)radius[i] color 2 8 0);
}
}
namedWindow(“contours“ CV_WINDOW_AUTOSIZE);
imshow(“contours“ drawing);
namedWindow(“contours_src“ CV_WINDOW_AUTOSIZE);
imshow(“contours_src“ src);
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 2421 2018-05-09 21:00 vehicle detecting.cpp
- 上一篇:西门子plc三层电梯梯形图
- 下一篇:labview的电池管理系统
相关资源
- opencv分类器.rar
- v4l2 qt实时显示摄像头数据未使用ope
- QT+opencv边缘检测,轮廓提取及轮廓跟
- QT+opencv图像增强,包括高斯平滑,中
- OpenCV人脸识别包含数据集的txt文件
- opencv团块跟踪 blobtracking
- opencv中cvHoughCircle同心圆检测完整程序
- unity3d插件-脚本-图像识别OpenCVforUnit
- opencv+vs2017实现图象去雾
- opencv-3.2.0-vc14 安装包
- opencv图像细化代码
- Improved adaptive Gausian mixture model for ba
- 使用Hu矩进行形状匹配
- Linux下的QT车牌识别门禁系统基于ope
- 读取并可视化DICOM图像VTK & OpenCV
- opencv中关于高斯建模的参考论文英文
- Learning Opencv 课后习题答案2-5
- OpenCV中cvvImage的头文件和源代码
- opencv与qt结合使用的(亲测可用)
- Opencv2链接CUDA9.0中cmake修改版
- opencv处理图像8*8分块DCT变换和量化
- opencv 人头统计
- opencv灰度图像和二维数组相互转换操
- zedboard移植opencv+qt的人脸检测
- opencv实现图像灰度化和二值化
- NCVPixelOperations.hpp
- CVUI配合Opencv书写界面神器
- 基于Chan-Vese模型图像分割算法代码
- openCV中grabcut图像分割函数使用VS2017
- 基于opencv的三维重建程序
评论
共有 条评论