PIVlab icon indicating copy to clipboard operation
PIVlab copied to clipboard

Add webcam example to image acquisition module....

Open Shrediquette opened this issue 2 years ago • 0 comments

...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};

Shrediquette avatar Aug 04 '23 19:08 Shrediquette