Dark Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Find object position based on python-opencv2

License

Notifications You must be signed in to change notification settings

NetEaseGame/aircv

Repository files navigation

aircv

Find object position based on python-opencv2 for python2.7+

Usage

import aircv as ac
imsrc = ac.imread('youimage.png') # Yuan Shi Tu Xiang
imsch = ac.imread('searched.png') # Dai Cha Zhao De Bu Fen

SIFTCha Zhao Tu Xiang

print ac.find_sift(imsrc, imsch)
# - when Not found
@return None
# Zhi Qian Shi Fan Hui De []

# - when found
@return {'point': (203, 245), 'rectangle': [(160, 24), (161, 66), (270, 66), (269, 24)], 'confidence': 0.09}
# point: Cha Zhao Dao De Dian
# rectangle: Mu Biao Tu Xiang Zhou Wei Si Ge Dian De Zuo Biao
# confidence: Cha Zhao Tu Pian Pi Pei Cheng Gong De Te Zheng Dian Chu Yi Zong De Te Zheng Dian

SIFTDuo Ge Xiang Tong De Bu Fen Cha Zhao

print ac.find_all_sift(imsrc, imsch, maxcnt = 0)
# - when not found
@return []
# - when found
@return [{..}, {..}]
# {..}De Nei Rong Gen SIFTCha Zhao Dao Dan Ge Tu Xiang De Ge Shi Yi Yang

maxcntShi Ke Xuan Can Shu ,Xian Zhi Zui Duo Pi Pei De Shu Liang .

Zhi Jie Pi Pei Cha Zhao Tu Xiang

print ac.find_template(imsrc, imsch)

Qi Wang Shu Chu (Mu Biao Tu Pian De Zhong Xin Dian ,Xiang Si Du ), Xiang Si Du Shi Dian Nao Ji Suan Chu Lai De Yi Ge Zhi ,Gen Ping Chang Suo Shuo De Xiang Si 97%Bu Shi Yi Ge Yi Si . Dui Yu Zhe Ge Zhi ,Da Dao 0.999Yi Shang Cai Suan Shi Tu Pian Yi Yang .

(294, 13), 0.9715

Cha Zhao Duo Ge Xiang Tong De Tu Pian ,Ru Zai Tu Xing

Zhong Cha Zhao

print ac.find_all_template(imsrc, imsch)

Qi Wang Shu Chu (Mu Biao Tu Pian De Zhong Xin Dian ,Xiang Si Du )

[((294, 13), 0.9715), ...]

Xiao Guo

Kai Fa Gui Fan

Kai Fa Gui Fan

LICENSE

LICENCE under MIT

Some other idea. Not implemented

example

import aircv

imsrc = aircv.Image('demo.png')
imobj = aircv.Image('object.png')

print imsrc.find(imobj, method=aircv.FIND_TMPL) # or method=aircv.FIND_SIFT
# expect aircv.Position(x=10, y=20, extra={'method': aircv.FIND\_TMPL, 'result': 0.98})

print imobj.find_in(imsrc, method=aircv.FIND_TMPL)
# expect aircv.Position(x=10, y=20)

rect = aircv.Rect(left=80, top=10, width=50, height=90)
# Rect define: Rect(left=0, top=0, right=None, bottom=None, width='100%', height='100%')
pos = imsrc.find(imobj, rect=rect, method=aircv.FIND_TMPL)
print pos
# expect aircv.Position(x=10, y=20)

print imsrc.draw_point(pos) # .draw_point(pos2)
# expect aircv.Image object

print imsrc.draw_rectangle(aircv.Rect(left=80))
# expect aircv.Image object

print imsrc.draw_circle(??)

print imsrc.cv_object
# expect numpy object

imsrc.save('source.png')
# An Exception raised when file exists

print imsrc.rect() == imobj.rect()
# expect True or False

print imsrc.percent(imobj)

About

Find object position based on python-opencv2

Resources

Readme

License

MIT license

Stars

Watchers

Forks

Packages

Contributors