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!