Finder.find() method doesn't have fixed execution time even with same background image and target image.

Asked by upma

        As far as I know, the concrete implementation of Finder.find() is the Open CV's template_match method. Besides that, I don't find any manual delay on the c++ side written to call Open CV.
        Based on my comprehension, the execution time of find method should be the same if screen and pattern are not changed. However, its execution time varies time by time.

Code snippet:
   long beforeFind = (new Date()).getTime();
   f.find(ptn);
   long afterFind = (new Date()).getTime();
   long timeDiff = afterFind - beforeFind;
   System.out.println("timeDiff: " + timeDiff);

The timeDiff varies from 48ms to 72ms if find and varies from 665ms to 808ms if find failed.

What's the cause of inconsistent search time?

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

what version of SikuliX?

Revision history for this message
Eugene S (shragovich) said :
#2

Try performing the same test in a loop a couple of times. I tried the same and it looks like the first result is a bit higher but all the subsequent results are much more similar. Might be a caching somewhere.

Revision history for this message
upma (yujunma09-i) said :
#3

@RaiMan. The DLLs are of version SikuliX-2014-1.1.0-Beta4.

Revision history for this message
upma (yujunma09-i) said :
#4

@Eugene S. Thanks for your test. Did you mean that the result varies a little time by time in your test case? Could you please me the range of data?

Revision history for this message
RaiMan (raimund-hocke) said :
#5

the DLL's have not changed since then, but their usage from the Java level API.

latest 1.1.0 build: http://sikulix.com
sources: https://github.com/RaiMan/SikuliX-2014

Revision history for this message
upma (yujunma09-i) said :
#6

@RaiMan. Thanks for you response. I don't think the Java level plays an important role in this situation. I do the test below:

      long beforeVisionFind = (new Date()).getTime();
      _results = Vision.find(_findInput);
      long afterVisionFind = (new Date()).getTime();
      long findDiff = afterVisionFind - beforeVisionFind;
      System.out.println("findDiff: " + findDiff);

The findDiff is also not stable. The difference between min value and max value is also tens of milliseconds. Besides that, @Eugene S's finding(the first one or two search has long time) can be reproduced on my machine in this case.

Revision history for this message
RaiMan (raimund-hocke) said :
#7

ok, I jump out here ;-)

When I will work on the version later this year, I will get rid of all that special C++ stuff anyway and do everything from the Java level using the OpenCV Java API (partly implemented, but switched off already now in class ImageFinder).

Can you help with this problem?

Provide an answer of your own, or ask upma for more information if necessary.

To post a message you must log in.