The general solution would need two parts, one to broadcast the data from the device and another part to read this data into MATLAB.
A specific solution for Android:
- Install the free IP Webcam app. (Make sure you read the corresponding permissions and understand any security issues therein)
- Open the app, set the desired resolution (will impact the speed!)
- Scroll to the bottom and tap on 'Start Server'
- In the camera preview window, note the url at the bottom of the screen.
- Open MATLAB and use this code snippet to obtain a live preview window. Note that this uses JPG files for discrete frames, which is probably not the fastest way. The app can stream the video and/or audio in multiple ways.
url = 'http://<ip address>/shot.jpg';
ss = imread(url);
fh = image(ss);
while(1)
ss = imread(url);
set(fh,'CData',ss);
drawnow;
end
Example:

(If you find faster ways/solutions for other devices, post it here!)
1 Comment
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/12036-how-do-i-use-my-smart-phone-camera-as-a-webcam-in-matlab#comment_152620
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/12036-how-do-i-use-my-smart-phone-camera-as-a-webcam-in-matlab#comment_152620
Sign in to comment.