← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #817874]: OnAppear Not Catching Pattern's Low Similarity

 

Question #817874 on SikuliX changed:
https://answers.launchpad.net/sikuli/+question/817874

Hassan posted a new comment:
The issue you are encountering with SikuliX regarding the `onAppear`
handler not triggering for matches below a certain similarity score,
despite setting a lower similarity threshold, is not uncommon. Here are
some insights based on your description and relevant findings:

### Observations on Similarity Settings

1. **Minimum Similarity Threshold**: The `onAppear` method seems to have
an implicit minimum similarity threshold that may not align with the
`similar()` setting you applied. While you set the pattern's similarity
to 0.4, it appears that `onAppear` may still enforce a higher threshold
(like 0.7) for triggering the handler. This behavior could be a design
choice in SikuliX, where the observer uses a stricter criterion for
event handling compared to direct matches checked with `exists()`.

2. **Settings.minSimilarity**: You mentioned that changing
`Settings.minSimilarity` allowed the 0.66 image to trigger the handler.
This indicates that while the pattern's similarity can be adjusted, the
observer's internal logic might still impose its own limitations. If you
have multiple observations running, adjusting this global setting could
lead to conflicts with those needing tighter matches.

### Possible Solutions

- **Separate Observers**: Consider creating separate observers for
different patterns with varying similarity requirements. This way, you
can set `Settings.minSimilarity` appropriately for each observer without
affecting others.

- **Custom Handling Logic**: Implement a custom logic within your
handler to check the similarity score of the found pattern. You can use
`similar()` to dynamically adjust your response based on the actual
score returned.

- **Update to Latest Version**: If feasible, consider updating to a
newer version of SikuliX. There may have been improvements or bug fixes
that address your issue.

### Known Issues and Community Feedback

While there is no definitive documentation stating this behavior as a
known issue, users have reported similar experiences with the `onAppear`
and `onVanish` methods in various contexts. The community forums, such
as the one you referenced, often discuss these nuances, indicating that
the behavior may not be fully documented or predictable across different
versions or setups [1][4].

If you continue to experience difficulties, it may be beneficial to
reach out directly on SikuliX forums or check for updates in the
documentation regarding event handling and similarity settings.
Regarding https://pgsharp.us/

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for SikuliX.