I want to find object real time, using a webcam.

%% I found some example code comparing two pictures, but I want to compare the webcamstream to a picture. Can any one help me how to do this?
close all;
clear all;
clc;
%%Read Images
I1= imread('klokke1.jpg');
figure;imshow(I1); title('object');
I2=webcam;
figure; imshow(I2);title('klokka er 12')
%%Detect features
points1 = detectSURFFeatures(rgb2gray(I1));
points2 = detectSURFFeatures(rgb2gray(I2));
%%Extract Features
[feats1, validpts1] = extractFeatures( rgb2gray(I1),points1);
[feats2, validpts2] = extractFeatures( rgb2gray(I2),points2);
%%Display features
figure; imshow(I1); hold on;plot(validpts1,'showOrientation',true);
title('Detect Features');
%%Match Features
index_pairs= matchFeatures(feats1, feats2,...
'Prenormalized', true);
matched_pts1 = validpts1(index_pairs(:,1));
matched_pts2 = validpts2(index_pairs(:,2));
figure; showMatchedFeatures(I1,I2,matched_pts1, matched_pts2,'montage');
title('Initial Matches');

Answers (1)

vid1 = videoinput('winvideo', 1); vid2 = videoinput('winvideo', 2); start([vid1 vid2]); further u can use ur regular code with your camera running end of loop
############
also need to install support package

Asked:

on 27 Oct 2017

Answered:

on 27 Oct 2017

Community Treasure Hunt

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

Start Hunting!