import pickle fname='train_img.png' trImg = cv.imread(fname, cv.IMREAD_GRAYSCALE); ret, bwtrImg=cv.threshold(trImg, 122, 255, cv.THRESH_BINARY_INV) bxs=extractBlobs(bwtrImg, False, True) #bxs.sort() # print(bxs) samples = np.zeros((36, 69)); i=0 print(bxs[0]) for bx in bxs: # print(trImg.shape) cimg = trImg[bx[0]:bx[0]+bx[2],bx[1]:bx[1]+bx[3]]; # print(cimg.shape) clbp = findLBP(cimg); chist = lbpHist(clbp); chist=chist.reshape((1, 69)) # print(chist.shape); samples[i, :]=chist; i+=1 # cv.imshow('img',cimg); # cv.waitKey(0) resp=['9','8','7','6','5','4','3','2','1','0','Z','Y','X','W','V','U','T','S','R','Q','P','O','N','H','F','E','D','B','M','L','K','J','C','A','I','G'] responses=[ord(i) for i in resp] # print(resp) responses=np.asarray(responses) responses=responses.reshape((36,1)) # print(responses) print(responses.shape) print(samples.shape)
import numpy as np from matplotlib import pyplot as plt from findLBP import findLBP from lbpHist import lbpHist from getFVec import clrHist import pickle tImg = cv.imread('image_0040.jpg',cv.IMREAD_GRAYSCALE); img = cv.imread('cars_markus/image_0011.jpg',cv.IMREAD_GRAYSCALE); img=cv.GaussianBlur(img, (3,3), 0) tImg=cv.GaussianBlur(tImg, (3,3), 0) tImg = cv.Sobel(tImg,cv.CV_8U,1,0,ksize=3) img = cv.Sobel(img,cv.CV_8U,1,0,ksize=3) imLbp = findLBP(img); tLbp = findLBP(tImg); h,w = imLbp.shape; tHist=lbpHist(tLbp); tcHist=clrHist(tImg); minDist=100000 bBox=[0,0,0,0]; scaleStp=15; moveStp=10; ratio=(tImg.shape[1]*1.0)/tImg.shape[0] bxs=[] for scaleF in range(1,scaleStp/3):