I'm trying to detect edges of a Business Card using GPUImage's HoughTransform since it seems to be the best way to achieve this task with this framework from what I have found with similar questions/problems.
The best results that I'm able to get is just playing with lineDetectionThreshold set to 0.25, which is giving me the 4 lines delimiting the business card, while minimizing the total number of lines.
I'm not able to determine if the edgeThreshold parameter helps here or not.
With the lines I get I'm filtering out lines that are very similar to each other (usually on each edge it finds a lot!), dividing them in horizontal and vertical and then finding 2 horizontal and 2 vertical lines that can form a rectangle.
I'm still finding many lines due to text, or shapes in the business card itself, and the higher the number, the worse the performance for a video stream.
I've tried to add some preprocessing, but not very successfully, probably because I don't know which techniques could help me here.
How could I improve detection of the just the 4 lines determining the edges? Actually, is it possible?
EDIT:
Here are some images to illustrate. I have deleted the logo and details in the business card to preserve privacy.
Raw lines obtained with 0.25 threshold (and this threshold sometimes makes to lose some of the edges while processing video)
lines after manual filtering with the same image:
Another example, though this one might be more difficult, even adding preprocessing steps:
Raw Lines:
Filtered Lines: