帮我用python语言写识别草的程序
时间: 2023-02-26 07:27:46 浏览: 101
我可以为您提供一个Python代码示例:from skimage.feature import local_binary_pattern from sklearn.svm import LinearSVC from sklearn.externals import joblib import numpy as np import cv2 # 加载图片 image = cv2.imread('grass.jpg') # 转换为灰度图 gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) # 用LBP生成特征 lbp = local_binary_pattern(gray, 24, 8, method="uniform")(x,y) # 把特征转换为数组 data = np.array(lbp) # 加载训练好的模型 clf = joblib.load('grass_svm.pkl') # 识别草的程序 result = clf.predict(data.reshape(1,-1)) # 输出结果 print(result[0])
阅读全文