本文整理汇总了Python中sklearn.cluster.MiniBatchKMeans.cluster_centers_astype方法的典型用法代码示例。如果您正苦于以下问题:Python MiniBatchKMeans.cluster_centers_astype方法的具体用法?Python MiniBatchKMeans.cluster_centers_astype怎么用?Python MiniBatchKMeans.cluster_centers_astype使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sklearn.cluster.MiniBatchKMeans
的用法示例。
在下文中一共展示了MiniBatchKMeans.cluster_centers_astype方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: VideoFrameReaders
# 需要导入模块: from sklearn.cluster import MiniBatchKMeans [as 别名]
# 或者: from sklearn.cluster.MiniBatchKMeans import cluster_centers_astype [as 别名]
def VideoFrameReaders(VideoDirectory):
cap = cv2.VideoCapture(VideoDirectory)
kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (3, 3))
fgbg = cv2.createBackgroundSubtractorMOG2()
timestamp = []
count = 0
try:
while cap.isOpened():
ret,frame = cap.read()
time = cap.get(0) #get the frame in seconds
timestamp.append(time)
print timestamp
if frame == None:
break;
# frame = cv2.cvtColor(frame,cv2.COLOR_RGB2GRAY)
image = frame.reshape((frame.shape[0]*frame.shape[1],3))
K = 4
clf = MiniBatchKMeans(K)
#predict cluster labels and quanitize each color based on the labels
cls_labels = clf.fit_predict(image)
print cls_labels
cls_quant = clf.cluster_centers_astype("uint8")[labels]
except EOFError:
pass