I have the following image of a seedling tray, and I am attempting to detect the tray edges.
When I attempt to run a Canny edge detection - after applying a Gaussian blur - this is the result that is provided:
Running a probabilistic Hough transform results in a jumbled mess like so:
Are there any opencv functions that should be used instead due to the detail and level of objects present in the image? Should I use a different program entirely? Here is an example of what I would hope the output would achieve:
I updated my method with some pre-processing to flatten the image ("removebg") as well as morphological operations (open and close) with structual elements matching a vertical bar and horizontal bar separately to enhance the planter edges after thresholding. Most of the parameters can be tuned for different size objects and images, which was the main problem going from the small resolution photo to full resolution. The main parameter of HoughLines is the detection threshold, which I put together a rough calculation based on the size of the image that seems to work well. This code seems to work with both small and large versions of the example image.
The first thing I would mess with to get those missing horizontal lines is the multiplyer on hough_thresh (set to .3 in this post). Lower = more lines detected.
I explored some convolution based methods and I recommend taking a look at them. Trying to match the shape of each planter or maybe corners may be better in the long run if you consistently have images with obscured lines.