def initialFraming(self,path):
global cap
global success
global frame
sampleIndex=0
cap = cv2.VideoCapture(path)
success,frame=cap.read(cv.CV_IMWRITE_JPEG_QUALITY)
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
gray = cv2.GaussianBlur(gray, (21, 21), 0)
height,width = gray.shape[:2]
print "Dimension of the image is: ",height, width, (height*width)
samples = np.array([[0 for x in range(0,self.numberOfSamples)] for x in range(0,(height*width))])
tempArray = np.reshape(gray,(height*width)).T
samples[:,sampleIndex]= np.copy(tempArray)
sampleIndex+=1
while (success and sampleIndex!=(self.numberOfSamples)):
success,frame = cap.read(cv.CV_IMWRITE_JPEG_QUALITY)
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
gray = cv2.GaussianBlur(gray, (21, 21), 0)
tempArray = (np.reshape(gray,(height*width))).T
samples[:,sampleIndex]= np.copy(tempArray)
sampleIndex+=1
return samples
评论列表
文章目录