JavaScript Raw APIs
Low level APIs for controlling your android phone
getScreenSize()
Returns Object
- {width: Integer, height: Integer}
getScreenshot()
Returns Integer
- The image pointer
getScreenshotModify(cropX, cropY, cropWidth, cropHeight, resizeWidth, resizeHeight, qualitys)
Get screenshot, crop and resize. For speeding up screenshot.
cropX
IntegercropY
IntegercropWidth
IntegercropHeight
IntegerresizeWidth
IntegerresizeHeight
Integerquality
Integer
Returns Integer
- The image pointer
execute(command)
Call exec command in android system. It's permission is same as adb shell
command
String
Returns String
- The result of the execution
tap(x, y, during)
Simulate a tap event
x
Integery
Integerduring
Integer
tapDown(x, y, during)
x
Integery
Integerduring
Integer
tapUp(x, y, during)
x
Integery
Integerduring
Integer
moveTo(x, y, during)
moveTo should be betewwn tapDown
and tapUp
x
Integery
Integerduring
Integer
swipe(x1, y1, x2, y2, during)
Simulate a swipe event, using tapDown
, moveTo
and tapUp
event. This function may not work in some game, you should implement yourself.
x1
Integery1
Integerx2
Integery2
Integerduring
Integer
keycode(label, during)
Send a key code event to system Like adb shell input keyevent command Android Keycode List
label
Stringduring
Integer
typing(words, during)
Only allow English words
words
Stringduring
Integer
OpenCV
clone(sourceImg)
Duplicate an image to another.
sourceImg
Integer
Returns Integer
- The image pointer
smooth(sourceImg, smoothType, size)
Same as OpenCV smooth()
function.
sourceImg
IntegersmoothType
Integersize
Integer
convertColor(sourceImg, code)
Same as OpenCV cvtColor()
. Not support different channels. If you want to convert to gray, please use bgrToGray. Note that getScreenshot
and getScreenshotModify
is BGR order;
sourceImg
Integercode
Integer
See more: OpenCV Types
bgrToGray(sourceImg)
Convert form bgr (3 channels) to gray (1 channel).
sourceImg
Integer
Returns Integer
- The gray image pointer
absDiff(sourceImg, targetImg)
Same as OpenCV adbdiff()
.
sourceImg
IntegertargetImg
Integer
Returns Integer
- The image pointer of the difference
threshold(sourceImg, thr, maxThr, code)
Same as OpenCV threshold()
.
sourceImg
Integerthr
FloatmaxThr
Floatcode
Integer
See more: OpenCV Types
eroid(sourceImg, width, height, x, y)
Same as OpenCV eroid
.
width
, height
, x
, y
is getStructuringElement()
parameters.
sourceImg
Integerwidth
Integerheight
Integerx
Integery
Integer
dilate(sourceImg, width, height, x, y)
Same as OpenCV dilate
.
width
, height
, x
, y
is getStructuringElement()
parameters.
sourceImg
Integerwidth
Integerheight
Integerx
Integery
Integer
inRange(sourceImg, minB, minG, minR, minA, maxB, maxG, maxR, maxA)
Same as OpenCV inRange + clone + mask
. Filter with range color and clone to new image.
sourceImg
IntegerminB
IntegerminG
IntegerminR
IntegerminA
IntegermaxB
IntegermaxG
IntegermaxR
IntegermaxA
Integer
Returns Integer
- The filtered image pointer
outRange(sourceImg, minB, minG, minR, minA, maxB, maxG, maxR, maxA)
Same as OpenCV inRange + clone + not + mask
. Filter without range color and clone to new image.
sourceImg
IntegerminB
IntegerminG
IntegerminR
IntegerminA
IntegermaxB
IntegermaxG
IntegermaxR
IntegermaxA
Integer
Returns Integer
- The filtered image pointer
cloneWithMask(sourceImg, mask)
Same as OpenCV copyTo
. Clone image with mask (only support 1 channel)
sourceImg
Integermask
Integer
Returns Integer
- new image pointer with mask
houghCircles(sourceImg, method, dp, minDist, p1, p2, minR, maxR)
Same as OpenCV houghCircles
. For finding circles.
sourceImg
Integermethod
Integer (3 = CV_HOUGH_GRADIENT)dp
Float (1) (ratio between input image and input params.)minDist
Float (min distance between circles)p1
Float (canny parameter)p2
Float (canny parameter)minR
Integer (min radius)maxR
Integer (max radius)
Returns Object
- Array of circles
canny(sourceImg, t1, t2, apertureSize)
Same as OpenCV canny
sourceImg
Integert1
Floatt2
FloatapertureSize
Integer
Returns Integer
- The canny image pointer
findContours(cannyImgPtr, minArea, maxArea)
Same as OpenCV findContours
.
cannyImgPtr
Integer (Canny image as input)minArea
FloatmaxArea
Float
Returns Object
- {"0": {x: Integer, y: Integer}
drawCircle(sourceImg, x, y, radius, r, g, b, a)
Draw circle in an image.
sourceImg
Integerx
Integery
Integerradius
Integerr
Integerg
Integerb
Integera
Integer
getIdentityScore(sourceImg, targetImg)
sourceImg
IntegertargetImg
Integer
Returns Float
- The identity score
cropImage(sourceImg, x, y, width, height)
Crop image.
x
Integery
Integerwidth
Integerheight
Integer
Returns Integer
- The image pointer
findImage(sourceImg, targetImg)
Using OpenCV Template Match
to fing image.
sourceImg
IntegertargetImg
Integer
Returns Object
- {x: Integer, y: Integer, score: Float}
findImages(sourceImg, targetImg, scoreLimit, resultCountLimit, withoutOverlap)
Same as findImage()
, but find mulitple times.
sourceImg
IntegertargetImg
IntegerscoreLimit
IntegerresultCountLimit
IntegerwithoutOverlap
Boolean
Returns String
- {"0": {"x": Integer, "y": Integer, "score": Float}, "1": {"x": Integer, "y": Integer, "score": Float}}
, Key is String!
resizeImage(sourceImg, width, height)
Resize image.
width
Integerheight
Integer
Returns Integer
- The image pointer
releaseImage(imgPtr)
Very Important! You should call this function with all imgPtrs.
imgPtr
Integer
getImageColor(sourceImg, x, y)
Get color of point from an image.
sourceImg
Integerx
Integery
Integer
Returns Object
- {r: Integer, g: Integer, b: Integer, a: Integer}
getImageSize(imgPtr)
imgPtr
Integer
Returns Object
- {width: Integer, height: Integer}
saveImage(imgPtr, path)
Save image to disk.
imgPtr
Integerpath
String
openImage(path)
Open image from disk.
path
String
Returns Integer
- The image pointer
sleep(milliseconds)
Like sleep
function in C language, pause current process.
milliseconds
Integer
getStoragePath()
Get Robotmon folder. Like /sdcard/Robotmon
.
Returns String
- The storage path
getImageFromURL(url)
Get image from an url.
url
String
Returns Integer
- The image pointer
getImageFromBase64(base64)
Get image from a base64 string.
base64
String
Returns Integer
- The image pointer
getBase64FromImage(imgPtr)
Get base64 string from an image.
imgPtr
Integer
Returns String
- base64
readFile(path)
Read a file as string.
path
String
Returns String
- The text of the file
writeFile(path, text)
Write a string to a file.
path
Stringtext
String
encrypt(script)
Encrypted a string
script
String
Returns String - The encrypted script
runEncryptedScript(script)
Run a encrypted javascript string.
script
String - The script is encrypted byencrypt
runScript(script)
Run a javascript string.
script
String
httpClient(method, url, body, headers)
Do a http request.
method
Stringurl
Stringbody
Stringheaders
Object
Returns String
- The result
importJS(library)
Import an JS library.
library
String
getVirtualButtonHeight()
Returns Integer
- The height of the virtual button
Last updated