This example shows how to set up an IP camera on your Android device and acquire images from it. Unlike most IP cameras that have to be plugged in to an outlet and stay in one place, an IP camera on a smartphone can stream video from anywhere.
Download the IP Webcam Android app. You can use other similar IP camera apps as well, but this example explains the workflow for this app.
Open the app and set your preferences. To reduce the resolution of your video stream, select Video preferences > Video resolution. Larger resolutions result in slower framerate.
Go back to the main screen, and scroll to the bottom to select Start server.
After the stream opens on your phone, note the IP address, labeled IPV4, displayed at the bottom. You use this URL to create a connection to the IP camera.
Create a connection to the IP camera using the URL from the stream on the app. The input argument for the
ipcam function is the URL with '
/video' appended to the end.
cam = ipcam('http://172.31.214.164:8080/video')
cam = ipcam with properties: URL: 'http://172.31.214.164:8080/video' Username: '' Password: '' Timeout: 10
Preview the video stream from the IP camera. The
preview function opens a MATLAB figure window with a live stream of the IP camera's field of view.
Close the preview window when you are done.
You can also take a single image from the video stream and display it.
img = snapshot(cam); imshow(img);