User Tools

Site Tools


en:code:core:image

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:code:core:image [2011/11/18 13:05] – [findSubImage] jmgren:code:core:image [2023/10/09 10:17] (current) jmgr
Line 15: Line 15:
 </code> </code>
 <code javascript> <code javascript>
-var myObject = new Image(x, y);+var myObject = new Image(filename);
 </code> </code>
  
 === Arguments === === Arguments ===
   - otherImage - (Image) other Image to copy   - otherImage - (Image) other Image to copy
 +  - filename - (string) a valid image filename 
 === Exceptions === === Exceptions ===
   * (ParameterTypeError) incorrect parameter type   * (ParameterTypeError) incorrect parameter type
Line 51: Line 51:
 === Exceptions === === Exceptions ===
   * (InvalidWindowError) invalid window   * (InvalidWindowError) invalid window
 +
 +==== takeScreenshotUsingScreenIndex ====
 +Take a screenshot of one screen and store the result in a new Image. [//Added in Actionaz 3.7.0.//]
 +
 +=== Syntax ===
 +<code javascript>
 +var myObject = Image.takeScreenshotUsingScreenIndex(0);
 +</code>
 +
 +=== Arguments ===
 +  - screenIndex - (integer) the index of the screen to screenshot
 +
 +=== Exceptions ===
 +  * (InvalidScreenIndexError) invalid screen index
  
 ===== Methods ===== ===== Methods =====
Line 339: Line 353:
 Searches for another image contained in this one. Searches for another image contained in this one.
  
-Added in Actionaz 3.1.0.+//Added in Actionaz 3.0.1.//
  
 === Syntax === === Syntax ===
Line 354: Line 368:
     * confidenceMinimum - (integer) the minimum confidence percentage, 100 means perfect match (default: 70)     * confidenceMinimum - (integer) the minimum confidence percentage, 100 means perfect match (default: 70)
     * downPyramidCount - (integer) the number of pyramids to use. A pyramid is a subdivision of the image used to accelerate the search. Choose 1 here if the searched image is not very different from this image. (default: 2)     * downPyramidCount - (integer) the number of pyramids to use. A pyramid is a subdivision of the image used to accelerate the search. Choose 1 here if the searched image is not very different from this image. (default: 2)
-    * searchExpansion - (integer) the number of pixels to shift when searching for another matching image (default: 15)+    * method - ([[#method|Method]]) the search method to use (default: CorrelationCoefficient[//Added in Actionaz 3.7.0.//]
  
 === Returns === === Returns ===
-  * (object) the matching point, or null if not matching point can be found+  * (object) the matching point, or null if no matching point can be found
     * position - ([[en:code:core:point|Point]]) the matching image center     * position - ([[en:code:core:point|Point]]) the matching image center
     * confidence - (integer) the confidence percentage     * confidence - (integer) the confidence percentage
Line 379: Line 393:
  
 ==== findSubImages ==== ==== findSubImages ====
-Searches for another images contained in this one. +Searches for images contained in this one.
-TODO+
  
 +//Added in Actionaz 3.0.1.//
 +
 +=== Syntax ===
 +<code javascript>
 +myObject.findSubImages(otherImage);
 +</code>
 +<code javascript>
 +myObject.findSubImages(otherImage, options);
 +</code>
 +
 +=== Arguments ===
 +  - otherImage - (Image) the Image to find
 +  - options - (object) search options
 +    * confidenceMinimum - (integer) the minimum confidence percentage, 100 means perfect match (default: 70)
 +    * downPyramidCount - (integer) the number of pyramids to use. A pyramid is a subdivision of the image used to accelerate the search. Choose 1 here if the searched image is not very different from this image. (default: 2)
 +    * searchExpansion - (integer) the number of pixels to shift when searching for another matching image (default: 15)
 +    * maximumMatches - (integer) the maximal number of matches (default: 10)
 +    * method - ([[#method|Method]]) the search method to use (default: CorrelationCoefficient) [//Added in Actionaz 3.7.0.//]
 +
 +=== Returns ===
 +  * (array of objects) the matching points, or null if no matching point can be found
 +    * position - ([[en:code:core:point|Point]]) the matching image center
 +    * confidence - (integer) the confidence percentage
 +
 +=== Exceptions ===
 +  * (FindSubImageError) an error occured while searching for a sub-image
 +  * (ParameterTypeError) incorrect parameter type
 +
 +=== Example ===
 +<code javascript>
 +//Searches for objects on the screen
 +var screenShot = Image.takeScreenshot();
 +var imageToFind = new Image("object.png");
 +
 +var searchResult = screenShot.findSubImages(imageToFind);
 +if(searchResult)
 +{
 +    Console.print("Matching images found\n");
 +    
 +    for(var i = 0; i < searchResult.length; ++i)
 +    {
 +        Console.print("position: " + searchResult[i].position + ", confidence: " + searchResult[i].confidence + "\n");
 +    }
 +}
 +else
 +    Console.print("No matching images found.");
 +</code>
 ==== findSubImageAsync ==== ==== findSubImageAsync ====
 Searches for another image contained in this one in asynchronous mode. Searches for another image contained in this one in asynchronous mode.
-TODO 
  
 +//Added in Actionaz 3.0.1.//
 +
 +=== Syntax ===
 +<code javascript>
 +myObject.findSubImageAsync(otherImage, callback);
 +</code>
 +<code javascript>
 +myObject.findSubImageAsync(otherImage, callback, options);
 +</code>
 +
 +=== Arguments ===
 +  - otherImage - (Image) the Image to find
 +  - callback(object) - (function) the function that will be called when the search ends
 +    * position - ([[en:code:core:point|Point]]) the matching image center
 +    * confidence - (integer) the confidence percentage
 +  - options - (object) search options
 +    * confidenceMinimum - (integer) the minimum confidence percentage, 100 means perfect match (default: 70)
 +    * downPyramidCount - (integer) the number of pyramids to use. A pyramid is a subdivision of the image used to accelerate the search. Choose 1 here if the searched image is not very different from this image. (default: 2)
 +    * searchExpansion - (integer) the number of pixels to shift when searching for another matching image (default: 15)
 +    * method - ([[#method|Method]]) the search method to use (default: CorrelationCoefficient) [//Added in Actionaz 3.7.0.//]
 +
 +=== Returns ===
 +  * (Image) this Image
 +
 +=== Exceptions ===
 +  * (FindSubImageError) an error occured while searching for a sub-image
 +  * (ParameterTypeError) incorrect parameter type
 +
 +=== Example ===
 +<code javascript>
 +//Searches for an object on the screen
 +var screenShot = Image.takeScreenshot();
 +var imageToFind = new Image("object.png");
 +
 +screenShot.findSubImageAsync(imageToFind, function(searchResult)
 +{
 +    if(searchResult)
 +        Console.print("Matching image found, position: " + searchResult.position + ", confidence: " + searchResult.confidence);
 +    else
 +        Console.print("No matching image found.");
 +});
 +</code>
 ==== findSubImagesAsync ==== ==== findSubImagesAsync ====
-Searches for another images contained in this one in asynchronous mode. +Searches for images contained in this one in asynchronous mode. 
-TODO+ 
 +//Added in Actionaz 3.0.1.// 
 + 
 +=== Syntax === 
 +<code javascript> 
 +myObject.findSubImagesAsync(otherImage, callback); 
 +</code> 
 +<code javascript> 
 +myObject.findSubImagesAsync(otherImage, callback, options); 
 +</code> 
 + 
 +=== Arguments === 
 +  - otherImage - (Image) the Image to find 
 +  - callback(object) - (function) the function that will be called when the search ends 
 +    * position - ([[en:code:core:point|Point]]) the matching image center 
 +    * confidence - (integer) the confidence percentage 
 +  - options - (object) search options 
 +    * confidenceMinimum - (integer) the minimum confidence percentage, 100 means perfect match (default: 70) 
 +    * downPyramidCount - (integer) the number of pyramids to use. A pyramid is a subdivision of the image used to accelerate the search. Choose 1 here if the searched image is not very different from this image. (default: 2) 
 +    * searchExpansion - (integer) the number of pixels to shift when searching for another matching image (default: 15) 
 +    * maximumMatches - (integer) the maximal number of matches (default: 10) 
 +    * method - ([[#method|Method]]) the search method to use (default: CorrelationCoefficient) [//Added in Actionaz 3.7.0.//] 
 + 
 +=== Returns === 
 +  * (Image) this Image 
 + 
 +=== Exceptions === 
 +  * (FindSubImageError) an error occured while searching for a sub-image 
 +  * (ParameterTypeError) incorrect parameter type 
 + 
 +=== Example === 
 +<code javascript> 
 +//Searches for objects on the screen 
 +var screenShot = Image.takeScreenshot(); 
 +var imageToFind = new Image("object.png"); 
 + 
 +screenShot.findSubImagesAsync(imageToFind, function(searchResult) 
 +
 +    if(searchResult) 
 +    { 
 +        Console.print("Matching images found\n"); 
 +     
 +        for(var i = 0; i < searchResult.length; ++i) 
 +        { 
 +            Console.print("position: " + searchResult[i].position + ", confidence: " + searchResult[i].confidence + "\n"); 
 +        } 
 +    } 
 +    else 
 +        Console.print("No matching images found."); 
 +}); 
 +</code>
 ===== Enumerations ===== ===== Enumerations =====
  
Line 416: Line 567:
   - Vertical: a vertical mirror   - Vertical: a vertical mirror
   - Horizontal: an horizontal mirror   - Horizontal: an horizontal mirror
 +
 +==== Method ====
 +Search method. [//Added in Actionaz 3.7.0.//]
 +
 +=== Values ===
 +  - CorrelationCoefficient: correlation coefficient, best for most use cases
 +  - CrossCorrelation: cross correlation
 +  - SquaredDifference: squared difference
en/code/core/image.1321621503.txt.gz · Last modified: 2021/02/13 11:23 (external edit)