camera.capture(stream, "rgb") img=stream.array #Convert to intensity grey = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY) #Remove faulty pixels start = time.time() #Load images cached gallery.append(grey) if (len(gallery) > 4): gallery.pop(0) faulty = pixcheck.pixcheck(list(gallery)) subtracted = numpy.count_nonzero(faulty) print("Subtracted pixels: "+str(subtracted)) #save this cv2.imwrite(name+"/faulty.bmp",faulty) end= time.time() print("Faulty/noisy pixel check time: "+str(end-start)) #find objects high_threshold = 100 low_threshold = 5 counts = counter.giveCount(img,low_threshold,high_threshold) rate = counts*framerate print("Rate: "+str(rate)) show.draw(rate,subtracted) print ("Img "+str(i)) i+=1 stream.seek(0) stream.truncate()
camera.capture(stream, "rgb") img = stream.array #Convert to intensity grey = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY) #Remove faulty pixels start = time.time() #Load images cached gallery.append(grey) if (len(gallery) > 4): gallery.pop(0) faulty = pixcheck.pixcheck(list(gallery)) subtracted = numpy.count_nonzero(faulty) print("Subtracted pixels: " + str(subtracted)) #save this cv2.imwrite(name + "/faulty.bmp", faulty) end = time.time() print("Faulty/noisy pixel check time: " + str(end - start)) #find objects high_threshold = 100 low_threshold = 5 counts = counter.giveCount(img, low_threshold, high_threshold) rate = counts * framerate print("Rate: " + str(rate)) show.draw(rate, subtracted) print("Img " + str(i)) i += 1 stream.seek(0) stream.truncate()
W = T * Pp return W # 开始测试,输入测试样例和权值矩阵,返回输出的矩阵并且转换为数组 def start(pt,W): pt = np.matrix(pt) n = W * pt.T n = n.getA1() a = [] for i in n: a.append(hardlims(i)) return a if __name__ == '__main__': W = training() # print W test = [-1,1,1,1,-1, 1,-1,-1,-1,1, 1,-1,-1,-1,1, -1,-1,-1,-1,-1, -1,-1,-1,-1,-1, -1,-1,-1,-1,-1] show.draw(test) pt = np.matrix(test) n = pt * W n = n.getA1() a = [] for i in n: a.append(hardlims(i)) # a = np.matrix(a) show.draw(a)