How do I use my smart phone camera as a webcam in MATLAB?

I have an smartphone device with a camera. I would like to obtain and process this image data in MATLAB.
(Specifically, I have an Android device).

댓글 수: 3

is there any other solution that make matlab still running in the foreground, I tried this method yet it require the ip cam to run in the foreground i need matlab to be still running for later image processing. Also is it possible to access the smart phone camera using matlab mobile Specifically to iphone camera ?
keerthana potharaj
keerthana potharaj 2019년 1월 29일
이동: DGM 2023년 2월 22일
how do we interface mobile camera for deep learning?
P.S we don't have web cam. pls help us.
kundan surse
kundan surse 2020년 1월 21일
이동: DGM 2023년 2월 22일
I want to take the screenshot of my mobile screen form matlab to use it for further prossesing how can i do that ?

댓글을 달려면 로그인하십시오.

 채택된 답변

Ashish Uthama
Ashish Uthama 2011년 7월 20일
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!)

댓글 수: 18

Nice recursive ML screen. +1 for that!
I use a 'dumb' phone so can't provide real feedback ;)
Its really fun to see it build it up! (i.e its not super fast :()
Is there a similar app for iOS?
Ashish Uthama
Ashish Uthama 2011년 7월 20일
편집: Walter Roberson 2023년 5월 16일
http://itunes.apple.com/us/app/ip-cam/id333208495?mt=8 appears close enough. Care to try and post another answer?
hi, i want to know that can we change this rgb image into grayscale or binary image. i have tried but failed. so any suggestion plz
set(fh, 'CData', rgb2gray(ss));
And be sure that you have done
colormap(gray(256))
after the original image() call.
I'm using a GoPro HD camera which has a URL via an Ambarella video player as http://10.5.5.9:8080/live/amba.m3u8. This is the network address to play in a VLC player. I want to use Matlab for further processing options.
What's the purpose of the .jpg string of the url input? I use the same code as above for the iPhone and Android with the '.jpg' extension on my URL and get the error message...
Error using imread (line 331) Can't read URL "http://10.5.5.9:8080/live/amba.m3u8.jpg".
Current input in command window is url = 'http://10.5.5.9:8080/live/amba.m3u8.jpg'; ss = imread(url); fh = image(ss);
while(1) ss = imread(url); set(fh,'CData',ss); drawnow; end
Very nice Thank You!!
>> Ipcamtest Error using imread (line 330) Cannot read URL "http://<htp://10.170.26.12>/shot.jpg".
Error in Ipcamtest (line 2) ss = imread(url);
Hi, Actually I got this Error.. Can you help me out?
Hola a todos. La propuesta de Ashish Uthama me ha resultado muy bien, el unico detalle es que en la IP se debe agregar el puerto que muestra la imagen en la parte inferior en el dispositivo android.
Saludos.
Hi Prateek..! Just remove all the connection to your PC except the connection of android and your PC. This error is coming because Your PC is trying to connect to other network and your cam is in other network.
how can i save a particular frame as an image from this live feed of video from the phone?
thank you very much
Is there anyway to use the smart phone camera as web cam through usb cable?
Hello, is it possible to edit the exposure of the android camera?
Walter Roberson
Walter Roberson 2023년 5월 16일
편집: Walter Roberson 2024년 11월 7일
If you happen to use the same product as was discussed in the link on instructables then the vendor site says that exposure is adjustable. https://www.e2esoft.com/ivcam-camera-settings/
Hi, tip from me - a bit quicker than taking jpg files is to use video. Using the mentioned app the link is simpy:
url_cam = 'http://<ip_address>/video';
cam = ipcam(url_cam)

댓글을 달려면 로그인하십시오.

추가 답변 (12개)

Soham Bhattacharyya
Soham Bhattacharyya 2016년 5월 16일

3 개 추천

You can use DroidCam if you are using an android phone. You'll need to install OS Generic Video Interface driver.
Hope it helps. :)

