問題描述
我有一個包含對象的示例圖像,例如下圖中的耳環:
I have a sample image which contains an object, such as the earrings in the following image:
http://imgur.com/luj2Z
然后我有一大組候選圖像,我需要確定哪一個最有可能包含對象,例如:
I then have a large candidate set of images for which I need to determine which one most likely contains the object, e.g.:
http://imgur.com/yBWgc
所以我需要為每個圖像生成一個分數,其中最高分數對應于最有可能包含目標對象的圖像.現在,在這種情況下,我有以下條件/約束可以使用/解決:
So I need to produce a score for each image, where the highest score corresponds to the image which most likely contains the target object. Now, in this case, I have the following conditions/constraints to work with/around:
1) 我可以獲取多個不同角度的樣本圖像.
1) I can obtain multiple sample images at different angles.
2) 樣本圖像的分辨率、角度和距離可能與候選圖像不同.
2) The sample images are likely to be at different resolutions, angles, and distances than the candidate images.
3) 有很多候選圖像 (> 10,000),所以它必須相當快.
3) There are a LOT of candidate images (> 10,000), so it must be reasonably fast.
4) 我愿意為速度犧牲一些精度,所以如果這意味著我們必須搜索前 100 名而不是只搜索前 10 名,那很好,可以手動完成.
4) I'm willing to sacrifice some precision for speed, so if it means we have to search through the top 100 instead of just the top 10, that's fine and can be done manually.
5) 我可以手動操作樣本圖像,例如勾勒出我希望檢測的對象;候選圖像太多,無法手動操作.
5) I can manipulate the sample images manually, such as outlining the object that I wish to detect; the candidate images cannot be manipulated manually as there are too many.
6) 我根本沒有真正的 OpenCV 或計算機視覺背景,所以我在這里從頭開始.
6) I have no real background in OpenCV or computer vision at all, so I'm starting from scratch here.
我最初的想法是先在示例圖像中的對象周圍畫一個粗略的輪廓.然后,我可以識別對象中的角點和候選圖像中的角點.我可以分析每個角周圍的像素,看看它們是否相似,然后按每個角的最大相似度得分之和進行排名.我也不確定如何量化相似的像素.我猜只是它們的 RGB 值的歐幾里得距離?
My initial thought is to start by drawing a rough outline around the object in the sample image. Then, I could identify corners in the object and corners in the candidate image. I could profile the pixels around each corner to see if they look similar and then rank by the sum of the maximum similarity scores of every corner. I'm also not sure how to quantify similar pixels. I guess just the Euclidean distance of their RGB values?
問題在于它有點忽略了對象的中心.在上面的例子中,如果耳環的角都靠近金框,那么就不會考慮耳環里面的紅綠藍寶石.我想我可以通過查看所有角對并通過沿它們之間的線采樣一些點來確定相似性來改進這一點.
The problem there is that it kind of ignores the center of the object. In the above examples, if the corners of the earrings are all near the gold frame, then it would not consider the red, green, and blue stones inside the earring. I suppose I could improve this by then looking at all pairs of corners and determining similarity by sampling some points along the line between them.
所以我有幾個問題:
A) 這種思路總體上是否有意義,還是我遺漏了什么?
A) Does this line of thinking make sense in general or is there something I'm missing?
B) 我應該使用 OpenCV 中的哪些特定算法進行調查?我知道有多種角點檢測算法,但我只需要一個,如果差異都在邊緣優化,那么我可以用最快的.
B) Which specific algorithms from OpenCV should I investigate using? I'm aware that there are multiple corner detection algorithms, but I only need one and if the differences are all optimizing on the margins then I'm fine with the fastest.
C) 任何使用有助于我理解的算法的示例代碼?
C) Any example code using the algorithms that would be helpful to aid in my understanding?
我的語言選擇是 Python 或 C#.
My options for languages are either Python or C#.
推薦答案
查看 SURF 功能,這是 openCV 的一部分.這里的想法是你有一個算法可以在兩個圖像中找到興趣點".您還有一個算法可以計算每個興趣點周圍的圖像塊的描述符.通常,此描述符捕獲補丁中邊緣方向的分布.然后您嘗試找到點對應關系,即.e.對于圖像 A 中的每個興趣點,嘗試在圖像 B 中找到相應的興趣點.這是通過比較描述符并尋找最接近的匹配來完成的.然后,如果您有一組通過某種幾何變換相關的對應關系,那么您就有了檢測.
Check out the SURF features, which are a part of openCV. The idea here is that you have an algorithm for finding "interest points" in two images. You also have an algorithm for computing a descriptor of an image patch around each interest point. Typically this descriptor captures the distribution of edge orientations in the patch. Then you try to find point correspondences, i. e. for each interest point in image A try to find a corresponding interest point in image B. This is accomplished by comparing the descriptors, and looking for the closest matches. Then, if you have a set of correspondences that are related by some geometric transformation, you have a detection.
當然,這是一個非常高級的解釋.魔鬼在細節中,對于那些你應該閱讀一些論文.從 David Lowe 的 來自尺度不變關鍵點的獨特圖像特征開始,然后閱讀 SURF 上的論文.
Of course, this is a very high level explanation. The devil is in the details, and for those you should read some papers. Start with Distinctive image features from scale-invariant keypoints by David Lowe, and then read the papers on SURF.
另外,考慮將此問題移至信號和圖像處理堆棧交換
Also, consider moving this question to Signal and Image Processing Stack Exchange
這篇關于使用 OpenCV 檢測一個圖像中的對象是否在另一個圖像中的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!