Closed fatalfeel closed 2 years ago
here i make some test for pca~~~ when add pca speed up 2.5~3 times https://github.com/fatalfeel/hog_pca_svm_detection
I do this version for cpp detect 21 fps in old cpu 2012 i7-3770k https://github.com/fatalfeel/hog_pca_svm_slider_nms_cpp
Warning: this issue has been inactive for 35 days and will be automatically closed on 2022-05-17 if there is no further activity.
If you are waiting for a response but haven't received one it's possible your question is somehow inappropriate. E.g. it is off topic, you didn't follow the issue submission instructions, or your question is easily answerable by reading the FAQ, dlib's official compilation instructions, dlib's API documentation, or a Google search.
Warning: this issue has been inactive for 42 days and will be automatically closed on 2022-05-17 if there is no further activity.
If you are waiting for a response but haven't received one it's possible your question is somehow inappropriate. E.g. it is off topic, you didn't follow the issue submission instructions, or your question is easily answerable by reading the FAQ, dlib's official compilation instructions, dlib's API documentation, or a Google search.
Notice: this issue has been closed because it has been inactive for 45 days. You may reopen this issue if it has been closed in error.
import glob import numpy as np import time import random import PIL import cv2 from skimage.feature import hog from sklearn import svm from sklearn.decomposition import PCA from sklearn.model_selection import train_test_split
train pos use 96X160H96
if name == 'main': car_paths = glob.glob("./dataset/car_images" + "/*")[:5000] neg_paths = [] pos_images = [] neg_images = []
#########pca enable or disable this section######## pca = PCA(n_components=40) pca.fit(x) x = np.array(pca.fit_transform(x)) #########pca end##########
########################test one picture##################### test_list = [] example_image = np.asarray(PIL.Image.open(car_paths[0])) example_image = cv2.cvtColor(cv2.resize(example_image, (96, 64)), cv2.COLOR_RGB2GRAY) example_image = hog(example_image, orientations=9, pixels_per_cell=(16, 16), cells_per_block=(2, 2)) test_list.append(example_image) x = np.asarray(test_list) x = np.array(pca.transform(x)) decision = svc.predict(x) print(decision)
########################refer to py source and do dlib in c++#################### i found an example here https://books.google.com.tw/books?id=ozDnDwAAQBAJ&pg=PA187&lpg=PA187&dq=dlib::vector_normalizer_pca+train&source=bl&ots=4jnTiSl1Mj&sig=ACfU3U23Tm922fkpJNu49oBpjzgZvr6R7w&hl=zh-TW&sa=X&ved=2ahUKEwjUy7G9pd72AhWgsFYBHeNCAMIQ6AF6BAgSEAM#v=onepage&q=dlib%3A%3Avector_normalizer_pca%20train&f=false
fhog_ex.cpp extract_fhog_features(img, hog, sbin);
svm_c_ex.cpp svm_c_trainer trainer;
pca example: https://github.com/PacktPublishing/Hands-On-Machine-Learning-with-CPP/blob/master/Chapter06/dlib/dlib-dr.cc
how to combine hog + pca + svm to detector in dlib c++?