关于机器人感知-视觉部分,有过一次公开分享,讲稿全文和视屏实录,参考如下CSDN链接:

机器人感知-视觉部分(Robotic Perception-Vision Section):

https://blog.csdn.net/ZhangRelay/article/details/81352622


Cozmo视觉Vision也可以完成很多功能,宠物、方块、人脸等识别和跟踪等,非常有趣。

中文

英文

这就是教程tutorials中第三部分vision中的内容。


1. light when face

当检测到人脸在图像中识别并点亮cozmo背部的LED灯。

#!/usr/bin/env python3# Copyright (c) 2016 Anki, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License in the file LICENSE.txt or at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.'''Wait for Cozmo to see a face, and then turn on his backpack light.This is a script to show off faces, and how they are easy to use.
It waits for a face, and then will light up his backpack when that face is visible.
'''import asyncio
import timeimport cozmodef light_when_face(robot: cozmo.robot.Robot):'''The core of the light_when_face program'''# Move lift down and tilt the head uprobot.move_lift(-3)robot.set_head_angle(cozmo.robot.MAX_HEAD_ANGLE).wait_for_completed()face = Noneprint("Press CTRL-C to quit")while True:if face and face.is_visible:robot.set_all_backpack_lights(cozmo.lights.blue_light)else:robot.set_backpack_lights_off()# Wait until we we can see another facetry:face = robot.world.wait_for_observed_face(timeout=30)except asyncio.TimeoutError:print("Didn't find a face.")returntime.sleep(.1)cozmo.run_program(light_when_face, use_viewer=True, force_viewer_on_top=True)

2. face follower

识别人脸并跟随,控制头部角度和履带运动调整是人脸处于采集图像的中间位置(x,y两轴)。

#!/usr/bin/env python3# Copyright (c) 2016 Anki, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License in the file LICENSE.txt or at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.'''Make Cozmo turn toward a face.This script shows off the turn_towards_face action. It will wait for a face
and then constantly turn towards it to keep it in frame.
'''import asyncio
import timeimport cozmodef follow_faces(robot: cozmo.robot.Robot):'''The core of the follow_faces program'''# Move lift down and tilt the head uprobot.move_lift(-3)robot.set_head_angle(cozmo.robot.MAX_HEAD_ANGLE).wait_for_completed()face_to_follow = Noneprint("Press CTRL-C to quit")while True:turn_action = Noneif face_to_follow:# start turning towards the faceturn_action = robot.turn_towards_face(face_to_follow)if not (face_to_follow and face_to_follow.is_visible):# find a visible face, timeout if nothing found after a short whiletry:face_to_follow = robot.world.wait_for_observed_face(timeout=30)except asyncio.TimeoutError:print("Didn't find a face - exiting!")returnif turn_action:# Complete the turn action if one was in progressturn_action.wait_for_completed()time.sleep(.1)cozmo.run_program(follow_faces, use_viewer=True, force_viewer_on_top=True)

3. annotate

此示例使用tkviewer在屏幕上显示带注释的摄像头图像并使用两种不同的方法添加了一些自己的自定义注释。

#!/usr/bin/env python3# Copyright (c) 2016 Anki, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License in the file LICENSE.txt or at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.'''Display a GUI window showing an annotated camera view.Note:This example requires Python to have Tkinter installed to display the GUI.It also requires the Pillow and numpy python packages to be pip installed.The :class:`cozmo.world.World` object collects raw images from Cozmo's camera
and makes them available as a property (:attr:`~cozmo.world.World.latest_image`)
and by generating :class:`cozmo.world.EvtNewCamerImages` events as they come in.Each image is an instance of :class:`cozmo.world.CameraImage` which provides
access both to the raw camera image, and to a scalable annotated image which
can show where Cozmo sees faces and objects, along with any other information
your program may wish to display.This example uses the tkviewer to display the annotated camera on the screen
and adds a couple of custom annotations of its own using two different methods.
'''import sys
import timetry:from PIL import ImageDraw, ImageFont
except ImportError:sys.exit('run `pip3 install --user Pillow numpy` to run this example')import cozmo# Define an annotator using the annotator decorator
@cozmo.annotate.annotator
def clock(image, scale, annotator=None, world=None, **kw):d = ImageDraw.Draw(image)bounds = (0, 0, image.width, image.height)text = cozmo.annotate.ImageText(time.strftime("%H:%m:%S"),position=cozmo.annotate.TOP_LEFT)text.render(d, bounds)# Define another decorator as a subclass of Annotator
class Battery(cozmo.annotate.Annotator):def apply(self, image, scale):d = ImageDraw.Draw(image)bounds = (0, 0, image.width, image.height)batt = self.world.robot.battery_voltagetext = cozmo.annotate.ImageText('BATT %.1fv' % batt, color='green')text.render(d, bounds)def cozmo_program(robot: cozmo.robot.Robot):robot.world.image_annotator.add_static_text('text', 'Coz-Cam', position=cozmo.annotate.TOP_RIGHT)robot.world.image_annotator.add_annotator('clock', clock)robot.world.image_annotator.add_annotator('battery', Battery)time.sleep(2)print("Turning off all annotations for 2 seconds")robot.world.image_annotator.annotation_enabled = Falsetime.sleep(2)print('Re-enabling all annotations')robot.world.image_annotator.annotation_enabled = True# Disable the face annotator after 10 secondstime.sleep(10)print("Disabling face annotations (light cubes still annotated)")robot.world.image_annotator.disable_annotator('faces')# Shutdown the program after 100 secondstime.sleep(100)cozmo.run_program(cozmo_program, use_viewer=True, force_viewer_on_top=True)

4. exposure

此示例演示了使用自动曝光和手动曝光Cozmo的摄像头图像。当前的摄像头设置会叠加到PC上查看器窗口。

#!/usr/bin/env python3# Copyright (c) 2017 Anki, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License in the file LICENSE.txt or at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.'''Demonstrate the manual and auto exposure settings of Cozmo's camera.This example demonstrates the use of auto exposure and manual exposure for
Cozmo's camera. The current camera settings are overlayed onto the camera
viewer window.
'''import sys
import timetry:from PIL import ImageDraw, ImageFontimport numpy as np
except ImportError:sys.exit('run `pip3 install --user Pillow numpy` to run this example')import cozmo# A global string value to display in the camera viewer window to make it more
# obvious what the example program is currently doing.
example_mode = ""# An annotator for live-display of all of the camera info on top of the camera
# viewer window.
@cozmo.annotate.annotator
def camera_info(image, scale, annotator=None, world=None, **kw):d = ImageDraw.Draw(image)bounds = [3, 0, image.width, image.height]camera = world.robot.cameratext_to_display = "Example Mode: " + example_mode + "\n\n"text_to_display += "Fixed Camera Settings (Calibrated for this Robot):\n\n"text_to_display += 'focal_length: %s\n' % camera.config.focal_lengthtext_to_display += 'center: %s\n' % camera.config.centertext_to_display += 'fov: <%.3f, %.3f> degrees\n' % (camera.config.fov_x.degrees,camera.config.fov_y.degrees)text_to_display += "\n"text_to_display += "Valid exposure and gain ranges:\n\n"text_to_display += 'exposure: %s..%s\n' % (camera.config.min_exposure_time_ms,camera.config.max_exposure_time_ms)text_to_display += 'gain: %.3f..%.3f\n' % (camera.config.min_gain,camera.config.max_gain)text_to_display += "\n"text_to_display += "Current settings:\n\n"text_to_display += 'Auto Exposure Enabled: %s\n' % camera.is_auto_exposure_enabledtext_to_display += 'Exposure: %s ms\n' % camera.exposure_mstext_to_display += 'Gain: %.3f\n' % camera.gaincolor_mode_str = "Color" if camera.color_image_enabled else "Grayscale"text_to_display += 'Color Mode: %s\n' % color_mode_strtext = cozmo.annotate.ImageText(text_to_display,position=cozmo.annotate.TOP_LEFT,line_spacing=2,color="white",outline_color="black", full_outline=True)text.render(d, bounds)def demo_camera_exposure(robot: cozmo.robot.Robot):global example_mode# Ensure camera is in auto exposure mode and demonstrate auto exposure for 5 secondscamera = robot.cameracamera.enable_auto_exposure()example_mode = "Auto Exposure"time.sleep(5)# Demonstrate manual exposure, linearly increasing the exposure time, while# keeping the gain fixed at a medium value.example_mode = "Manual Exposure - Increasing Exposure, Fixed Gain"fixed_gain = (camera.config.min_gain + camera.config.max_gain) * 0.5for exposure in range(camera.config.min_exposure_time_ms, camera.config.max_exposure_time_ms+1, 1):camera.set_manual_exposure(exposure, fixed_gain)time.sleep(0.1)# Demonstrate manual exposure, linearly increasing the gain, while keeping# the exposure fixed at a relatively low value.example_mode = "Manual Exposure - Increasing Gain, Fixed Exposure"fixed_exposure_ms = 10for gain in np.arange(camera.config.min_gain, camera.config.max_gain, 0.05):camera.set_manual_exposure(fixed_exposure_ms, gain)time.sleep(0.1)# Switch back to auto exposure, demo for a final 5 seconds and then returncamera.enable_auto_exposure()example_mode = "Mode: Auto Exposure"time.sleep(5)def cozmo_program(robot: cozmo.robot.Robot):robot.world.image_annotator.add_annotator('camera_info', camera_info)# Demo with default grayscale camera imagesrobot.camera.color_image_enabled = Falsedemo_camera_exposure(robot)# Demo with color camera imagesrobot.camera.color_image_enabled = Truedemo_camera_exposure(robot)cozmo.robot.Robot.drive_off_charger_on_connect = False  # Cozmo can stay on his charger for this example
cozmo.run_program(cozmo_program, use_viewer=True, force_viewer_on_top=True)

Fin


Cozmo人工智能机器人SDK使用笔记(3)-视觉部分vision相关推荐

  1. Cozmo人工智能机器人SDK使用笔记(1)-基础部分basics

    APP和SDK有对应关系 如(3.0.0和1.4.6)或(3.1.0和1.4.7).不严格对应,无法正常使用SDK. cozmosdk.anki.com/docs/ Cozmo SDK经常更新,以便提 ...

  2. Cozmo人工智能机器人SDK使用笔记(4)-任务部分cubes_and_objects

    先简单总结一下使用笔记1-3: 基础部分介绍了一些常用功能,比如运动控制.LED显示和扬声器交互等 人机接口显示部分--输出,cozmo面部显示屏输出一些基本信息 人机接口视觉部分--输入,cozmo ...

  3. Cozmo人工智能机器人SDK使用笔记(2)-显示部分face

    这篇博文针对SDK教程中的第二部分cozmo_face进行简单介绍,如下: face是cozmo显示的核心部分: 来学习一下,如何操作吧- 分为3个文件,如上图所示. 1. face image co ...

  4. Cozmo人工智能机器人SDK使用笔记(6)-并行部分Parallel_Action

    Cozmo并行动作示例. 此示例演示如何并行(而不是按顺序)执行动作. import sys import timetry:from PIL import Image except ImportErr ...

  5. Cozmo人工智能机器人SDK使用笔记(5)-时序部分async_sync

    Cozmo首先寻找一个立方体. 找到立方体后,立方体的灯以循环方式绿色闪烁,然后等待轻敲立方体. 此时,程序分别为同步和异步两种类型,注意区分. 1. 同步 立方体闪烁同步示例 import asyn ...

  6. Vector人工智能机器人SDK使用笔记

    Cozmo是2016年推出的,2两年后的2018年Vector上市,具备语音助手和更多功能,元件数由300+升级到700+. Vector的SDK具体说明在:developer.anki.com/ve ...

  7. ROS2GO之手机连接Cozmo人工智能机器人玩具

    ROS2GO之手机连接Cozmo人工智能机器人玩具 参考anki的开发者页面,硬件基础: 1. Cozmo机器人:: 2. 兼容Cozmo APP的手机或平板:: 3. 运行Windows.MacOS ...

  8. Cozmo人工智能机器人玩具/教具完整版中文说明书和介绍(附应用下载链接)

    Cozmo(Anki)人工智能AI机器人Robot完整版中文说明书和介绍 (附应用下载链接)https://download.csdn.net/download/zhangrelay/10854427 ...

  9. 曾推出Anki Drive和Cozmo人工智能机器人的独角兽企业Anki谢幕

    Anki DRIVE | 极客东东 听说 Anki 出事了,即将在未来的一周关闭,公司近200名员工将获得一周薪酬补偿.很遗憾这家小林很欣赏的初创公司,前后融资多达2亿美元,其实他们已经很有钱了,但却 ...

最新文章

  1. python knn-基于python实现KNN分类算法
  2. Java面试题 22 牛客 Java是一门支持反射的语言,基于反射为Java提供了丰富的动态性支持
  3. 【kafka】produce response correlation id xxx on topic-partition retrying Error: NETWORK_EXCEPTION
  4. PC端编辑 但能在PC端模拟移动端预览的富文本编辑器
  5. iOS 给测试人员测试手机APP的四种方法:真机运行(略),打ipa包,(testFlighe)邮件,蒲公英(一)打ipa包
  6. educoder 软件工程导论 结构化分析方法-数据流图
  7. 各种音视频编解码学习详解
  8. burp抓取APP数据包+安装Xposed+Just TrustMe
  9. Excel技能培训之十 选择性粘贴,单元格公式转换为数值,对每个单元格进行运算,行列转换,只粘贴非空值
  10. 你想要的WinForm界面开发教程在这里 - 如何使用自定义用户控件
  11. 《现代密码学教程》| 谷利泽 | 课后答案 | 个人整理
  12. 网页动态效果——随鼠标移动的动态触击式线条
  13. php-fpm status,使用php-fpm状态页观察当前的php-fpm状态
  14. 关于谷歌浏览器崩溃,打不开页面
  15. 前端-element-ui
  16. 如何网上打印广州市个人社保缴纳证明
  17. 电大计算机c语言形考作业,(2017年电大)c语言形成性考核册.doc
  18. Ubuntu 18.04安装搜狗输入法笔记
  19. idea打开接口实现类快捷键
  20. pod定义和pod的配置

热门文章

  1. c语言绝对值题目,初中数学绝对值的练习题(整理)
  2. 简单的英语四级作文可能用到的句子
  3. 诺华创血小板减少症新药纳入新版国家医保目录
  4. python小城市创业好项目_在小城市适合的创业好项目
  5. 常见病毒☆常见问题☆常用方法
  6. 大数据技术的原理是什么
  7. 【ROS】Android开发环境搭建
  8. iOS 13 navigationBar的背景色失效
  9. 聚焦 | 电力行业国产操作系统迎来大市场,麒麟信安积极承接发展新机遇
  10. java如何集成百度地图