Lamp
Lamp

Reputation: 342

Halcon: numLevels parameter of FindNccModel has problem

If set numLevels to 'auto' and minScore = 0.99, it cannot find the model created on the same image.

Change the minScore to 0.8, get a result with score 1

It seems the minScore didn't work good on mulitple levels, but set numLevels to 1 will increase processing time from 2ms to 40ms.

Is there any way to fix this issue?

create_ncc_model (Image, 'auto', 0, 0, 'auto', 'use_polarity', ModelID)
find_ncc_model (Image1, ModelID, 0, 0, 0.99, 1, 0.5, 'false', 0, Row, Column, Angle, Score)

Upvotes: 1

Views: 88

Answers (1)

Marco Freudenberger
Marco Freudenberger

Reputation: 689

The problem are the searches at higher pyramid levels. I assume you understand the concept of Halcon's pyramid search.

Your problem is, that MinScore is used at all pyramid levels, and 0.99 is not suitable for higher levels: if NumLevels > 1 and your MinScore is pretty high, it can't find the model with that high score at higher pyramid levels (= lower resolution). If you effectively skip the pre-search at higher pyramid levels (by using NumLevels=1), the whole high resolution image needs to be searched, thus it is slower. The result score you get is the score at the lowest pyramid level (= original resolution).

I don't know your image, but in the easiest case you can just use a lower MinScore for find_ncc_model. Then accept the result if Score >= your original MinScore, dismiss it otherwise:

create_ncc_model (Image, 'auto', 0, 0, 'auto', 'use_polarity', ModelID)
MinScore := 0.99
SearchScore := 0.40
find_ncc_model (Image1, ModelID, 0, 0, SeachrScore, 1, 0.5, 'false', 0,     Row, Column, Angle, Score)
if (|Score| > 0)
    ** ncc_model found something with Score > SearchScore
    if ( Score[0] > MinScore)
        ** Accept your result
    else
        ** Dismiss your result
endif

What are actually good values for MinScore and SearchScore depends on your template ("Image"), the NumLevels and the image to analyze ("Image1).

Some remarks:

  • 0.99 is a pretty high score anyways, I assume your model is extracted from the image you actually analyze.
  • The lower the search score, the longer it may take to analyze. Impact is usually much less than what you are seeing with NumLevels=1, though.
  • It gets a bit more complicated if you have multiple features looking similar to your model (let's call them "match candidates") in the image. Another match candidate that would score lower on the lowest pyramid level might score higher than the best match at higher pyramid levels. In that case, you also need to to increase the NumMatches values, so that multiple candidates from higher pyramid levels are carried over to the next lower pyramid levels. Then just use Row[0], Column[0], Angle[0], Score[0] as your result (find_ncc_model sorts the results by score on the lowest pyramid level in descending order, i.e. best match first).
  • The same applies to shape matching.

Upvotes: 2

Related Questions