[英]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.