Skip to content

Commit d7fa9d0

Browse files
committed
(#87) VisionAdapter API docs
1 parent 161d26c commit d7fa9d0

File tree

1 file changed

+27
-28
lines changed

1 file changed

+27
-28
lines changed

Diff for: lib/adapter/vision.adapter.class.ts

+27-28
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,19 @@ import { TemplateMatchingFinder } from "../provider/opencv/template-matching-fin
1010
import { Region } from "../region.class";
1111

1212
/**
13-
* OpenCVAdapter serves as an abstraction layer for all image based interactions.
13+
* {@link VisionAdapter} serves as an abstraction layer for all image based interactions.
1414
*
1515
* This allows to provide a high level interface for image based actions,
16-
* whithout having to spread (possibly) multiple dependencies all over the code.
16+
* without having to spread (possibly) multiple dependencies all over the code.
1717
* All actions which involve screenshots / images are bundled in this adapter.
1818
*/
1919
export class VisionAdapter {
20+
/**
21+
* {@link VisionAdapter} class constructor
22+
* @param finder A {@link FinderInterface} instance used for on-screen image detection (Default: {@link TemplateMatchingFinder})
23+
* @param screen A {@link ScreenActionProvider} instance used to retrieve screen data (Default: {@link ScreenAction})
24+
* @param dataSink A {@link DataSink} instance used to write output data to disk (Default: {@link ImageWriter})
25+
*/
2026
constructor(
2127
private finder: FinderInterface = new TemplateMatchingFinder(),
2228
private screen: ScreenActionProvider = new ScreenAction(),
@@ -25,34 +31,31 @@ export class VisionAdapter {
2531
}
2632

2733
/**
28-
* grabScreen will return an Image containing the current screen image
34+
* {@link grabScreen} will return an {@link Image} containing the current screen image
2935
*
30-
* @returns {Promise<Image>} Image will contain screenshot data as well as dimensions
31-
* @memberof VisionAdapter
36+
* @returns An {@link Image} which will contain screenshot data as well as dimensions
3237
*/
3338
public grabScreen(): Promise<Image> {
3439
return this.screen.grabScreen();
3540
}
3641

3742
/**
38-
* grabScreenRegion essentially does the same as grabScreen, but only returns a specified Region
43+
* {@link grabScreenRegion} essentially does the same as grabScreen, but only returns a specified {@link Region}
3944
*
40-
* @param {Region} region The screen region we want to grab
41-
* @returns {Promise<Image>} Image will contain screenshot data of the specified region as well as dimensions
42-
* @memberof VisionAdapter
45+
* @param region The screen {@link Region} we want to grab
46+
* @returns An {@link Image} which will contain screenshot data of the specified {@link Region} as well as dimensions
4347
*/
4448
public grabScreenRegion(region: Region): Promise<Image> {
4549
return this.screen.grabScreenRegion(region);
4650
}
4751

4852
/**
49-
* findOnScreenRegion will search for a given pattern inside a region of an image.
50-
* If multiple possible occurences are found, the one with the highes probability is returned.
53+
* {@link findOnScreenRegion} will search for a given pattern inside a {@link Region} of the main screen
54+
* If multiple possible occurrences are found, the one with the highest probability is returned.
5155
* For matchProbability < 0.99 the search will be performed on grayscale images.
5256
*
53-
* @param {MatchRequest} matchRequest A match request which holds all required matching data
54-
* @returns {Promise<MatchResult>} MatchResult will contain location and probability of a possible match
55-
* @memberof VisionAdapter
57+
* @param matchRequest A {@link MatchRequest} which holds all required matching data
58+
* @returns {@link MatchResult} containing location and probability of a possible match
5659
*/
5760
public async findOnScreenRegion(
5861
matchRequest: MatchRequest,
@@ -68,47 +71,43 @@ export class VisionAdapter {
6871
}
6972

7073
/**
71-
* screenWidth returns the main screen's width as reported by the OS.
74+
* {@link screenWidth} returns the main screens width as reported by the OS.
7275
* Please notice that on e.g. Apples Retina display the reported width
7376
* and the actual pixel size may differ
7477
*
75-
* @returns {Promise<number>} The main screen's width as reported by the OS
76-
* @memberof VisionAdapter
78+
* @returns The main screens width as reported by the OS
7779
*/
7880
public screenWidth(): Promise<number> {
7981
return this.screen.screenWidth();
8082
}
8183

8284
/**
83-
* screenHeight returns the main screen's height as reported by the OS.
85+
* {@link screenHeight} returns the main screens height as reported by the OS.
8486
* Please notice that on e.g. Apples Retina display the reported width
8587
* and the actual pixel size may differ
8688
*
87-
* @returns {Promise<number>} The main screen's height as reported by the OS
88-
* @memberof VisionAdapter
89+
* @returns The main screens height as reported by the OS
8990
*/
9091
public screenHeight(): Promise<number> {
9192
return this.screen.screenHeight();
9293
}
9394

9495
/**
95-
* screenSize returns a Region object with the main screen's size.
96-
* Please notice that on e.g. Apples Retina display the reported width
96+
* {@link screenSize} returns a {@link Region} object with the main screens size.
97+
* Please note that on e.g. Apples Retina display the reported width
9798
* and the actual pixel size may differ
9899
*
99-
* @returns {Promise<Region>} The Region object the size of your main screen
100-
* @memberof VisionAdapter
100+
* @returns A {@link Region} object representing the size of a systems main screen
101101
*/
102102
public screenSize(): Promise<Region> {
103103
return this.screen.screenSize();
104104
}
105105

106106
/**
107-
* saveImage saves an Image to a given path on disk.
107+
* {@link saveImage} saves an {@link Image} to a given path on disk.
108108
*
109-
* @param image The Image to store
110-
* @param path The storage path
111-
* @memberof VisionAdapter
109+
* @param image The {@link Image} to store
110+
* @param path The path where to store the image
112111
*/
113112
public saveImage(image: Image, path: string): Promise<void> {
114113
return (this.dataSink as ImageWriter).store(image, path);

0 commit comments

Comments
 (0)