Take a picture of what Pepper is seeing ¶
Cannot be tested on an emulated robot, requires a real robot.
In this tutorial, we will use Pepper’s camera.
We will use the camera service, which can be accessed using the
Before stepping in this tutorial, you should be familiar with the robot focus and robot lifecycle notions.
For further details, see: Mastering Focus & Robot lifecycle.
Let’s start a new project
- Start a new project, let’s call it TakePicturePepper.
- Robotify it and make sure it implements the QiSDK & the Robot Life Cycle.
For further details, see: Creating a robot application.
Taking a picture¶
Put the following code in the
Now let’s test it using a button to start the action and an imageView to display the taken picture.
In the activity_main.xml layout file, add the following
<ImageView android:id="@+id/picture_view" android:layout_width="300dp" android:layout_height="300dp" android:layout_above="@+id/take_pic_button" android:layout_centerInParent="true" /> <Button android:id="@+id/take_pic_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:text="Take a picture"/>
Create these fields in the
Put the following code for the
Set the button onClick listener:
Add a method that runs takePicture Action asynchronously:
TakePicture action returns a
TimestampedImageHandle object that contains the picture and its timestamp.
The following snippet gets the image data as a ByteBuffer then display it as a
Let’s try it¶
The sources for this tutorial are available on GitHub.
Install and run the application.
For further details, see: Running an application.
Choose “Take a picture”.
Wait for pepper to say the instruction.
Click on take picture button.
When the picture is taken you will see it in the center of the screen.
You are now able to take pictures with Pepper!