日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python实现外挂自动学习网络课程实例

發布時間:2023/12/14 python 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python实现外挂自动学习网络课程实例 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

全套源碼下載地址:https://download.csdn.net/download/bvngh3247/10783804

碩士畢業后,一直從事算法工程師,具有豐富的深度學習,圖像視頻處理經驗,因此錄制了一些課程,歡迎大家觀看,有問題可以找我私聊:QQ:81664352,謝謝
基于web端的人臉識別算法視頻教程
1.掌握深度學習圖像處理(基于keras、tensorflow、opencv)
2.掌握web前后端設計(基 于flask框架)
3.開發基于web端的深度學習圖像,把web端應用與人工智能相結合
視頻教程
https://edu.csdn.net/course/detail/28400/391614?pre_view=1

聲明:只是用來學習,請不要使用非法用途,責任自負
工具

使用python 3.6版本,安裝如下庫:
安裝win32api
pip3 install pywin32
安裝PIL
pip install Pillow
安裝pyautogui
pip install pyautogui
安裝numpy
pip install numpy
安裝cv2
pip install opencv-python
安裝matplotlib
pip install matplotlib

使用SPY查看相關窗口標題, 類名。此標題唯一, 故可以以此來查找相關窗口

得到窗口句柄

window_title = '課件學習 - Google Chrome'screen_width = win32api.GetSystemMetrics(0)screen_height = win32api.GetSystemMetrics(1) hwnd = win32gui.FindWindow(win32con.NULL,window_title) if hwnd == 0 :error_exit('%s not found' % window_title)exit()else:print('hwnd = %x'%(hwnd))window_left,window_top,window_right,window_bottom = win32gui.GetWindowRect(hwnd)

主循環

原理:主要通信截圖屏幕的圖片,然后通過模板圖像與之比較,如果出現我們需要的場景,那么得到對應的位置坐標,然后自動調用點擊功能,從而實現自動化操作。那么這里主要使用opencv的兩個算法,一個是圖像相似度打分算法,另一個是圖像搜索算法。


while True:grab_image = snapshot.grab_screen(deal_left,deal_top,deal_right,deal_bottom)#grab_image.show()grab_image.save(r'.\tmp_output\full_screen.png')#big pic size = 1936x1056full_screen_w = 1936full_screen_h = 1056pixel_core_x = 877.0pixel_core_y = 25.0deal_left = window_left #window_left + kejian_x / full_screen_w * window_width - 100deal_top = window_top + pixel_core_y / full_screen_h * window_height - 20deal_right = window_left + window_width#window_left + kejian_x / full_screen_w * window_width + 150 deal_bottom = window_top + pixel_core_y / full_screen_h * window_height + 20grab_image = snapshot.grab_screen(deal_left,deal_top,deal_right,deal_bottom)search_pic = r'.\tmp_output\search_kejianxuexi.png' grab_image.save(search_pic)#find kejian_temtemplate_pic = r'.\template\kejian_tem.png'num, w, h, pos_list = match.lookup_pos(template_pic, search_pic)left = 0top = 0find_kejian_flag = 0no_voice_flag = 0if num == 1:left = pos_list[0][0]top = pos_list[0][1]find_kejian_flag = 1else:print('==========warning search_kejianxuexi = ' + str(num))find_kejian_flag = 0if find_kejian_flag:img_rgb = cv2.imread(search_pic)img_rgb = img_rgb[top:top + h, left:left + w + 80, :] # h, w, ccompare_pic = r'.\tmp_output\kejianxuexi_compare.png'cv2.imwrite(compare_pic, img_rgb)temp_voice = r'.\template\kejianhua_tem_voice.png'temp_no_voice = r'.\template\kejianhua_tem_no_voice.png'no_voice_flag = match.score_pic(compare_pic, temp_voice, temp_no_voice)if no_voice_flag:print('===============find no_voice_flag')find_question_flag = find_question()if find_question_flag:#secondtime.sleep(5)find_daan()time.sleep(5)find_quding()find_chongbo_flag = find_chong_bo()if find_question_flag and find_chongbo_flag:print('========>find_chongbo_flag and find_chongbo_flag')exit()if find_chongbo_flag:weikaishi() else:print('===============every thing is ok')time.sleep(2) #exit(0)

圖像相似度打分算法

