real time smartphone camera processing

7 visualizaciones (últimos 30 días)
Abel
Abel el 7 de Nov. de 2014
Comentada: Zarish Akeel el 13 de Jun. de 2017
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 comentario
Zarish Akeel
Zarish Akeel el 13 de Jun. de 2017
What was your MATLAB version? I'm using MATLAb 2013a but this code isn't running on that version.

Iniciar sesión para comentar.

Respuestas (2)

Image Analyst
Image Analyst el 7 de Nov. de 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;

Abel
Abel el 10 de Nov. de 2014
Thats close but not what I need. I will try to explain in more detail than:
I want to measure my heartbeat, with my phone camera (as a plethyzmograph). So my phone is working as a webcam, and streams the data to the matlab. I have the code written that processes the signal, so the only thing I need is an array that contains pixel intensities through time.
First I need to record the cam for 3 seconds, and give the recorded data to my process function, than wait another sec, add it to the previous array but remove the last second also, and give it to the process function again, and do this step in every second, and so on and so on.
3 second of data is: approx 75 frames -> thats 75 x (240x320) pixel data That is the amound I want to process after 3 sec, and the same amount after each new secundum.

Categorías

Más información sobre MATLAB Mobile en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by