real time smartphone camera processing
6 views (last 30 days)
Show older comments
Hi!
I installed IP Webcam app onto my android phone. When I start the server, it begins to stream pictures (frames) of the camera, and I can process it with matlab in the following way:
url = 'http://192.168.1.109:8080/shot.jpg';
cam = imread(url);
img = image(cam);
tic;
while(toc < 5)
cam = imread(url);
set(img,'CData',cam);
drawnow;
toc;
end
So my question: I would like to calculate the intensity of pixels (240 x 320) for each frame and store it in an array. How can i do this? Thanks you for help!
1 Comment
Zarish Akeel
on 13 Jun 2017
What was your MATLAB version? I'm using MATLAb 2013a but this code isn't running on that version.
Answers (2)
Image Analyst
on 7 Nov 2014
I'd think you would do something like this (untested):
% Retrieve current (next) image.
cameraImage = imread(url);
hImage = image(cameraImage);
lastPhoto = cameraImage;
difference = 1;
% Set up a failsafe so we don't go on forever.
maxCounter = 100; % Max number you ever want to analyze.
counter = 1;
while difference ~= 0 && counter <= maxCounter
% Continue until image does not change anymore...
theMeans = mean(cameraImage(:));
% Retrieve current (next) image.
cameraImage = imread(url);
counter = counter + 1;
set(img,'CData', cameraImage);
drawnow;
% Compute difference to see if it changed.
diffImage = double(cameraImage) - double(lastPhoto);
difference = nnz(diffImage);
% Delay some to give time for next photo to arrive at the URL.
pause(2);
end
plot(theMeans, 'bs-', 'LineWidth', 3);
grid on;
0 Comments
See Also
Categories
Find more on MATLAB Mobile in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!