1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

UWSCのCHKIMGXがとんでもない座標を帰してきた

Last updated at Posted at 2019-09-02

#この問題にぶち当たるまで
##最近なにしてたの
最近ゲームのマクロ作りに筆者がハマっていまして・・・(某国民的人気MMOやスマホ銃ゲー)
それでルンルンとRPA()をやっていたこの頃でした
##何が起こったの
そこで当然状態遷移の把握が必要になりCHKIMGXっていう神みたいな画像認識ライブラリがあって利用させていただいたのですが・・・
x:-1298015017 y:1081345421
みたいなある訳ねえだろ!っていう座標がしばしば現れて非常に困る状況に見舞われました

#対策
確認してみた結果あくまで座標がおかしいだけ、認識自体はうまく行ってることが確認できたのでありえない座標が帰ってきたときだけ再チェックをかける関数を自作することにより回避しました

###コード

function.uws
FUNCTION C_CHKIMGX(imgpath, winid, x1, y1, x2, y2, Detect_num, Threshold_delta, Target_color)
  while True
    ismatch = CHKIMGX(imgpath, winid, x1, y1, x2, y2, Detect_num, Threshold_delta, Target_color)
    print "ismatch:" + ismatch
    ifb ismatch = true and (x1 <= g_imgx_x and g_imgx_x <= x2) and (y1 <= g_imgx_y and g_imgx_y <= y2)
      break
    elseif ismatch = false
      break
    else
      PRINT "異常座標検知"
    endif
  Wend
  RESULT = ismatch
Fend

##おまけ
CHKIMGXでも全然認識してくれない時があって(画像サイズがとても小さい)かなり難儀していたのですが
ちゃんと色を指定してあげる(Target_color)と認識率がかなり上がり上手くいきました(そのシーンの中で特徴のある色を選択すると良い)

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?