Figure 1 -
- Ozeki Sniffer: http://www.ozeki.hu/index.php?owpn=6204
- Ozeki 10 installed: http://www.ozeki.hu/index.php?owpn=6066
- Lego connection installed: http://www.ozeki.hu/index.php?owpn=6067
- Snap basics: http://www.ozeki.hu/index.php?owpn=6180
Install face detection connection
In Ozeki 10 platform, you can use USB camera as a face detect camera, plug in to your PC. In the Control Panel you have to create a new connection. Click on the 'Create new conncetion' button and select the Video option. After that, choose the 'Vision' connection, so just select the Face camera connection. Lastly, you can settings the camera, the resolution and the framerate.
Figure 2 - Create the connection
You need to make a route connection to SNAP to get all information about the Face detect camera. So, select the Routes menu and click on the 'Create new Route' button and specify the information is come from the face detector connection to SNAP as you can see it on Figure 3 below.
Figure 3 - Create a route
Firstly, add the 'when green flag clicked' entry point from the Control menu. The most important thing is set the camera to detect face, so subscribe the face detector with using the 'Subscribe' block from the Ozeki menu and select the face detector camera. Then to wait for messages from the camera, add the 'Get next message' block. After that, store that message with the 'Set 'message' to message value (string)'. This is demonstrate in the Figure 4 below.
Figure 4 - Wait to the message
Modify your program to start the robot
You have to start the robot, so put the 'Start motor [motors] at [speed]%' block from the Lego motors menu between Subscribe and Get next message blocks. Select the A+D motors and set the motor speed to '10'. Now, robot goes forward until get information about the face recognize camera.
Figure 5 - Start the robot
Stop the robot and raise the robot's arm if the face is detected
If the camera is detected face, the robot stop moving and raise the arm, so add the 'Stop motor' block from the Lego motors menu and select the A+D motors. Then the robot stop moving. You have to add the 'Rotate [motor] by [degree]' block from the Lego motors menu, where select the 'B' motor and set the robot's arm degree to 180 as you can see it on Figure 5 below.
Figure 6 - Stop the robot
Display smile, set the Led to flahing and play some notes
Finally, drag 'Display on LCD' block from the Lego menu to the program and choose the smiley character. You have to set the LED flashing with green colour, so add the 'Set LED' block from the Lego menu and choose the green flashing option. After that, Add 3 'Play notes' blocks from the Lego menu and set them as you can see it on the Figure 6 below.
Figure 7 - It is happy to see you
Figure 8 -
This program code is a Face detect code |
You can watch the code work in the lecture starter video
It places the rocks depending on the Face detect codes
Download the Face detect program code
- Introduction to visual sensors
- Introduction to cameras, taking snapshots
- Barcode recognition / build a cash register
- Computer vision, QR code recognition
- Motion detection
- Circle detection, line detection, measurements using cameras
- Car license plate recognition
- Build a PTZ camera
- Use a VR headset to control your camera