[英]Python/OpenCV how to deal with large number of SIFT feaure in .yml file?
我正在使用OpenCv,並使用yaml來存儲SIFT關鍵點和描述符。 我有一個1659張圖片(.jpg,每張圖片約95 KB)的數據庫。 對於每個圖像,我創建了一個帶有關鍵點和描述符的.yml文件。 現在,對於一幅圖像,我最終得到了700個關鍵點和描述符,結果得到了一個大約文件。 4MB,我想避免使用二進制文件。
我的問題是:
- 我如何知道特征數量是否足以容納圖像?
- 有什么方法可以控制功能數量? 例如,為SIFT設置閾值?
- 現在,使用
cv2.FileStorage.write
將numpy矩陣存儲到yamil文件中,OpenCv用16個有效數字(例如1.9705572128295898e + 00)寫入每個數字。 如果我減少有效數字是否有問題? 例如到4?
- 我如何知道特征數量是否足以容納圖像?
它必須取決於您的圖像和任務要求。 您應該比其他人了解更多,或者做一些實驗來弄清楚。
- 有什么方法可以控制功能數量?
當然。 創建時,只需傳遞必要的參數。
cv2.xfeatures2d.SIFT_create([, nfeatures[, nOctaveLayers[, contrastThreshold[, edgeThreshold[, sigma]]]]]) -> retval
| . @param nfeatures The number of best features to retain. The features are ranked by their scores
| . (measured in SIFT algorithm as the local contrast)
| .
| . @param nOctaveLayers The number of layers in each octave. 3 is the value used in D. Lowe paper.
| . The number of octaves is computed automatically from the image resolution.
| .
| . @param contrastThreshold The contrast threshold used to filter out weak features in semi-uniform
| . (low-contrast) regions. The larger the threshold, the less features are produced by the detector.
| .
| . @param edgeThreshold The threshold used to filter out edge-like features. Note that the its meaning
| . is different from the contrastThreshold, i.e. the larger the edgeThreshold, the less features are
| . filtered out (more features are retained).
| .
| . @param sigma The sigma of the Gaussian applied to the input image at the octave \#0. If your image
| . is captured with a weak camera with soft lenses, you might want to reduce the number.
|
例如,我創建了一個具有50個關鍵點和3層的篩選檢測器:
sift = cv2.xfeatures2d.SIFT_create(nfeatures = 50, nOctaveLayers=3)
這是檢測結果:
- 太長。 我知道您在OpenCV-Python中將大量關鍵點和描述符存儲為.yml格式。
好的,當您有大數據要存儲時, .yml
真的有幫助? 是真的很合理嗎?您真的需要每個keypoint (points2f, size, response, octave, class_id)
元素keypoint (points2f, size, response, octave, class_id)
。 對於描述符,它是直方圖或int數組。 因此,即使將其保存為int,該值也沒問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.