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

歡迎訪問 生活随笔!

生活随笔

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

python

python颜色识别原理_电脑控制手机 Python实现颜色识别功能

發(fā)布時間:2024/10/12 python 42 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python颜色识别原理_电脑控制手机 Python实现颜色识别功能 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

原標題:電腦控制手機 Python實現(xiàn)顏色識別功能

用電腦控制手機好幾年了,Total Control作為安卓手機的多控系統(tǒng),是我用過各方面都比較穩(wěn)定的一款軟件了。通過腳本實現(xiàn)識別顏色是其強大功能之一,之前分享了多點顏色比較的腳本示例,今天來說說如何用Total Control 提供的REST API 實現(xiàn)多點比較顏色,支持多色,顏色范圍,相似度比較顏色。

Total Control 提供的REST API:

請求參數(shù):

請求示例:

http://localhost:8090/TotalControl/v1/devices/device@1116106541/screen/colors/color?token=270eq7lXQK8bXYsJ&color=[[3,5,"0x000000"], [4,6,"0x000f00"], [9,225,"0xffffff"]]&sim=0.3

響應示例:

{

"value":"",

"status":true

}

Python示例:

#!/user/bin/python

#-*- coding:utf-8 -*-

import

import requests

# The username and password are separated by a single : and sent on the wire encoded

user_pass = 'sigma:3D391497'

encodeStr = .b64encode(user_pass.encode("UTF-8"))

# First step: Get the API token

LoginUrl = "http://localhost:8090/TotalControl/v1/login"

response = requests.get(LoginUrl, headers={'Authorization':encodeStr})

print("Get the token,Return value: ",response.json())

token = response.json()['value']['token']

print("The value of token is: ",token)

# Second step: Get the device id value of the master device

if token is not None:

GetDeviceUrl = "http://localhost:8090/TotalControl/v1/devices/main?token=" + token

response = requests.get(url=GetDeviceUrl)

print("Get the device id,Return value: ", response.json())

device = response.json()['id']

print("The value of device id is: ", device)

if device is not None:

# Third step: Execute this REST API

APIUrl = "http://localhost:8090/TotalControl/v1/devices/" + device + "/screen/colors/color"

data = {

"color": "[[200,500,'0xffffff|0xaabbcc-0x000000'], [200,400,'0x000f00'], [200,225,'0xffffff']]",

"sim": 0.8,

"token": token

}

response = requests.get(url=APIUrl, params=data)

ret = response.json()['status']

# Determine if this REST API is executed successfully

if ret is True:

print("Executed successfully,Return value: ", response.json())

elif response.status_code == 200 and ret is not True:

print("An error message is returned: ",response.json())

else:

print("This API failed to execute.")

else:

print("Failed to get device id.")

else:

print("Failed to get token.")

運行結(jié)果:

Get the token,Return value: {'status': True, 'value': {'token': 'lo7ssQ12KgkM6ik7'}}

The value of token is: lo7ssQ12KgkM6ik7

Get the device id,Return value: {'id': 'device@33254183'}

The value of device id is: device@33254183

Executed successfully,Return value: {'status': True, 'value': ''}

要怎樣擁有Total Control呢?官網(wǎng)直接下載就可以了,專業(yè)版還提供免費試用哦,快點下載一個試試吧!

責任編輯:

總結(jié)

以上是生活随笔為你收集整理的python颜色识别原理_电脑控制手机 Python实现颜色识别功能的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。