问题
I hame some image with plane which have perspective transform.
I need to detect center of each white rhombus or rhombus itself.
Here is examples:
As I unserstand the problem can be solved by simple template matching if we rectify image, but I need to do it automatically.
Is there any functions in OpenCV suitable for this task? Any other ideas?
回答1:
Here are two quick tests I just did without correcting the perspective issue.
Pure mathematical morphology:
- Extract the red channel
- Big white top-hat in order to detect all the bright areas, but without the big bright reflexion.
- Small white top-hat in order to detect only the thin lines between the rhombus
- Result of 2 minus result of 3. The lines between the rhombus are then thinner or even disappeared.
- Opening to clean the final result.
Here are two results: Image1 and Image2. The main issue is that the rhombus do not have the same sizes (different magnification and perspective), which can be problematic with the mathematical morphology.
So here is an other solution using the Hough transform:
- You start with the resulting image of the step 3 from the previous algorithm.
- You apply a hough transform.
Here are the results: Hough1 and Hough2. Then you have to filter between lines touching a rhombus or not, but you can use my first algorithm for that. Even if all the rhombus are not detected by the first algorithm, most will be and it will be enough to detect the lines touching the Rhombus. Then the line intersections will be the centroids that your are looking for.
来源:https://stackoverflow.com/questions/38706642/opencv-how-to-detect-rhombus-on-image