Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

win下使用exists匹配图像的时候,总是会把分辨率转换成(1024,0),导致识别不到 #1227

Open
rurutiazhou opened this issue Jul 15, 2024 · 0 comments

Comments

@rurutiazhou
Copy link

(请尽量按照下面提示内容填写,有助于我们快速定位和解决问题,感谢配合。否则直接关闭。)

bug描述:
我attach了一个windows的窗口,在脚本里使用exists方法截取了窗体内的一部分图像,在脚本运行的时候,log里显示,总是把我的窗体的分辨率转换成(1024,0),导致匹配失败:

[05:21:25][INFO]<airtest.core.api> Try finding:
Template(C:\Users\lucy.zhou\Desktop\集成用例脚本\v5_student_test_1.air\tpl1721024590314.png)
[05:21:26][DEBUG]<airtest.core.api> resize: (484, 108)->(1, 1), resolution: (1024, 768)=>(1024, 0)
[05:21:26][DEBUG]<airtest.core.api> try match with _find_template
[05:21:26][DEBUG]<airtest.core.api> 'error: in template match, found im_search bigger than im_source.'
[05:21:26][DEBUG]<airtest.core.api> try match with _find_sift_in_predict_area
[05:21:26][DEBUG]<airtest.core.api> try match with _find_sift
[05:21:26][DEBUG]<airtest.core.api> match result: None

**```Traceback (most recent call last):**
  File "C:\UItestFramwork\Common\python3.7\lib\site-packages\airtest\cli\runner.py", line 66, in runTest
    six.reraise(*sys.exc_info())
  File "C:\UItestFramwork\Common\python3.7\lib\site-packages\six.py", line 693, in reraise
    raise value
  File "C:\UItestFramwork\Common\python3.7\lib\site-packages\airtest\cli\runner.py", line 62, in runTest
    exec(compile(code.encode("utf-8"), pyfilepath, 'exec'), self.scope)
  File "C:\Users\lucy.zhou\Desktop\集成用例脚本\v5_student_test_1.air\v5_student_test_1.py", line 47, in <module>
    existsExamNo = exists(Template(r"tpl1721024590314.png", record_pos=(0.046, 0.002), resolution=(1024, 768)))
  File "C:\UItestFramwork\Common\python3.7\lib\site-packages\airtest\utils\logwraper.py", line 72, in wrapper
    res = f(*args, **kwargs)
  File "C:\UItestFramwork\Common\python3.7\lib\site-packages\airtest\core\api.py", line 408, in exists
    pos = loop_find(v, timeout=ST.FIND_TIMEOUT_TMP)
  File "C:\UItestFramwork\Common\python3.7\lib\site-packages\airtest\utils\logwraper.py", line 72, in wrapper
    res = f(*args, **kwargs)
  File "C:\UItestFramwork\Common\python3.7\lib\site-packages\airtest\core\cv.py", line 59, in loop_find
    try_log_screen(screen)
  File "C:\UItestFramwork\Common\python3.7\lib\site-packages\airtest\utils\logwraper.py", line 72, in wrapper
    res = f(*args, **kwargs)
  File "C:\UItestFramwork\Common\python3.7\lib\site-packages\airtest\core\cv.py", line 83, in try_log_screen
    aircv.imwrite(filepath, screen)
  File "C:\UItestFramwork\Common\python3.7\lib\site-packages\airtest\aircv\aircv.py", line 29, in imwrite
    cv2.imencode('.jpg', img)[1].tofile(filename)
cv2.error: OpenCV(3.4.2) C:\projects\opencv-python\opencv\modules\imgcodecs\src\grfmt_base.cpp:145: error: (-10:Unknown error code -10) Raw image encoder error: Empty JPEG image (DNL not supported) in function 'cv::BaseImageEncoder::throwOnEror'

**python 版本:** `python3.5`

**airtest 版本:** `1.2.17`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant