行人檢測OpenCV ICF

2021-08-14 03:54:16 字數 2648 閱讀 2912

最近專案中需要用到行人檢測,對比了幾種常用的演算法後,果斷選擇出自大神piotr dollar的icf(integral channel features)。

下面開始了苦逼之旅。。。。

由於從網上down的**都是matlab版的,如果翻譯成c++的話,勞民傷財。以前就聽說opencv_contrib裡整合了該演算法,但不知道效果如何,還是本著對大神的敬仰,重新編譯了整合擴充套件功能的opencv3.0。

萬事俱備,開始幹活!(看完xobjdetect.hpp後,就覺得這裡面的坑不是一般的多,很多關鍵的引數都木有注釋!!!)

準備訓練樣本是件枯燥的事,但很重要。icf的訓練對樣本沒有特別的要求:正樣本需要歸一化(推薦64*128),彩圖;負樣本不需要歸一化。準備好之後,生成檔案列表pos_list,txt和neg_list.txt。

直接貼**吧

#include "opencv2\opencv.hpp"

#include "opencv2\xobjdetect.hpp"

#include

#include

using

namespace cv;

using

namespace

std;

using

namespace xobjdetect;

bool resize_img(string posfile, string negfile)

while (getline(fin_p,p_sample))

fin_p.close();

return

true;

}bool train_model(string posfile, string negfile,string model_name)

while (getline(fin_p, p_sample))

fin_p.close();

fstream fin_n(negfile.c_str());

string n_sample;

if (!fin_n)

while (getline(fin_n, n_sample))

fin_n.close();

icfdetector hh_icfdetector;

icfdetectorparams icf_params;

icf_params.alpha = 0.15f;

icf_params.bg_per_image = 5;

icf_params.feature_count = 15000;

icf_params.weak_count = 200;

icf_params.features_type = "icf";

icf_params.is_grayscale = false;

icf_params.model_n_cols = 56; //model尺寸?訓練過程中歸一化的尺寸

icf_params.model_n_rows = 70;

icf_params.use_fast_log = false;

hh_icfdetector.train(vposfile, vnegfile, icf_params);

//filestorage fs;

//xobjdetect::write(fs, model_name, hh_icfdetector);

filestorage fs(model_name, filestorage::write);

hh_icfdetector.write(fs);

fs.release();

return

true;

}bool test_model(string modelfile)

filenode model = fs["model"];

icfdetector hh_icfdetector;

hh_icfdetector.read(model);

fs.release();

mat image = imread("test.png", 1);

vector

vr;vector

ftrs;

hh_icfdetector.detect(image, vr, 1.1, size(30, 50), size(300, 500), 1, 1, ftrs);

//hh_icfdetector.detect(image, vr, 1, 4, 1.2, 0, 5, ftrs);

for (int i = 0; i < vr.size();i++)

namedwindow("result", cv_window_normal);

imshow("result", image);

waitkey(0);

return

true;

}void main()

測試

測試結果

效果是非常的渣,並且檢測速度不盡人意。折騰了兩天,有些失望。。。。

後面繼續關注這個演算法,萬一效果很讚呢

PCL行人檢測

首先我們知道hog特徵結合svm分類器已經被廣泛應用於影象識別中,尤其在行人檢測中獲得了極大的成功 hog svm進行行人檢測的方法是法國研究人員dalal在2005的cvpr上提出的,而如今雖然有很多行人檢測演算法不斷提出,但基本都是以hog svm的思路為主,那麼pcl中也是利用這一思想來進行行...

行人檢測 HOG運算元

梯度直方圖特徵 hog 是一種對影象區域性重疊區域的密集型描述符 它通過計算區域性區域的梯度方向直方圖來構成特徵。hog特徵結合 svm分類器已經被廣泛應用於影象識別中,尤其在行人檢測中獲得了極大的成功。需要提醒的是,hog svm 進行行人檢測的方法是法國研究人員 dalal 在2005 的cvp...

HOG演算法 行人檢測

hog histogram of oriented gridients 是2005年提出描述行人特徵的演算法,在當年取得了突破性的進展,處理在行人檢測領域,在其他識別方面hog也取得了不錯的效果。hog通過計算和統計影象區域性區域的梯度方向直方圖來形成描述特徵 在一張影象中,人與外界存在乙個邊緣,通...