资源简介
利用opencv开发的车道检测和车辆识别代码。包含源代码、目的代码、演示视频。
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using OpenCvSharp;
namespace LaneDetection
{
class Program
{
[STAThread]
static void Main()
{
CvCapture cap = CvCapture.FromFile(“road.avi“);
CvWindow w = new CvWindow(“Lane Detection“);
IplImage src gray dstCanny halfframe smallImg;
CvMemStorage storage = new CvMemStorage();
CvSeq lines;
CvHaarClassifierCascade cascade = CvHaarClassifierCascade.FromFile(“haarcascade_cars3.xml“);
const double Scale = 2.0;
const double ScaleFactor = 1.05;
const int MinNeighbors = 2;
CvSeq cars;
while (CvWindow.WaitKey(10) < 0)
{
src = cap.Queryframe();
halfframe = new IplImage(new CvSize(src.Size.Width / 2 src.Size.Height / 2) BitDepth.U8 3);
Cv.PyrDown(src halfframe CvFilter.Gaussian5x5);
gray = new IplImage(src.Size BitDepth.U8 1);
dstCanny = new IplImage(src.Size BitDepth.U8 1);
smallImg = new IplImage(new CvSize(Cv.Round(src.Width / Scale) Cv.Round(src.Height / Scale)) BitDepth.U8 1);
using (IplImage grey = new IplImage(src.Size BitDepth.U8 1))
{
Cv.CvtColor(src grey ColorConversion.BgrToGray);
Cv.Resize(grey smallImg Interpolation.Linear);
Cv.EqualizeHist(smallImg smallImg);
}
storage.Clear();
cars = Cv.HaarDetectobjects(smallImg cascade storage ScaleFactor MinNeighbors HaarDetectionType.DoCannyPruning new CvSize(30 30));
for (int i = 0; i < cars.Total; i++)
{
CvRect r = cars[i].Value.Rect;
CvPoint center = new CvPoint
{
X = Cv.Round((r.X + r.Width * 0.5) * Scale)
Y = Cv.Round((r.Y + r.Height * 0.5) * Scale)
};
int radius = Cv.Round((r.Width + r.Height) * 0.25 * Scale);
src.Circle(center radius CvColor.Blue 2 LineType.AntiAlias 0);
}
// Crop off top half of image since we‘re only interested in the lower portion of the video
int halfWidth = src.Width / 2;
int halfHeight = src.Height / 2;
int startX = halfWidth - (halfWidth / 2);
src.SetROI(new CvRect(0 halfHeight - 0 src.Width - 1 src.Height - 1));
gray.SetROI(src.GetROI());
dstCanny.SetROI(src.GetROI());
src.CvtColor(gray ColorConversion.BgrToGray);
Cv.Smooth(gray gray SmoothType.Gaussian 5 5);
Cv.Canny(gra
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 144 2010-11-14 11:46 LaneDetection\LaneDetection\app.config
文件 118803 2013-05-11 08:40 LaneDetection\LaneDetection\bin\Debug\haarcascade_cars3.xm
文件 7680 2013-05-13 20:24 LaneDetection\LaneDetection\bin\Debug\LaneDetection.exe
文件 144 2010-11-14 11:46 LaneDetection\LaneDetection\bin\Debug\LaneDetection.exe.config
文件 13824 2013-05-13 20:24 LaneDetection\LaneDetection\bin\Debug\LaneDetection.pdb
文件 11600 2013-05-13 20:24 LaneDetection\LaneDetection\bin\Debug\LaneDetection.vshost.exe
文件 144 2010-11-14 11:46 LaneDetection\LaneDetection\bin\Debug\LaneDetection.vshost.exe.config
文件 470016 2012-05-19 09:21 LaneDetection\LaneDetection\bin\Debug\OpenCvSharp.dll
文件 348160 2012-05-19 09:21 LaneDetection\LaneDetection\bin\Debug\OpenCvSharpExtern.dll
文件 751616 2011-10-29 22:28 LaneDetection\LaneDetection\bin\Debug\opencv_calib3d231.dll
文件 531968 2011-10-29 22:28 LaneDetection\LaneDetection\bin\Debug\opencv_contrib231.dll
文件 1739776 2011-10-29 22:28 LaneDetection\LaneDetection\bin\Debug\opencv_core231.dll
文件 895488 2011-10-29 22:28 LaneDetection\LaneDetection\bin\Debug\opencv_features2d231.dll
文件 7417192 2011-10-29 22:28 LaneDetection\LaneDetection\bin\Debug\opencv_ffmpeg.dll
文件 391680 2011-10-29 22:28 LaneDetection\LaneDetection\bin\Debug\opencv_flann231.dll
文件 909824 2011-10-29 22:28 LaneDetection\LaneDetection\bin\Debug\opencv_highgui231.dll
文件 1672192 2011-10-29 22:28 LaneDetection\LaneDetection\bin\Debug\opencv_imgproc231.dll
文件 540672 2011-10-29 22:28 LaneDetection\LaneDetection\bin\Debug\opencv_objdetect231.dll
文件 295936 2011-10-29 22:28 LaneDetection\LaneDetection\bin\Debug\opencv_video231.dll
文件 13640312 2013-05-11 08:40 LaneDetection\LaneDetection\bin\Debug\road.avi
文件 142552 2011-10-20 18:52 LaneDetection\LaneDetection\bin\Debug\tbb.dll
文件 3200 2013-05-13 20:22 LaneDetection\LaneDetection\LaneDetection.csproj
文件 143 2010-11-14 11:44 LaneDetection\LaneDetection\LaneDetection.csproj.user
文件 4018 2013-05-13 20:21 LaneDetection\LaneDetection\Program.cs
文件 1488 2013-05-13 20:20 LaneDetection\LaneDetection\Properties\AssemblyInfo.cs
文件 885 2013-05-13 20:17 LaneDetection\LaneDetection.sln
目录 0 2013-05-13 20:25 LaneDetection\LaneDetection\obj\x86\Debug
目录 0 2013-05-13 20:25 LaneDetection\LaneDetection\obj\x86\Release
目录 0 2013-05-13 20:24 LaneDetection\LaneDetection\bin\Debug
目录 0 2013-05-13 20:20 LaneDetection\LaneDetection\bin\Release
............此处省略9个文件信息
相关资源
- opencv立体匹配算法BM+SGBM+VAR运行官方立
- 电脑网站支付快捷下单-微信
- 电脑网站支付快捷下单-支付宝
- 基于opencv的手写数字字符识别
- opencv数字识别更新
- OpenCV 2.4.3编译生成的libdllinclude文件
- .net商品销售管理系统完整源码(进销
- .net经典会员管理项目完整源码(包含
- LearningOpenCV_Code.rar
- 学生预警管理系统
- Unity-JumpJump-master.zip
- qt+opencv+人脸识别
- 《学习opencv中文版》于仕琪著 电子版
- 基于OpenCV的图像识别及跟踪程序
- 2017新版focas.zip
- 篮球网站设计开发
- opencv 2.4.10_vs2008_x86库
- opencv1.0Windows安装版
- opencv 3.4.0 安装需要的东西
- opencv4.2需要的文件.rar
- .net文件上传功能实现demo
- OpenCV资料
- opencv3.3需要的ippicv_2017u2_mac_intel64_20
- ippicv_2017u3_win_intel64_general_20180518.zip
- 2076个opencv分类器苹果样本及解释文件
- opencv+svm实现图像分类代码+训练图片
- cmake好的opencv
- opencv一维码识别
- opencv3_contrib_cmake_files
- 最小二乘法求圆心和半径
评论
共有 条评论