mercredi 8 juillet 2015

Q: Comparision of specified points in two images in MATLAB

I have to write an application, which is tracking an chosen object in a video. Next i have to open a second video, choose an element i want to track. I want to compare these 2 objects, and if it turns out that these objects are the same my program become tracking this object, and if it's not, program is displaying proper message.

And there is a problem; how can i compare these 2 objects?

here is the program code, all i have to add is 'if' statement, in which object is recognized.

whole method i took from this tutorial: http://ift.tt/1zQJWih

clear;
PrzestRobocza1 = vision.VideoFileReader('2.avi');                                 
Odtwarzacz1 = vision.VideoPlayer('Position', [125, 125, 700, 540]);                 
PierwszaKlatka1= step(PrzestRobocza1);                                                 

figure;
imshow(PierwszaKlatka1);
title('Zaznacz obszar na ktorym znajduje sie sledzony obiekt');
ObszarObiektu1= round(getPosition(imrect)); 
imwrite(ObszarObiektu1, 'abcdcd.jpg');
PunktyChar1 = detectMinEigenFeatures(rgb2gray(PierwszaKlatka1), 'ROI',           ObszarObiektu1);   
PokazPunkty1 = insertMarker(PierwszaKlatka1, PunktyChar1.Location, 'o',   'Color', 'green');


figure; 
imshow(PokazPunkty1);
title('Punkty charakterystyczne na obszarze');

Sledzenie1 = vision.PointTracker('MaxBidirectionalError', 1);
initialize(Sledzenie1, PunktyChar1.Location, PierwszaKlatka1);

while ~isDone(PrzestRobocza1)
      Ramka1 = step(PrzestRobocza1);
      [PunktyChar1, validity] = step(Sledzenie1, Ramka1);
      out = insertMarker(Ramka1, PunktyChar1(validity, :), 'o');
      step(Odtwarzacz1, out);
end

release(Odtwarzacz1);
release(PrzestRobocza1);

PrzestRobocza2 = vision.VideoFileReader('3.avi');                                
Odtwarzacz2 = vision.VideoPlayer('Position', [125, 125, 700, 540]);             
PierwszaKlatka2 = step(PrzestRobocza2);
figure;
imshow(PierwszaKlatka2);
title('Zaznacz obszar na ktorym znajduje sie sledzony obiekt');
ObszarObiektu2= round(getPosition(imrect)); 
imwrite(ObszarObiektu2, 'zdj1.jpg');
%pobieranie współrzędnych śledzonego obiektu
PunktyChar2 = detectMinEigenFeatures(rgb2gray(PierwszaKlatka2), 'ROI',     ObszarObiektu2);  
PokazPunkty2 = insertMarker(PierwszaKlatka2, PunktyChar2.Location, '+', 'Color', 'red');
figure; 
imshow(PokazPunkty2);
title('Punkty charakterystyczne na obszarze');



if    %here is the problematic statement

    Sledzenie2 = vision.PointTracker('MaxBidirectionalError', 1);
        initialize(Sledzenie2, PunktyChar2.Location, PierwszaKlatka1); 

        while ~isDone(PrzestRobocza2)
            Ramka1 = step(PrzestRobocza2);
            [PunktyChar2, validity] = step(Sledzenie2, Ramka2);
            out = insertMarker(Ramka2, PunktyChar2(validity, :), 'o');
            step(Odtwarzacz2, out);
    end

        release(Odtwarzacz2);
        release(PrzestRobocza2);
   else                            
        disp('brak dopasowania!');
    end

Aucun commentaire:

Enregistrer un commentaire