推广 热搜: 行业  设备  机械    系统  教师    参数  经纪  蒸汽 

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

   日期:2025-02-25     移动:http://sjzytwl.xhstdz.com/mobile/quote/89084.html

原标题:电脑控制手机 Python实现颜色识别功能

用电脑控制手机好几年了,Total Control作为安卓手机的多控系统,是我用过各方面都比较稳定的一款软件了。通过脚本实现识别颜色是其强大功能之一,之前分享了多点颜色比较的脚本示例,今天来说说如何用Total Control 提供的REST API 实现多点比较颜色,支持多色,颜色范围,相似度比较颜色。

70be2f826f834cb6bf8ce1cdd824e626.jpeg

Total Control 提供的REST API:

ed1e5d22867e4cbca4c283d2b21910fd.jpeg

请求参数

c50eea52c8554e0bacad0a9c6bbe17f7.jpeg

请求示例

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

}

77276c383f574473ae1aaed0a45d7823.jpeg

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.")

运行结果

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呢?官网直接下载就可以了,专业版还提供免费试用哦,快点下载一个试试吧

本文地址:http://sjzytwl.xhstdz.com/quote/89084.html    物流园资讯网 http://sjzytwl.xhstdz.com/ , 查看更多

特别提示:本信息由相关用户自行提供,真实性未证实,仅供参考。请谨慎采用,风险自负。


0相关评论
相关最新动态
推荐最新动态
点击排行
网站首页  |  关于我们  |  联系方式  |  使用协议  |  版权隐私  |  网站地图  |  排名推广  |  广告服务  |  积分换礼  |  网站留言  |  RSS订阅  |  违规举报  |  鄂ICP备2020018471号