Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

Positive and negative image Hog description value problem

I will take HOG descriptors from positive and negative images in my study. Although I don't have trouble getting HOG identifiers from positive images, I'm having trouble getting negative images (the algorithm doesn't see the file). How can I overcome this problem? Note: There are 41 images in both files. Note 2: Both files are in the same location.

import cv2
import glob
import numpy as np
from sklearn.model_selection import cross_val_score
from sklearn.naive_bayes import GaussianNB
from sklearn.externals import joblib
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.svm import LinearSVC
import time


path_positive = "E:\drone_detect\hog_descriptor_conferance\images\positive_images\*.*"
path_negative = "E:\drone_detect\hog_descriptor_conferance\images\negative_images\*.*"

np.set_printoptions(threshold=np.nan)

# For  HoG Keypoints
winSize = (32,32)
blockSize = (16,16)
blockStride = (8,8)
cellSize = (8,8)
nbins = 9
derivAperture = 1
winSigma = 4.
histogramNormType = 0
L2HysThreshold = 2.0000000000000001e-01
gammaCorrection = 0
nlevels = 64
winStride = (8,8)
padding = (8,8)
locations = ((10,20),)
hog = cv2.HOGDescriptor(winSize,blockSize,blockStride,cellSize,nbins,derivAperture,winSigma,
                            histogramNormType,L2HysThreshold,gammaCorrection,nlevels)

count1=0    
data  = open('positive_data.txt', 'w')

car_features=[]

for file in glob.glob(path_positive):
    count1 = count1 +1 
    im = cv2.imread(file)
    hist = hog.compute(im ,winStride,padding,locations)
    # ~ print 'positive image number',count1
    a = np.hstack(hist)
    car_features.append(a)
    data.write(str(a) + '\n' )
data.close()

print(len(hist))
for x in range(41):
    print(car_features[x])
print('-----------------------------------------------------------------------')

count2=0    
data1  = open('negative_data.txt', 'w')

notcar_features=[]

for file in glob.glob(path_negative):
    count2 = count2 +1 
    im1 = cv2.imread(file)
    hist1 = hog.compute(im1 ,winStride,padding,locations)
    # ~ print 'negative image number',count2
    a1 = np.hstack(hist1)
    car_features.append(a1)
    data.write(str(a1) + '\n' )
data1.close()

print(len(hist1))
for x1 in range(41):
    print(car_features[x1])
print('-----------------------------------------------------------------------')

Comments