3C科技 娛樂遊戲 美食旅遊 時尚美妝 親子育兒 生活休閒 金融理財 健康運動 寰宇綜合

Zi 字媒體

2017-07-25T20:27:27+00:00
加入好友
fanfuhan OpenCV 教學101 ~ opencv-101-HOG特徵描述子之多尺度 檢測/定位/標記 資料來源: https://fanfuhan.github.io/ https://fanfuhan.github.io/2019/05/17/opencv-101/ GITHUB:https://github.com/jash-git/fanfuhan_ML_OpenCV HOG(定向梯度直方圖)特徵本身不支持旋轉不變性,通過金字塔可以支持多尺度檢測實現尺度空間不變性,OpenCV中支持HOG描述子多尺度檢測。 C++ #include #include using namespace cv; using namespace std; int main(int argc, char** argv) { Mat src = imread("D:/images/pedestrian_02.png"); if (src.empty()) { printf("could not load image..\n"); return -1; } imshow("input", src); HOGDescriptor *hog = new HOGDescriptor(); hog->setSVMDetector(hog->getDefaultPeopleDetector()); vector objects; hog->detectMultiScale(src, objects, 0.0, Size(4, 4), Size(8, 8), 1.05); for (int i = 0; i < objects.size(); i++) { rectangle(src, objects[i], Scalar(0, 0, 255), 2, 8, 0); } imshow("result", src); waitKey(0); return 0; } Python """ HOG特征描述子之多尺度检测 """ import cv2 as cv src = cv.imread("images/pedestrian.png") hog = cv.HOGDescriptor() hog.setSVMDetector(cv.HOGDescriptor_getDefaultPeopleDetector()) # detect people in image (rects, weights) = hog.detectMultiScale(src, winStride=(4, 4), padding=(8, 8), scale=1.55, useMeanshiftGrouping=False) for (x, y, w, h) in rects: cv.rectangle(src, (x, y), (x + w, y + h), (0, 255, 0), 2) cv.imshow("hog-detector", src) cv.waitKey(0) cv.destroyAllWindows()

本文由jashliaoeuwordpress提供 原文連結

寫了 5860316篇文章,獲得 23313次喜歡
精彩推薦