Share E-Book
Scan to open this page

Scan with your phone to open this page

Author: 陈宇航, 侯俊萍, 叶昶

Rating No ratings yet

树莓派是一款基于ARM架构、Linux系统的极简计算机,既可以用于计算机编程教育,也可以作为机器人的控制核心。第一种运行于树莓派上的编程语言是Python,这是当前人工智能领域最为流行的编程语言。机器视觉是人工智能中重要的细分研究领域,OpenCV则是当前机器视觉领域主流的开源处理库,可以方便地用于计算机图像处理,并应用于面部识别、目标识别等具体问题。本书介绍在树莓派硬件上使用Python语言,借助OpenCV库编程,来实现具有机器视觉功能(识别和抓取特定颜色物体、识别人脸、识别特定人脸、进行面部跟踪)的智能机器人。 《人工智能+机器人入门与实战》力求通过一系列不同层次的软硬件任务,由浅入深地讲解人工智能的概念,同时覆盖Linux系统操作、Python编程、机器人系统搭建等多方面的综合知识。在本书案例中使用的主要硬件载体是可在桌面上固定运转的双轴云台和三轴机械臂等,它们可以代表一类智能机器人的形态。本书遵循开源、分享的创客精神,所有的硬件材料和软件内容均可以从公共平台获取,读者在充分理解的基础上,不必局限于本书所列硬件,可自行获取类似设备完成项目。 本书可以作为中小学STEAM人工智能教育的一本基础读物,也可以作为中高职院校相关专业学生的参考书。

AI Reading Assistant

Whole-book reading guide from stratified index samples; jump to passages in the text

AI guide
【One-Line Pitch】 A hands-on, project-driven introduction to building computer-vision robots with Raspberry Pi, Python, and OpenCV—ideal for STEAM educators, hobbyists, and students who want to learn AI by making things move, see, and react. 【Book Arc】 - **Opening (~0%–4%)**: Introduces the book’s mission—using Raspberry Pi, Python, and OpenCV to teach AI through practical robotics—and outlines the 7-chapter structure, from Linux basics to vision-guided robot projects. - **Early (~4%–16%)**: Covers Raspberry Pi 3B+ hardware setup, Linux fundamentals (Raspbian), and why Python is the go-to language for AI, including its readability, simplicity, and rich ecosystem. - **Early (~16%–28%)**: Dives into Python programming essentials—variables, data types, conditionals, loops, functions—and then connects code to hardware via GPIO, with projects like blinking LEDs, button-controlled lights, and a two-player quiz buzzer. - **Middle (~32%–44%)**: Shifts to computer vision: how cameras and pixels work, OpenCV basics, HSV color space, image binarization, contour detection, and drawing on frames—culminating in a “magic wand” color-tracking project. - **Middle (~44%–52%)**: Introduces the three-axis robotic arm, servo motors, and a vacuum suction gripper; explains serial communication and how to control the arm from Raspberry Pi, including positioning the arm to align with detected objects. - **Late (~52%–end)**: Combines vision and motion: using camera feedback to locate colored blocks, adjusting servo angles to center objects, and maintaining arm height for accurate pickup—plus face detection and tracking projects on a two-axis gimbal (excerpts cover the sorting task in detail). 【Key Takeaways】 - **Raspberry Pi is a full computer plus a robot brain** (Early): It runs Linux, has USB/HDMI/Wi-Fi, and adds 40 GPIO pins for direct hardware control—making it ideal for both learning programming and driving robots. - **Python’s simplicity is its superpower** (Early): A “Hello World” takes one line versus many in C#; its clean syntax, auto-typed variables, and huge library ecosystem (NumPy, TensorFlow) make it the default for AI education. - **GPIO projects teach real input/output logic** (Early): Using RPi.GPIO, you can read buttons and drive LEDs; combining conditions with `and`/`or`/`not` and adding randomness with `randint` turns simple circuits into games like a quiz buzzer. - **HSV beats RGB for color detection** (Middle): RGB values shift wildly with lighting, but HSV (Hue, Saturation, Value) matches human perception—so you can reliably isolate a color range and binarize an image with `inRange`. - **Contours turn pixels into positions** (Middle): After binarization, `findContours` extracts object outlines; using `RETR_EXTERNAL` and `CHAIN_APPROX_SIMPLE` gives corner points, from which you can compute a center and draw markers with `circle`. - **Servo control is the key to robot motion** (Middle): Digital servos act like joints; PWM values (500–2500) map to 0°–180°, and the `roboticarm` package simplifies sending serial commands to the control board. - **Vision-guided pickup is a calibration problem** (Late): By fixing the arm’s height and knowing the target’s expected image coordinates (e.g., 320, 150), you can iteratively adjust servos to center the object—first left/right, then forward/back—for reliable grasping. - **Geometry simplifies complex arm control** (Late): Parallel-link structures keep the gripper parallel to the table, and prebuilt functions like `get_angle` compute servo PWM values from desired height and distance, avoiding manual inverse kinematics. 【Reading Tips】 - **Skim the Linux and hardware setup chapters** if you’ve used Raspberry Pi before; focus instead on the GPIO wiring diagrams and the exact pin numbers used in later projects. - **Deep-read the Python chapter** if you’re new to coding—variables, conditionals, loops, and functions are all reused heavily; the “try it” exercises (like building a calculator) are worth doing. - **Pay extra attention to the HSV color section** (Chapter 5): it’s the foundation for all vision tasks. Use the Geany color picker to find your own HSV ranges, and test with different lighting. - **Treat the robotic arm chapter as a step-by-step lab**: first control servos manually, then add camera feedback. The calibration steps (finding the target coordinates) are the trickiest—run the experiments as described rather than skipping ahead. - **Don’t worry about the math in the arm geometry** if it feels heavy; the book provides `get_angle` to handle it. Skim the parallelogram proof and focus on the practical control loops. 【Coverage Limits】 This guide is based on excerpts covering roughly the first half to two-thirds of the book (through the robotic arm sorting project). Face detection and face-tracking projects from the final chapter are mentioned in the book’s overview but not detailed in the available material.
Page 6
要聚焦于在树莓派平台上使 用Python 语言调用OpenCV库实现机器视觉的任务。全书内容共分为 7章,前 4章为树 莓派与Python 编程基础知识部分,第 1章介绍人工智能与机器人的基本概念,第 2章则 介绍树莓派主板与操作系统使用方法,第 3章为简单的 Python 编程入门学习内容,第 4 章介绍 Py...
View in text
Excerpt 2
字符串“Hello World”。 虽然我们在对变量赋值时并不需要指定它存储的数据的类型,但Python 在首次对一个 变量赋值时会根据我们设定的初始值来自动为变量分配一个合适的数据类型。 不过,某些程序功能要求特定的数据类型,如果输入的数据类型不符合要求,可能导致 程序错误。举例来说,Python 中使用 in...
View in text
Excerpt 3
.indd 42 2020/3/9 15:28:58 第 5 章 机 器 视 觉 入 门 P1-132人工智能.indd 45 2020/3/9 15:28:58 第 5 章 机器视觉入门 图 5.3  传统彩色照相机的显像原理 现代的数码相机则稍有不同,它不再依赖于特定的化学物质,而是通过电子感光单元将 接收到...
View in text
Excerpt 4
机通过舵机控制板控制机械臂的运动。现在,为了使 用树莓派调用摄像头执行智能任务,我们需要先了解树莓派控制机械臂的方法。 机械臂的舵机控制板可以接收串行通信信号,我们可以通过树莓派发送串行通信信号 来控制它。 74 P1-132人工智能.indd 74 2020/3/9 15:29:11 人工智能+机器人入门与实战...
View in text
Excerpt 5
来的,并会随着人的成长逐渐变强。实际上,人工智能系统同样可以通过对既有事实 的分析和学习掌握新的技能,这被称为机器学习。在人脸识别的例子中,机器学习是一种有 效的方法。   7.2    使用肤色检测找到人脸 在检测人脸的多种方法中,最直接、简单的方法是通过肤色识别确定人脸的位置,这种 方法被称为肤色检测。在此前...
View in text
Excerpt 6
计时可以借助 time 扩展包中的 time 函数实现。该函数将返回自 1970 年 1月 1日至当前时刻经历的秒数。 get_face = False # 定义一个变量用于表示当前是否找到人脸 if len(faces) > 0: # 如果寻找到人脸 get_face = True # 改变 get_face...
View in text
Excerpt 7
55) mask = cv2.inRange(hsv, yellow_lower, yellow_upper) (mask, cnts, hierarchy) = cv2.findContours(mask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) if len(c...
View in text
Excerpt 8
age, cv2.COLOR_BGR2RGB) my_face_encoding = face_recognition.face_encodings(my_image) 141 P1-132人工智能.indd 141 2020/3/9 15:29:48 爱 爱上机器人 上 爱上机器人 机 器 人 Robot: m...
View in text
Tags
AI categories
Artificial IntelligencePython
Publish Year: 2020
Language: English
Pages: 143
File Format: PDF
File Size: 4.3 MB
Text Preview (First 20 pages)
Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Generating text preview…