Practical work Camera programming

Page 1

EDUCATION IN ARTIFICIAL INTELLIGENCE CAMERA PROGRAMMING

INTRODUCTION KNOWLEDGE REQUIREMENTS → o ��ℎ������ ����/��������/�������� o → MATERIALS → → →

HANDLING THE ROBOT Testing the alphai library to control the robot alphai.py pip install alphai api from alphai import * motor(30, 30, 5) motor(30,alphai 30, 5) motor(left, right, duration) left right duration motor alphai alphai

Connecting to the AlphAI robot → → → connect_bluetooth(n) connect_wifi() disconnect() from alphai import disconnect()motor(30,connect_bluetooth(n)*30,5)

NAVIGATION WITH ULTRA SOUND Discovery of the ultra-sound sensor set_distance(True)get_distance() None set_distance(True)connect_bluetooth(n)# activate the ultrasound sensor while True: d = get_distance() # get the distance measured by the sensor print("distance:", d) Autonomous movement with ultra sound get_distance() ultrasound_race() NAVIGATION WITH THE CAMERA Discovering the camera image bluetooth_connect(n)

set_camera("8x6") get_camera() List[List[List[int]]] image image[i, j, k] set_camerabluetooth_connect(n)("8x6")#set the camera to the correct resolution whileimageTrue:= get_camera() # get the camera image print('red', image[0, 7, 0], 'green', image[0, 7, 1], 'blue', image[0, 7, 2])

First autonomous movement with the camera camera_race() image[4, 3, 0] < 100 → image[4, 3, 1] < 100 → → Autonomous robot improvements and racing

Appendix: alphai library API ����������������������ℎ ��������() → �������� �������������������� ����������������ℎ(���������� ����������:������)→�������� �������������������� ��������()→�������� ��������������������������() ���������� ������������������()→�������� ����������������(��������,������ℎ��,����������������) duration �������������� ������ ������()→�������� ������������ ����������������()→�������� ������������ ����������������(������������:��������) ������������ ����������������()→���������� ������������ ������������(������������:������) config 2x1 4x3 8x6 16x12 21x16 32x24 64x48 ������������ ������������()→�������� ������������ ����(��������) None all std mean ������������ ����������������()→�������� As you will have noticed, the

Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.