Compare commits
5 Commits
master
...
Julian_dev
| Author | SHA1 | Date |
|---|---|---|
|
|
65f25bb19d | |
|
|
6a50638753 | |
|
|
cbb47880db | |
|
|
efa66c4a71 | |
|
|
1837834c83 |
|
|
@ -0,0 +1,38 @@
|
|||
import processing.video.*;
|
||||
|
||||
Capture cam;
|
||||
int x =0;
|
||||
int d = 26;
|
||||
int eyeZone = 10;
|
||||
float s = 1/30;
|
||||
int start = 0;
|
||||
|
||||
void setup() {
|
||||
size(750, 480);
|
||||
cam = new Capture(this, width, height);
|
||||
cam.start();
|
||||
loop();
|
||||
x=0;
|
||||
}
|
||||
|
||||
void draw() {
|
||||
if(cam.available()) {
|
||||
cam.read();
|
||||
}
|
||||
image(cam, 0, 0);
|
||||
if(x<10*1/s && start==1){
|
||||
saveFrame("frame_#####.jpg");
|
||||
x++;
|
||||
}
|
||||
//fill(255,0,0);
|
||||
rect(width*0.5-d*2-eyeZone/2,height*0.5,eyeZone,5);
|
||||
rect(width*0.5+d*2-eyeZone/2,height*0.5,eyeZone,5);
|
||||
fill(0,0);
|
||||
rect(width*0.5-3*d/2,height*0.5-d*5/2,3*d,3*d/2);
|
||||
delay( int(s*1000) );
|
||||
}
|
||||
|
||||
void keyPressed() {
|
||||
start = 1;
|
||||
println("ok");
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%function [] = ()
|
||||
%
|
||||
% Task:
|
||||
%
|
||||
% Inputs:
|
||||
|
||||
% Outputs:
|
||||
%
|
||||
% Antoine Rodary - Julian Leclerc - Gwenn Durpoix-Espinasson - Luc Pichot
|
||||
% 06/04/2021
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
function [gROI] = picToROI(imgWidth,imgHeight,nbIm,d)
|
||||
display("piToRoi Start")
|
||||
files = dir('*.jpg');
|
||||
ROI = zeros (3*d/2,3*d+1,nbIm,3);
|
||||
for n=1:1:nbIm
|
||||
files(n).name
|
||||
frame = imread (files(n).name);
|
||||
|
||||
Image = im2double (frame);
|
||||
for i=1:1:3*d/2 %imgHeight*0.5-d*5/2:1:3*d/2
|
||||
for j=1:1:3*d %imgWidth*0.5-3*d/2:1:3*d
|
||||
|
||||
rROI(i,j,n) = Image(i+imgHeight*0.5-d*5/2,j+imgWidth*0.5-3*d/2,1)*255;
|
||||
gROI(i,j,n) = Image(i+imgHeight*0.5-d*5/2,j+imgWidth*0.5-3*d/2,2)*255;
|
||||
bROI(i,j,n) = Image(i+imgHeight*0.5-d*5/2,j+imgWidth*0.5-3*d/2,3)*255;
|
||||
|
||||
endfor
|
||||
endfor
|
||||
endfor
|
||||
display("piToRoi End")
|
||||
endfunction
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%function []= plotAverage(ROI,nbIm, fps)
|
||||
%
|
||||
% Task: plotting the average color of the ROI over time
|
||||
%
|
||||
% Inputs:
|
||||
% - ROI: 3D matrix, Region of interest, made out of 'nbIm' different images
|
||||
% - nbIm: integer, number of images stored from the video
|
||||
% - fps: frames per seconds of the video
|
||||
%
|
||||
% Outputs:
|
||||
% - plot of the average color of the ROI as a function of time
|
||||
%
|
||||
% Antoine Rodary - Julian Leclerc - Gwenn Durpoix-Espinasson - Luc Pichot
|
||||
% 06/04/2021
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
|
||||
function [averageArray]= plotAverage(ROI,nbIm, fps)
|
||||
display("PlotAv Start")
|
||||
% passing through each image of the video
|
||||
averageArray = zeros(1,nbIm);
|
||||
[n,m,Nimg]=size(ROI);
|
||||
for k = 1:nbIm
|
||||
% calculating the average value of the ROI
|
||||
sum = 0;
|
||||
for i = 1:n
|
||||
for j = 1:m
|
||||
sum = sum + ROI(i,j,k);
|
||||
end
|
||||
end
|
||||
average = sum/(i*j);
|
||||
%storing
|
||||
averageArray(k)= average;
|
||||
end
|
||||
xAxis = [0:(1/fps):(nbIm/fps)-(1/fps)];
|
||||
figure(1);
|
||||
plot(xAxis, averageArray);
|
||||
title('Average color of the ROI over time')
|
||||
xlabel('t (s)')
|
||||
ylabel('Average color of the ROI')
|
||||
display("PlotAv End")
|
||||
endfunction
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%function []= plotFFT(averageArray, nbIm, fps)
|
||||
%
|
||||
% Task: plotting the fast fourier transform of the average color of the ROI
|
||||
%
|
||||
% Inputs:
|
||||
% - averageArray : function of the average color of the ROI over time
|
||||
% - nbIm : integer, number of images stored from the video
|
||||
% - fps : frames per seconds of the video
|
||||
%
|
||||
% Outputs:
|
||||
% - plot of the fast fourier transform of the average color of the ROI
|
||||
%
|
||||
% Antoine Rodary - Julian Leclerc - Gwenn Durpoix-Espinasson - Luc Pichot
|
||||
% 06/04/2021
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
function []= plotFFT(averageArray, nbIm,fps)
|
||||
|
||||
display("Plot FFT Start")
|
||||
Fs = fps; % Sampling frequency
|
||||
T = 1/Fs; % Sampling period
|
||||
L = nbIm; % Length of signal
|
||||
t = (0:L-1)*T; % Time vector
|
||||
Y = fft(averageArray);
|
||||
|
||||
P2 = abs(Y/L);
|
||||
P1 = P2(1:L/2+1);
|
||||
P1(2:end-1) = 2*P1(2:end-1);
|
||||
f = Fs*(0:(L/2))/L;
|
||||
figure(2);
|
||||
plot(f,P1)
|
||||
title('Fast Fourier Transform of the signal of the average color of the ROI')
|
||||
xlabel('f (Hz)')
|
||||
ylabel('|P1(f)|')
|
||||
display("Plot FFT End")
|
||||
hold on;
|
||||
endfunction
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
fps = 30;
|
||||
nbIm = 300;
|
||||
|
||||
%rROI = picToROI(750,480,nbIm,26,1);
|
||||
gROI = picToROI(750,480,nbIm,26,1);
|
||||
%bROI = picToROI(750,480,nbIm,26,1);
|
||||
|
||||
hold
|
||||
averageArray = plotAverage(gROI,nbIm, fps);
|
||||
plotFFT(averageArray, nbIm,fps);
|
||||
Loading…
Reference in New Issue