halcon

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)

Solution

  • 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: