Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I replied to your post on EMGU but figured you haven't checked back but this is it. The shape detection works on the principle of thresh-holding unlikely matches, this prevents lots of false classifications. This is true for many image processing algorithms. Basically there are <strong>no</strong> perfect setting and a designer must select the most appropriate settings to produce the most desirable results. I.E. match the most objects without saying there's more than there actually is. </p> <p>You will need to adjust each variable individually to see what kind of results you get. Start of with the edge detection.</p> <pre><code>Image&lt;Gray, Byte&gt; cannyEdges = gray.Canny(cannyThreshold, cannyThresholdLinking); </code></pre> <p>Have a look at your smaller image see what the difference is between the rectangles detected and the one that isn't. You could be missing and edge or a corner which is why it's not classified. If you are adjust cannyThreshold and observe the results, if good then keep it :) if bad :( go back to the original value. Once satisfied adjust cannyThresholdLinking and observe. </p> <p>You will keep repeating this until you get a preferred image the advantage here is that you have 3 items to compare you will continue until the item that's not being recognised matches the other two.</p> <p>If they are the similar, likely as it is a black and white image you'll need to go onto the Hough lines detection.</p> <pre><code> LineSegment2D[] lines = cannyEdges.HoughLinesBinary( 1, //Distance resolution in pixel-related units Math.PI / 45.0, //Angle resolution measured in radians. 20, //threshold 30, //min Line width 10 //gap between lines )[0]; //Get the lines from the first channel </code></pre> <p>Use the same method of adjusting one value at a time and observing the output you will hopefully find the settings you need. Never jump in with both feet and change all the values as you will never know if your improving the accuracy or not. Finally if all else fails look at the section that inspects the Hough results for a rectangle</p> <pre><code> if (angle &lt; 80 || angle &gt; 100) { isRectangle = false; break; } </code></pre> <p>Less variables to change as hough should do all the work for you. but still it could all work out here.</p> <p>I'm sorry that there is no straight forward answer, but I hope you keep at it and solve the problem. Else you could always resize the image each time.</p> <p>Cheers</p> <p>Chris</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. COThanks ... at least this represents a path I could follow. I agree that most image detection algorithms need some sort of tuning; however I've never come across one that depends on image size rather than aspect ratio. In any way edge detection does not seem to affect the result (for this image at least). Will update once I check the other parameters.
      singulars
    2. COIn this case your actually increasing the size of the objects your looking for. Very few algorithms actually depend on the image size or ratio but in fact the size of the object inside. Take your example the undetected Quadrilateral is a roughly Rectangle(165,97,240,114) that's an area of 27360 pixels. Now in your second image the same Quadrilateral is Rectangle(214, 129, 310, 146) that's an increased area 45'260 pixels. That's an increase of x1.65 now I'm sure you can see why the larger one is detected. Changing the Hough lines code should fix your problem if not I'll have a look, Good luck
      singulars
    3. COApparently in the example application, Hough lines are not used for shape detection ... contours are. If the number of pts are 4 => rectangle etc. In addition and this was my problem, the angle limits the number of rectangles detected. Any tilt of more than 10 deg (even if all the lines are at the same angle), and the shape is discarded. I can fiddle with this now :). There is another sinister thing going on though ... the shapes are being detected twice :/
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload