Using USB Webcams with MATLAB Online
Get started using USB webcams with MATLAB Online™. Set up a USB webcam in your web browser and discover the different features MATLAB Online offers for USB webcams. Perform basic tasks such as taking single images and video. Implement an object classifier using a deep learning neural network to classify everyday objects using the USB webcam and MATLAB Online.
Download the code used in this video.
Using a USB webcam is the easiest way to get live images and video into MATLAB Online for fast and convenient image processing. You can access your USB webcam and use MATLAB Online from Google Chrome without installing any software.
All the functions in the MATLAB Support Package for USB Webcams are also available in MATLAB Online.
You can take single images, take multiple images to form a video, and you can even do real-time processing on a video.
Use the command webcamlist to see the webcams connected to the computer. Click Allow when your browser prompts you for permission to use your camera.
If you have multiple webcams connected, you can specify which webcam to connect to. You can see the properties of the webcam such as the name and resolution of the camera. To get a preview of what the camera sees, you can use the command: preview.
Now you can take a picture using your webcam. The snapshot function allows you to take a single image from the camera. I'm using the imshow() function to display the image on the screen.
By using the same snapshot function, you can take a video by taking multiple images in a loop. Here, I am using a FOR loop to take 30 images and display them to the screen.
Next, in this demo, each frame of the video is classified using the pretrained neural network GoogLeNet. Here, you can see the label that is assigned to each object, along with the score, which tells us how confident the classifier is. As you can see, the classifier does a pretty good job at labeling these objects, such as coffee mug, orange, pen, mouse, and keyboard.
Now you're ready to get started with your own projects in MATLAB Online using a USB Webcam.
For more information, please refer to the documentation on Webcam Support in MATLAB Online.
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.