real time smartphone camera processing
6 次查看(过去 30 天)
显示 更早的评论
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 个评论
Zarish Akeel
2017-6-13
What was your MATLAB version? I'm using MATLAb 2013a but this code isn't running on that version.
回答(2 个)
Image Analyst
2014-11-7
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 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!