Skip to content

Commit a5edc91

Browse files
authored
Merge pull request #18 from Tencent/support_android10
Support android10
2 parents da24c60 + f1a68f5 commit a5edc91

File tree

241 files changed

+649
-4682
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

241 files changed

+649
-4682
lines changed

doc/environment/InstallStepByStep.md

+1-1

log/Agent/.gitignore

Whitespace-only changes.

log/GameRecognize/.gitignore

Whitespace-only changes.

log/IOService/.gitignore

Whitespace-only changes.

log/ManageCenter/.gitignore

Whitespace-only changes.

log/UIMatch/.gitignore

Whitespace-only changes.

log/UIRecognize/.gitignore

Whitespace-only changes.

log/images/.gitignore

Whitespace-only changes.

src/ImgProc/Comm/ImgReg/Recognizer/CBloodLengthReg.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,12 @@ int CBloodLengthRegTmplMatch::Predict(const cv::Mat &oSrcImg, tagBloodLengthRegR
6969

7070
// obtain roi region of image
7171
cv::Rect oROI;
72-
ResizeRect(m_oROI, static_cast<float>(oSrcImg.cols) / IMAGE_WIDTH,
73-
static_cast<float>(oSrcImg.rows) / IMAGE_HEIGHT, oROI);
72+
int longEdge = oSrcImg.rows;
73+
if (oSrcImg.cols > oSrcImg.rows) {
74+
longEdge = oSrcImg.cols;
75+
}
76+
ResizeRect(m_oROI, static_cast<float>(longEdge) / IMAGE_WIDTH,
77+
static_cast<float>(longEdge) / IMAGE_WIDTH, oROI);
7478
ExpandRect(oROI, static_cast<int>(oSrcImg.cols * m_fExpandWidth),
7579
static_cast<int>(oSrcImg.rows * m_fExpandHeight), oROI);
7680
oData.m_oROI = oROI;

src/ImgProc/Comm/ImgReg/Recognizer/CLocationReg.cpp

+11-3
Original file line numberDiff line numberDiff line change
@@ -324,11 +324,11 @@ int CLocationRegTmplMatch::SetROI(const cv::Rect &oRect, int nImgWidth, int nImg
324324
if (nImgWidth > nImgHeight)
325325
{
326326
ResizeRect(oRect, static_cast<float>(nImgWidth) / IMAGE_LONG_SIDE,
327-
static_cast<float>(nImgHeight) / IMAGE_SHORT_SIDE, oROI);
327+
static_cast<float>(nImgWidth) / IMAGE_LONG_SIDE, oROI);
328328
}
329329
else
330330
{
331-
ResizeRect(oRect, static_cast<float>(nImgWidth) / IMAGE_SHORT_SIDE,
331+
ResizeRect(oRect, static_cast<float>(nImgHeight) / IMAGE_LONG_SIDE,
332332
static_cast<float>(nImgHeight) / IMAGE_LONG_SIDE, oROI);
333333
}
334334

@@ -662,13 +662,21 @@ int Detect(int nID, const cv::Mat &oSrcImg, const cv::Mat &oTmplImg, const cv::R
662662
stTmpl.fThreshold = fThreshold;
663663
stTmpl.oTmplImg = oResizeTmplImg(oResizeSrcRect);
664664

665+
// it should recalculate position in source image according to template position
666+
cv::Rect oRealLocation;
667+
oRealLocation.x = static_cast<int>(oResizeSrcImg.cols * oResizeSrcRect.x / oResizeTmplImg.cols);
668+
oRealLocation.y = static_cast<int>(oResizeSrcImg.rows * oResizeSrcRect.y / oResizeTmplImg.rows);
669+
oRealLocation.width = static_cast<int>(oResizeSrcImg.cols * oResizeSrcRect.width / oResizeTmplImg.cols);
670+
oRealLocation.height = static_cast<int>(oResizeSrcImg.rows * oResizeSrcRect.height / oResizeTmplImg.rows);
671+
665672
tagLocationRegParam stParam;
666673
stParam.strAlgorithm = "Detect";
667674
stParam.fMinScale = 0.8f;
668675
stParam.fMaxScale = 1.2f;
669676
stParam.nScaleLevel = 9;
670677
stParam.nMatchCount = 1;
671-
stParam.oLocation = oResizeSrcRect;
678+
//stParam.oLocation = oResizeSrcRect;
679+
stParam.oLocation = oRealLocation;
672680
stParam.fExpandWidth = fExpandWidth;
673681
stParam.fExpandHeight = fExpandHeight;
674682
stParam.oVecTmpls.push_back(stTmpl);
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from .demo.PlatformWeTest import PlatformWeTest
2+
3+
def GetInstance():
4+
return PlatformWeTest()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
import cv2
2+
import time
3+
import logging
4+
5+
from demo.Initializer import Initializer
6+
from demo.PlatformWeTest import PlatformWeTest, setup_logging
7+
8+
logger = logging.getLogger(__name__)
9+
10+
def __test_move(GAME_HEIGHT=640):
11+
# test move
12+
device_action = PlatformWeTest("127.0.0.1")
13+
ret, desc = device_action.init(is_portrait=False, long_edge=GAME_HEIGHT, standalone=True)
14+
if ret is False:
15+
logger.info("device action init fail")
16+
device_action.deinit()
17+
return
18+
19+
di, _ = device_action.get_device_info()
20+
__width = GAME_HEIGHT * 1.0 / di.display_height * di.display_width
21+
start_x, start_y, end_x, end_y = 1, 1, __width - 1, GAME_HEIGHT-1
22+
23+
steps_w = 20
24+
steps = int((end_x - start_x) * 1.0 / steps_w)
25+
steps_h = int((end_y - start_y) / steps)
26+
27+
logger.info("{},{} -> {},{}, steps={}".format(start_x, start_y, end_x, end_y, steps))
28+
29+
device_action.touch_reset()
30+
device_action.touch_down(start_x, start_y, 0)
31+
device_action.touch_down(end_x, start_y, 1)
32+
for i in range(0, steps):
33+
time.sleep(0.2)
34+
device_action.touch_move(start_x + i * steps_w, start_y + i * steps_h, 0)
35+
device_action.touch_move(end_x - i * steps_w, start_y + i * steps_h, 1)
36+
37+
device_action.touch_up(0)
38+
device_action.touch_up(1)
39+
time.sleep(0.2*steps+2)
40+
41+
device_action = None
42+
def _onMouseEvent(event, x, y, flags, param):
43+
global device_action
44+
if event & cv2.EVENT_LBUTTONUP: # cv2.EVENT_LBUTTONUP=4
45+
if device_action:
46+
st = time.time()
47+
device_action.touch_down(x, y, 0)
48+
device_action.touch_up(0)
49+
print(time.time()-st)
50+
51+
def __test_image(GAME_HEIGHT = 640):
52+
global device_action
53+
device_action = PlatformWeTest("127.0.0.1", Initializer.TOUCH_SEVER_PORT, Initializer.CLOUD_SCREEN_PORT)
54+
ret, desc = device_action.init(is_portrait=True, long_edge=GAME_HEIGHT)
55+
if ret is False:
56+
logger.info("device action init fail")
57+
device_action.deinit()
58+
return
59+
60+
device_action.touch_reset()
61+
index = 0
62+
while True:
63+
err, image = device_action.get_image()
64+
if err == 0 and image is not None:
65+
#logger.info("index={} orientation: {}".format(index, device_action.get_rotation()))
66+
try:
67+
#cv2.imwrite("test_{}.jpg".format(index), image)
68+
cv2.imshow('test1', image)
69+
if index == 0:
70+
cv2.setMouseCallback('test1', _onMouseEvent)
71+
cv2.waitKey(1)
72+
except:
73+
pass
74+
index = index + 1
75+
else:
76+
logger.info("error: {}".format(err))
77+
78+
time.sleep(1)
79+
80+
def __test_getinfo(GAME_HEIGHT = 640):
81+
# test get touch info
82+
device_action = PlatformWeTest("127.0.0.1", Initializer.TOUCH_SEVER_PORT, Initializer.CLOUD_SCREEN_PORT)
83+
ret, desc = device_action.init(is_portrait=False, long_edge=GAME_HEIGHT, standalone=True)
84+
if ret is False:
85+
logger.info("device action init fail")
86+
device_action.deinit()
87+
return
88+
89+
device_info, _ = device_action.get_device_info()
90+
logger.info("{}".format(device_info))
91+
92+
93+
if __name__ == "__main__":
94+
setup_logging(default_path="demo/logging.json")
95+
96+
__test_image()
97+
#__test_move()
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,51 @@
1-
{
2-
"version": 1,
3-
"disable_existing_loggers": false,
4-
"formatters": {
5-
"simple": {
6-
"format": "%(asctime)s- [%(threadName)s] - %(filename)s:%(lineno)d - %(message)s"
7-
}
8-
},
9-
10-
"handlers": {
11-
"console": {
12-
"class": "logging.StreamHandler",
13-
"level": "DEBUG",
14-
"formatter": "simple",
15-
"stream": "ext://sys.stdout"
16-
},
17-
18-
"info_file_handler": {
19-
"class": "logging.handlers.RotatingFileHandler",
20-
"level": "INFO",
21-
"formatter": "simple",
22-
"filename": "info.log",
23-
"maxBytes": 10485760,
24-
"backupCount": 20,
25-
"encoding": "utf8"
26-
},
27-
28-
"error_file_handler": {
29-
"class": "logging.handlers.RotatingFileHandler",
30-
"level": "ERROR",
31-
"formatter": "simple",
32-
"filename": "errors.log",
33-
"maxBytes": 10485760,
34-
"backupCount": 20,
35-
"encoding": "utf8"
36-
}
37-
},
38-
39-
"loggers": {
40-
"my_module": {
41-
"level": "ERROR",
42-
"handlers": ["console"],
43-
"propagate": "no"
44-
}
45-
},
46-
47-
"root": {
48-
"level": "INFO",
49-
"handlers": ["console", "info_file_handler", "error_file_handler"]
50-
}
51-
}
1+
{
2+
"version": 1,
3+
"disable_existing_loggers": false,
4+
"formatters": {
5+
"simple": {
6+
"format": "%(asctime)s - %(threadName)s:%(filename)s:%(funcName)s:%(lineno)d - %(message)s"
7+
}
8+
},
9+
10+
"handlers": {
11+
"console": {
12+
"class": "logging.StreamHandler",
13+
"level": "DEBUG",
14+
"formatter": "simple",
15+
"stream": "ext://sys.stdout"
16+
},
17+
18+
"info_file_handler": {
19+
"class": "logging.handlers.RotatingFileHandler",
20+
"level": "INFO",
21+
"formatter": "simple",
22+
"filename": "info.log",
23+
"maxBytes": 10485760,
24+
"backupCount": 20,
25+
"encoding": "utf8"
26+
},
27+
28+
"error_file_handler": {
29+
"class": "logging.handlers.RotatingFileHandler",
30+
"level": "ERROR",
31+
"formatter": "simple",
32+
"filename": "errors.log",
33+
"maxBytes": 10485760,
34+
"backupCount": 20,
35+
"encoding": "utf8"
36+
}
37+
},
38+
39+
"loggers": {
40+
"my_module": {
41+
"level": "ERROR",
42+
"handlers": ["console"],
43+
"propagate": "no"
44+
}
45+
},
46+
47+
"root": {
48+
"level": "INFO",
49+
"handlers": ["console", "info_file_handler", "error_file_handler"]
50+
}
51+
}

tools/AIClient/WrappedDeviceAPI/deviceAPI/mobileDevice/android/plugin/Platform_plugin/PlatformWeTest/demo/start_touchserver.bat

-10
This file was deleted.

tools/AIClient/WrappedDeviceAPI/deviceAPI/mobileDevice/android/plugin/Platform_plugin/PlatformWeTest/demo/start_touchserver.sh

-16
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
export run_base=/data/local/tmp
2+
3+
# if not running as root, trick dalvik into using an alternative dex cache
4+
if [ ${USER_ID} -ne 0 ]; then
5+
tmp_cache=${run_base}/wetest/dalvik-cache
6+
7+
if [ ! -d ${tmp_cache} ]; then
8+
mkdir -p ${tmp_cache}
9+
fi
10+
11+
export ANDROID_DATA=${run_base}/wetest
12+
fi
13+
14+
export CLASSPATH=$run_base/wetest/inputserver.jar
15+
exec app_process $run_base/wetest com.tencent.wetest.inputserver.InputMain "$@"
Binary file not shown.

0 commit comments

Comments
 (0)