笔记.机器人

##3.连续动作
import YanAPI
YanAPI.yan_api_init("127.0.0.1")
motion_list=YanAPI.get_motion_list_value()
YanAPI.sync_play_motion(name="挥挥右手", speed="fast", repeat=2)
##4.传感系统
#红外线传感器
import YanAPI
ip_add='127.0.0.1'
YanAPI.yan_api_init(ip_add)
while True:
    res=YanAPI.get_sensors_infrared()
    print(res)
#触摸传感器
#读取机器人角度
import YanAPI
ip_add='127.0.0.1'
YanAPI.yan_api_init(ip_add)
res=YanAPI.get_sensors_gyro()
#print(res)
if len(res)>0:
    print('\n detect gyro value:')
    print(res['data']['gyro'][0])
#摔倒检测并爬起
import YanAPI
ip_add='127.0.0.1'
YanAPI.yan_api_init(ip_add)
res=YanAPI.get_sensors_gyro()
while True:
    res=YanAPI.get_sensors_gyro()
        if  angle_x>-20 and x<20:
            print("前趴摔倒")
            YanAPI.sync_play_motion(name = "GetupFront")#恢复站立
    elif   angle_x>160 and x<-160:
            print("后趴摔倒")
            YanAPI.sync_play_motion(name = "GetupRear")#恢复站立
#生成一张照片
import cv2 #导入opencv库
import numpy as np
array1=np.zeros([400,400,3],np.uint8)#生成一个400*400*3的0矩阵  0黑色    
array2=np.random.randint(0,255,(400,300,1),dtype='uint8')#随机矩阵 0-255的随机值
cv2.imshow('img',array1)#显示矩阵
cv2.waitKey()
#图片读取 ,读取模式:1:彩色图读取 0:灰度图读取 -1:alpha通道加载
cv2.imwrite("lujing"bianliang)#保存照片
img_bgr.shape#查看属性    (500,750,3)500*750 3通道
#获取宽和高   img_bgr.shape[0:2]
#缩小2倍
x,y=img_bgr.shape[0:2]
img_1_2=img_bar.copy()
img_1_2=cv2.resize(img_bgr,(int(y/2),int(x/2)))
#旋转flip函数  (0:沿x轴旋转,1:沿y轴旋转  -1:沿x轴和y轴同时旋转)
img_x=img_1_2.copy()
img_x=cv2.flip(img_1_2,0)
#imread() 彩色图像转灰度图像 灰度图像本质上是二维矩阵,彩色图像本质上是三维矩阵 原理是彩色照片的B,G,R.通道以一定的权重组合进行加法运算
img_gray=cv2.imread(path,0)#读取灰度照片
img_bgr=cv2.imread(path,1)#读取彩色照片
#转换
r,g,b=cv2.split(img_bgr)
img_gray2=0.299*r+0.587*g+0.114*b
img_gray2=img_gray2.astype('uint8') 
#轮廓检测
gray=cv2.cvtColor(img1,cv2.COLOR_BGR2GRAY)#获取灰度照片
ret.binary=cv2.threshold(gray,210,255,cv2.THRESH_BINARY)#获取二值照片
#获取轮廓
image,coutours,hie=cv2.findContours(binary,cv2.RETR_TREE,cv2.CHAIN_APPROX_NONE)
#识别
#录入人脸  (先拍照 上传人脸样本到数据库  为图片数据打上标签)
def input_face_sample(name):
    res=YanAPI.take_vision_photo()
    print(res)
#进行人脸识别
res=YanAPI.sync_do_face_recognition_value(type: str)
#物体识别
res=YanAPI.sync_do_object_recognition()
#音频
#导入pyaudio
#初始化
voice=YanAPI.Voice()
res=start_voice_tts("shuruwenben",False)
#自然语言理解
res=voice.sync_do_voice_nlp()

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值