資源簡介
基于opencv的車輛檢測代碼,檢測在道路上行駛車流量、車型等

代碼片段和文件信息
#include?“StdAfx.h“
#include?“AVIHandler.h“
#include?
#pragma?comment(lib“vfw32.lib“)
AVIHandler::AVIHandler(void):gray_value(NULL)gray_value_square(NULL)
{
this->loaded?=?FALSE;
}
AVIHandler::AVIHandler(CString?filename):gray_value(NULL)gray_value_square(NULL)
{
this?->loaded?=?FALSE;
LoadVideo(filename);
}
AVIHandler::~AVIHandler(void)
{
if(gray_value?!=?NULL)?free(gray_value);
if(gray_value_square?!=?NULL)?free(gray_value_square);
}
//加載視頻數據
BOOL?AVIHandler::LoadVideo(CString?filename)
{
//讀取AVI文件信息
HRESULT?result;
AVIFileInit();?//使用AVI族函數讀取AVI文件前應首先調用
PAVIFILE?pfile;//AVI文件指針
AVIFILEINFO?pfi;//AVI文件信息
PAVISTREAM?pavi;//AVI流
AVISTREAMINFO?stinfo;//AVI流信息
//CString?file?=?“d:\plane.avi“;
//打開AVI文件
result=AVIFileOpen(&pfilefilenameOF_READNULL);
//AVI文件信息
result=AVIFileInfo(pfile&pfisizeof(AVIFILEINFO));
//獲得AVI視頻流
result=AVIFileGetStream(pfile&pavistreamtypeVIDEO?
0);
//獲得AVI視頻流信息
result=AVIStreamInfo(pavi&stinfosizeof(AVISTREAMINFO));
//獲得AVI包
pgf?=?AVIStreamGetframeOpen(paviNULL);
?
????if?(pgf==NULL)
????{
//數據出錯
return?FALSE;
????}
HRESULT?hr;
//獲得特想的寬和高
int?cx=pfi.dwWidth;//圖象寬、高
int?cy=pfi.dwHeight;
width=cx;
height=cy;
length=pfi.dwLength;
//使用默認長度,只處理100幀
//length=50;
//AVI楨格式,位圖Header位圖具體格式。
lpbm?=?(LPBITMAPINFOHEADER)AVIStreamGetframe(pgf1);
defaultPad=3;
//分配緩沖內存空間
//非填充緩沖
gray_value?=?(unsigned?char*)malloc(sizeof(unsigned?char)*width*height*3);
//填充緩沖
gray_value_square?=?(unsigned?char*)malloc(sizeof(unsigned?char)*(width+defaultPad)*(height+defaultPad)*3);
this->loaded?=?TRUE;
return?TRUE;
}
//獲得一個frame
unsigned?char*?AVIHandler::GetSingleframe(int?i)
{
return?(unsigned?char*)AVIStreamGetframe(pgfi)+40;
//return?NULL;
}
int?AVIHandler::GetframeCount(void)
{
return?this->length;
}
int?AVIHandler::GetframeWidth(void)
{
return?this->width;
//return?0;
}
int?AVIHandler::GetframeHeight(void)
{
return?this->height;
//return?0;
}
//返回圖像的BMP格式數據
LPBITMAPINFOHEADER?AVIHandler::GetLPBM(void)
{
return?this->lpbm;
}
BOOL?AVIHandler::isLoaded(void)
{
return?this->loaded;
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????29184??2008-06-27?13:46??shipin\視頻圖像運動目標檢測演示說明.doc
?????文件???????2380??2008-04-07?19:06??shipin\Video?Demo\AVIHandler.cpp
?????文件????????844??2008-04-07?19:06??shipin\Video?Demo\AVIHandler.h
?????文件???????3159??2008-06-10?17:59??shipin\Video?Demo\ChafenMul.cpp
?????文件????????559??2008-06-07?10:53??shipin\Video?Demo\ChafenMul.h
?????文件???????1805??2007-10-10?17:46??shipin\Video?Demo\ColorTrans.cpp
?????文件????????572??2007-06-08?17:04??shipin\Video?Demo\colortrans.h
?????文件???????2236??2008-04-14?15:23??shipin\Video?Demo\DataManager.cpp
?????文件???????1261??2008-06-07?10:37??shipin\Video?Demo\DataManager.h
?????文件???????4476??2007-12-06?14:24??shipin\Video?Demo\Dbl
?????文件???????1135??2007-12-05?08:23??shipin\Video?Demo\Dbl
?????文件????????106??2008-04-06?13:16??shipin\Video?Demo\Global_Define.h
?????文件??????17947??2008-06-11?17:24??shipin\Video?Demo\GravityCenter.cpp
?????文件???????2679??2008-06-11?17:33??shipin\Video?Demo\GravityCenter.h
?????文件???????1168??2008-06-11?17:18??shipin\Video?Demo\GravityTrack.cpp
?????文件????????319??2008-06-11?17:17??shipin\Video?Demo\GravityTrack.h
?????文件??????15530??2008-06-11?17:36??shipin\Video?Demo\MainFrm.cpp
?????文件???????1711??2008-06-11?09:43??shipin\Video?Demo\MainFrm.h
?????文件???????7169??2008-06-07?12:06??shipin\Video?Demo\MeanShiftSegger.cpp
?????文件???????1292??2008-06-07?11:41??shipin\Video?Demo\MeanShiftSegger.h
?????文件????????348??2007-05-15?13:28??shipin\Video?Demo\MediaSource.h
?????文件???????1366??2008-06-11?17:41??shipin\Video?Demo\MotionDetectDiag.cpp
?????文件???????1248??2008-06-11?17:41??shipin\Video?Demo\MotionDetectDiag.h
?????文件???????1067??2008-06-10?17:23??shipin\Video?Demo\POSDiag.cpp
?????文件???????1221??2008-06-07?11:29??shipin\Video?Demo\POSDiag.h
?????文件???????4400??2008-06-07?02:30??shipin\Video?Demo\ReadMe.txt
?????文件???????1106??2008-06-07?12:23??shipin\Video?Demo\resource.h
?????文件??????12300??2008-06-11?17:30??shipin\Video?Demo\StaticDetect.cpp
?????文件???????2337??2008-06-11?17:40??shipin\Video?Demo\StaticDetect.h
?????文件????????212??2008-06-07?02:30??shipin\Video?Demo\StdAfx.cpp
............此處省略68個文件信息
評論
共有 條評論