運動物體目標檢測實現 基於OpenCV

2021-07-26 22:14:18 字數 1493 閱讀 6308

基於opencv實現的乙個運動目標檢測演算法,可以用來檢測行人,車輛等運動目標。

#include 

#include

#include

#include

int main( int argc, char** argv )

//宣告iplimage指標

iplimage* pframe = null;

iplimage* pfrimg = null;

iplimage* pbkimg = null;

cvmat* pframemat = null;

cvmat* pfrmat = null;

cvmat* pbkmat = null;

cvcapture* pcapture = null;

int nfrmnum = 0;

//建立視窗

cvnamedwindow("video", 1);

cvnamedwindow("background",1);

cvnamedwindow("foreground",1);

//使視窗有序排列

cvmovewindow("video", 30, 0);

cvmovewindow("background", 360, 0);

cvmovewindow("foreground", 690, 0);

argc = 1;

if( argc > 2 )

//開啟攝像頭

if (argc ==1)

if( !(pcapture = cvcapturefromcam(-1)))

if(argc == 2)

if( !(pcapture = cvcapturefromfile(argv[1])))

while(pframe = cvqueryframe( pcapture ))

else

}

//銷毀視窗

cvdestroywindow("video");

cvdestroywindow("background");

cvdestroywindow("foreground");

//釋放影象和矩陣

cvreleaseimage(&pfrimg);

cvreleaseimage(&pbkimg);

cvreleasemat(&pframemat);

cvreleasemat(&pfrmat);

cvreleasemat(&pbkmat);

cvreleasecapture(&pcapture);

return 0;

}

opencv運動物體檢測

參考資料 python opencv實現動態物體追蹤 python opencv實踐 一 基於顏色的物體追蹤 上 在hsv顏色空間識別區域顏色 opencv python tutorials opencv形態學處理 opencvl輪廓檢測函式 樹莓派智慧型小車結合攝像頭,opencv進行物體追蹤 給...

運動物體的檢測 初

最近為了實現運動物體的檢測這一功能,在網路上找了許多材料,但是大都不容易實現或者晦澀難懂,於是決定從基礎入手,先對兩張大小相同但略有差異的兩張進行操作,基本步驟是首先對兩張進行相減操作,把差值圖放在另外一張大小相同的圖上,之後對這張圖進行闕值化操作,然後再尋找輪廓,用矩形圈去輪廓。在建立差圖時找到了...

基於OpenCv的運動物體檢測演算法

基於乙個實現的基於opencv的運動物體檢測演算法,可以用於檢測行人或者其他運動物體。include include include include int main int argc,char argv 開啟攝像頭 if argc 1 if pcapture cvcapturefromcam 1 ...