Shrediquette / PIVlab

Particle Image Velocimetry for Matlab, official repository
https://shrediquette.github.io/PIVlab/
MIT License
140 stars 34 forks source link

Add webcam example to image acquisition module.... #92

Open Shrediquette opened 1 year ago

Shrediquette commented 1 year ago

...so users can play with the interface using their webcam. Don't use imaqtoolbox, but the free Webcam addon. Just use some resolution, so no extra settings available, like in my code ehre:

cam = webcam(1); disp('Using the first webcam from the list of available webcams.') %% Setting camera to a suitable resolution desired_resolution = 320; %this is the desired resolution for this example available_resolutions=cam.AvailableResolutions; width=zeros(numel(available_resolutions)); for i=1:numel(available_resolutions) temp = strsplit(available_resolutions{i},'x'); width(i)=str2double(temp{1}); end index_of_suitable_resolution = find(width>desired_resolution-50 & width < desired_resolution+50); if isempty(index_of_suitable_resolution) index_of_suitable_resolution = numel(available_resolutions); %take the last listed resolution end index_of_suitable_resolution=index_of_suitable_resolution(1); %take only the first element if more suitable resolutions were found cam.Resolution=available_resolutions{index_of_suitable_resolution};