那么如何判斷一張被PS過的圖片是否與另一張圖片本質上相同呢?比較簡單、易用的解決方案是采用感知哈希算法(Perceptual Hash Algorithm)。
感知哈希算法是一類算法的總稱,包括aHash、pHash、dHash。顧名思義,感知哈希不是以嚴格的方式計算Hash值,而是以更加相對的方式計算哈希值,因為“相似”與否,就是一種相對的判定。

aHash:平均值哈希。速度比較快,但是常常不太精確。
pHash:感知哈希。精確度比較高,但是速度方面較差一些。
dHash:差異值哈希。Amazing!精確度較高,且速度也非常快。因此我就選擇了dHash作為我圖片判重的def

pHash(imgfile):"""get image pHash value"""#加載并調整圖片為32x32灰度圖片img=cv2.imread(imgfile, 0) img=cv2.resize(img,(64,64),interpolation=cv2.INTER_CUBIC)#創建二維列表h, w = img.shape[:2]vis0 = np.zeros((h,w), np.float32)vis0[:h,:w] = img #填充數據#二維Dct變換vis1 = cv2.dct(cv2.dct(vis0))#cv.SaveImage('a.jpg',cv.fromarray(vis0)) #保存圖片vis1.resize(32,32)#把二維list變成一維listimg_list=(vis1.tolist())print('----------')sum(img_list)#計算均值avg = sum(img_list)/(len(img_list)*1.0)print('----------')avg_list = ['0' if i<avg else '1' for i in img_list]#得到哈希值return ''.join(['%x' % int(''.join(avg_list[x:x+4]),2) for x in range(0,32*32,4)])def hammingDist(s1, s2):assert len(s1) == len(s2)return sum([ch1 != ch2 for ch1, ch2 in zip(s1, s2)])def aHash(img):#縮放為8*8img=cv2.resize(img,(8,8),interpolation=cv2.INTER_CUBIC)#轉換為灰度圖gray=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)#s為像素和初值為0,hash_str為hash值初值為''s=0hash_str=''#遍歷累加求像素和for i in range(8):for j in range(8):s=s+gray[i,j]#求平均灰度avg=s/64#灰度大于平均值為1相反為0生成圖片的hash值for i in range(8):for j in range(8):if gray[i,j]>avg:hash_str=hash_str+'1'else:hash_str=hash_str+'0'return hash_strdef cmpHash(hash1,hash2):n=0#hash長度不同則返回-1代表傳參出錯if len(hash1)!=len(hash2):return -1#遍歷判斷for i in range(len(hash1)):#不相等則n計數+1,n最終為相似度if hash1[i]!=hash2[i]:n=n+1return 1 - n / 64def score_pic(compare_pic, temp_voice, temp_no_voice):#HASH1=pHash(compare_pic)#HASH2=pHash(temp_voice)#out_score = 1 - hammingDist(HASH1,HASH2)*1. / (32*32/4)img1 = cv2.imread(compare_pic)img2 = cv2.imread(temp_voice)img3 = cv2.imread(temp_no_voice)#time1 = time.time()hash1 = aHash(img1)hash2 = aHash(img2)voice_score = cmpHash(hash1, hash2)hash1 = aHash(img1)hash3 = aHash(img3)no_voice_score = cmpHash(hash1, hash3)no_voice_flag = 0#print(str(voice_score) + '=>' + str(no_voice_score))if no_voice_score >= voice_score:no_voice_flag = 1else:no_voice_flag = 0return no_voice_flag

圖像搜索算法

使用res = cv2.matchTemplate(img_gray,template,cv2.TM_CCOEFF_NORMED)

def lookup_pos(template_pic, search_pic):img_rgb = cv2.imread(search_pic)img_gray = cv2.cvtColor(img_rgb, cv2.COLOR_BGR2GRAY)img = img_gray#print(img.shape)template = cv2.imread(template_pic,0)w, h = template.shape[::-1]res = cv2.matchTemplate(img,template,cv2.TM_CCOEFF_NORMED)threshold = 0.95loc = np.where( res >= threshold)num = 0left = 0top = 0pos_list = []for pt in zip(*loc[::-1]):cv2.rectangle(img_rgb, pt, (pt[0] + w, pt[1] + h), (0,0,255), 2)left = pt[0]top = pt[1]pos_list.append(pt)num = num + 1res = res*256cv2.imwrite(r'.\tmp_output\out.png', img_rgb)cv2.imwrite(r'.\tmp_output\res.png', res)return num, w, h, pos_list

總結

以上是生活随笔為你收集整理的python实现外挂自动学习网络课程实例的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。