Androidアプリで使用されるSVMを後でトレーニングできるように、機能を抽出しようとしています。記述が簡単で時間を節約できるため、機能を見つけて抽出するために python を使用しています。私の問題は、機能が多すぎて、最良の機能だけを取得する方法がわからないことです。OpenCVのC++ APIにretainBestというメソッドがあるのを見つけたのですが、pythonでは見つけられませんでした。どうすればよいかアドバイスいただけますか?
これは私が使用するコードです:
import numpy as np
import cv2
from matplotlib import pyplot as plt
img = cv2.imread('./positive_images/1.jpg',cv2.CV_LOAD_IMAGE_GRAYSCALE)
#img = cv2.resize(cv2.imread('./positive_images/3.png',cv2.CV_LOAD_IMAGE_GRAYSCALE), (100, 100))
#th3 = cv2.adaptiveThreshold(img,255,cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY,11,2)
ret,th3 = cv2.threshold(img,127,255,cv2.THRESH_TOZERO_INV)
cv2.imwrite("result1.jpg", th3)
img = th3
# Initiate FAST object with default values
fast = cv2.FastFeatureDetector()
# find and draw the keypoints
keypoints = fast.detect(img,None)
img2 = cv2.drawKeypoints(img, keypoints, color=(255,0,0))
cv2.imwrite('fast_true.png',img2)
# Disable nonmaxSuppression
fast.setBool('nonmaxSuppression',0)
keypoints = fast.detect(img,None)
print "Total Keypoints without nonmaxSuppression: ", len(keypoints)
img3 = cv2.drawKeypoints(img, keypoints, color=(255,0,0))
cv2.imwrite("result.jpg",img3)
元の画像:
そして結果の画像:
私の目標は、ハンドルを検出することです。