Building Pluto The Robot, Part IV: Camera

Building Pluto The Robot, Part IV: Camera

5 min read
IoT

Share

The hour has come for the conclusion of my series of articles about building Pluto, a robot prototype controlled remotely via Wi-Fi connection and a browser. In the previous entries we constructed the robot and prepared the server side. Today’s conclusion will cover attachment of a camera and setup of real-time video streaming to the said browser.

As a matter of fact, this task was one of the simplest in the entire process of Pluto’s creation. I used a standard Raspberry Pi Camera Module V2. It’s quite easy to connect it to the Raspberry Pi, just make sure that the camera cable is plugged in correctly.

Pluto creation

Don’t forget to activate camera support in the settings of your Raspberry Pi, having connected via VNC.

I tried out several good scripts to work with the camera on Python; in particular, this script from the official tutorial, which allows to get a snapshot from the camera and save it to the desktop.

from picamera import PiCamera
from time import sleep

camera.start_preview()
sleep(5)
camera.capture('/home/pi/Desktop/image.jpg')
camera.stop_preview()

It became clear from the beginning that custom implementation of video streaming would not be an easy task. Fortunately, I quickly found an off-the-shelf solution, a library RPi-Cam-Web-Interface.

Follow the tips to install the library (launch all mentioned commands on the Raspberry Pi). It is necessary to set a couple of parameters during the installation.

Rpi Camera Web

It is important to indicate the camera directory and port 80, since both of these parameters have influence on the eventual address of the camera.

After the installation you can open http://YOUR_RASPBERRY_PI_IP/camera and enjoy the views from your robot’s camera. Then you need to add a window with streaming to the control panel. The simplest solution is the add the said page as a frame on the control panel. You may add the following code to the file templates/index.html:

<iframe src="" style="width:100%; height:800px;" frameBorder="0" 
id="camera-iframe" />
<script>
$(function () {
 $('#camera-iframe').attr('src', 'http://' 
+ window.location.hostname + '/camera/');
});
<!--script>

I used JavaScript to initialize the iframe source, in order to retrieve the server address automatically, in case the IP address changes (this can also be made from the Python when the page is generated). Now, the control panel: http://YOUR_RASPBERRY_PI_IP:5000

This is it. Pluto is ready. It can bring you coffee or entertain your friends and clients with a virtual journey in your office. Well, the choice is yours here.

In order to make the robot accessible from outside (from any spot with Internet access), you have to have some system administration skills and a static IP address. However, it’s a topic worth a separate article.

Meanwhile, connect the batteries, enter the control page… and let it roll!

The full working code can be found here.

LET'S DISCUSS YOUR PROJECT!

Contact us

YOU CAN ALSO READ

How to Mitigate IoT Security Threats in 2021

How to Mitigate IoT Security Threats in 2025

The Internet of Things plays a key role in digital transformation. However, in many cases, organizations realize that they already have a large fleet of legacy IoT devices that have been gradually deployed over the years. Many of these devices may not have been designed with security in mind. One of the biggest concerns of IoT is managing the risks associated with a growing number of IoT devices. Information security and privacy issues related to IoT devices have attracted global attention, beca

IoT Technology Trends To Drive Innovation For Business in 2025

Future of IoT Technology: 8 Trends for Businesses to Watch in 2025

The Internet of Things (IoT) technology is on an upward trajectory, with industries pushing its limits so relentlessly and quickly that it is becoming a challenge to keep up. The reasons behind this growth are varied, with three most obviously leading the charge: demand for real-time remote monitoring (for instance, in healthcare), the widespread adoption of smart payment systems (in digital banking), and the urgent need for robust digital infrastructures across industries. MobiDev has been assi

Artificial Intelligence in Manufacturing: Industrial AI Use Cases

Artificial Intelligence in Manufacturing: Industrial AI Use Cases

Industries explore different ways of using Artificial Intelligence in manufacturing, from calculating adequate fuel consumption to testing virtual copies of machinery in the metaverse. Moreover, AI is expected to make complex high-tech solutions cheaper and more approachable for businesses of all sizes.  Since 2009, MobiDev has specialized in software product development and focused on AI since 2018, so we understand how AI can deliver real business results. In this article, we will review how d

Close the CTA

Webinar Recording: Leveraging AI & AR in Retail