댓글 수: 2

elfodd
elfodd 2017년 5월 15일
편집: elfodd 2017년 5월 15일
for anyone that can't find the correct address for droidcam simply connect to droidcam using your browser and click on the i button. It should look like this
http://192.168.1.61:4747/mjpegfeed?640x480
and then
camera = ipcam('http://ipaddress:port/mjpegfeed?640x480')
thank you worked for me

댓글을 달려면 로그인하십시오.

Chirag Gupta
Chirag Gupta 2011년 7월 20일
With the iPhone, using the App suggested by Ashish above (IP Cam), you can achieve the same pretty easily! The code is exactly the same:
url = 'http://<ipaddress>:8020/image.jpg';
ss = imread(url);
fh = image(ss);
while(1)
ss = imread(url);
set(fh,'CData',ss);
drawnow;
end

댓글 수: 5

Nice Fractal, +1
Hi, Excuse me for my bad English. I'm using IP webcam for Android.I used
url = 'http://158.124.30.101:8080/shot.jpg';
ss = imread(url);
fh = image(ss);
The video is excellent but my problem is that I want to use a bounding box to sellect a red object in the video. I don't know if it's possible. Can anyone help me?thanks
Francisco, you'll get a better answer if you ask this as a new question: http://www.mathworks.com/matlabcentral/answers/questions/new
(also look at http://www.mathworks.com/matlabcentral/fileexchange/28512-simple-color-detection-by-hue for example)
is the IP address for the android webcam streaming live video or simply a single image or series of saved images?
hi, please how can i save the video from this function? thank you best regard

댓글을 달려면 로그인하십시오.

amro
amro 2014년 5월 10일
url=('http://192.168.43.1:8080/shot.jpg?rnd=350264');
hVideoIn = vision.VideoPlayer('Name', 'Final Video');
while(1)
ss=imread(url);
step(hVideoIn,ss)
end

댓글 수: 3

This works well but i have question that why you did not use IP Camera Image Acquisition? i there any why to use it with ip webcam app
ipcam() was not introduced until R2015a, a year after amro posted their Answer.
Hi Hauder Ali, please can you explain how it work on IP camera Image Acquisition. I new in Matlab. thx

댓글을 달려면 로그인하십시오.

PIYUSH KUMAR
PIYUSH KUMAR 2015년 9월 14일
Here's the working code for color detection using android camera:
url = 'http://192.168.0.100:8080/shot.jpg';
framesAcquired = 0;
while (framesAcquired <= 50) % the vedio will work till the 50 video frames, after that the vedio will stop. You can use while(1) for infinite loop
data = imread(url);
framesAcquired = framesAcquired + 1;
diff_im = imsubtract(data(:,:,1), rgb2gray(data)); % subtracting red component from the gray image
diff_im = medfilt2(diff_im, [3 3]); % used in image processing to reduce noise and for filtering
diff_im = im2bw(diff_im,0.18); % convert image to binary image
stats = regionprops(diff_im, 'BoundingBox', 'Centroid'); % measures a set of properties for each connected component in the binary image
drawnow;
imshow(data);
hold on
for object = 1:length(stats)
bb = stats(object).BoundingBox;
bc = stats(object).Centroid;
rectangle('Position',bb,'EdgeColor','b','LineWidth',2)
plot(bc(1),bc(2), '-m+')
end
hold off
end
%stop(vid); % to stop the video
%flushdata(vid); % erase the data video
clear all

댓글 수: 1

Tiwa Romuald
Tiwa Romuald 2015년 10월 14일
편집: Tiwa Romuald 2015년 10월 15일
hi PIYUSH KUMAR please this function it's just for a snaphot or video? i would like to have video and save it from my smarphone into matlab. how can I save directly as a AVI video? please help me. thank you

댓글을 달려면 로그인하십시오.

Amrinder Brar
Amrinder Brar 2015년 3월 25일
편집: Amrinder Brar 2015년 3월 25일

0 개 추천

Is there any simple solution to this problem in iphone(i.e. without having to install any third party apps) ?
saras
saras 2016년 7월 1일

0 개 추천

I am not sure if this is exactly what you are looking for. However, you can use 'Simulink Support Package for Samsung GALAXY Android Devices' or 'Simulink Support Package for Apple iOS Devices' to access the appropriate smartphone camera. Both these support packages come with a Camera block that allow you to get the Camera data inside MATLAB. You can subsequently connect the Camera block to a Video Viewer block if you would like to visualize the data in Simulink.

댓글 수: 1

Deepak B
Deepak B 2020년 9월 16일
편집: Deepak B 2020년 9월 16일
actuallty im looking for this can we send live camera video from the android device i installed the simulink support package for android
but i dont know hoe to use that to send live video to matkab simulink help me out

댓글을 달려면 로그인하십시오.

Cristian David Jimenez Bedoya
Cristian David Jimenez Bedoya 2016년 12월 5일
편집: Walter Roberson 2016년 12월 5일
buenas, este programa funciona bien pero no he logrado capturar una imagen a partir de este mismo, como puedo obtener una captura de imagen y almacenarla ?
url = "http: // <dirección IP> /shot.jpg ';
ss = imread (url);
fh = imagen (ss);
mientras que (1)
ss = imread (url);
conjunto (FH, 'programable CData', ss);
drawNow;
fin

댓글 수: 2

Approximate translation:
Good, this program works fine but I have not managed to capture an image from this same, how can I get an image capture and store it?
imwrite() the content of ss

댓글을 달려면 로그인하십시오.

MARIA JAVED
MARIA JAVED 2017년 2월 4일

0 개 추천

can anybody tell me that how we can do face detection through Android phone pls help??? i need that code?

댓글 수: 1

You would either have to write the code in MATLAB and use MATLAB Coder, or else you would have to create a Simulink model and deploy that to Android.

댓글을 달려면 로그인하십시오.

Jonathan berry
Jonathan berry 2017년 4월 10일

0 개 추천

Hello guys,
I keep having this error:
Error using imread (line 350) Can't read URL "http://MY_IP /shot.jpg".
any help will be appreciated

댓글 수: 2

I have the same issue. Looking for an answer.
You need to replace he "MY_IP " part by your actual IP address, such as http://192.168.0.10/shot.jpg

댓글을 달려면 로그인하십시오.

Dilip Dubey
Dilip Dubey 2018년 4월 29일

0 개 추천

How can I read other sensors from IP webcam app in Matlab?

댓글 수: 1

You can geet a json file for sensors
s='4'
urlImage=['http://192.168.1.' s ':8080/shot.jpg']
urlSensors=['http://192.168.1.' s ':8080/sensors.json']
frame = imread(urlImage);
q=jsondecode(urlread(urlSensors)); %#ok<URLRD>
q.accel.data{1}{2}

댓글을 달려면 로그인하십시오.

Beril Sirmacek
Beril Sirmacek 2018년 4월 29일
Hi All,
I found out that;
imread('http://MY_IP /shot.jpg');
works only on secured network for me. If I am on a public network, then it gives error.

댓글 수: 2

How can I extend this to Simulink model? any suggestions?
"On Windows platforms, this parameter supports URLs that point to MMS (Microsoft Media Server) streams."

댓글을 달려면 로그인하십시오.

Akram
Akram 2023년 12월 11일

0 개 추천

Hi, there is a new feature on Apple devices (Continuity Camera) where we can directly use our phone's camera as our mac's webcam. With this feature activated, when using the command imaqhwinfo, i only see my mac's webcam and not my iPhone camera. Is there a way to acquire video (live) with my iPhone's camera ?

질문:

2011년 7월 20일

편집:

2024년 11월 7일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by