how to take two images from real time image processing?

조회 수: 1 (최근 30일)
haya yousuf
haya yousuf 2016년 4월 30일
편집: Walter Roberson 2016년 4월 30일
I'm working on a real time image processing... i wrote a code to take an image from the video and then used (pause(3)) function to wait for 3 seconds, and then repeat the first codes again to take anther image. But the second image comes same as the first one with no change. why it's not changing ? why the same image is coming again?
  댓글 수: 3
Image Analyst
Image Analyst 2016년 4월 30일
Maybe you're not moving the camera or changing the scene or lighting. Maybe you call imshow() only once for the first image. Who knows? How can we know?
haya yousuf
haya yousuf 2016년 4월 30일
편집: Walter Roberson 2016년 4월 30일
this is the code for taking the second image:
pause(3)
while(vid.FramesAcquired<=200)
data = getsnapshot(vid);
diff_im = imsubtract(data(:,:,1), rgb2gray(data));
diff_im = medfilt2(diff_im, [3 3]);
diff_im = im2bw(diff_im,0.18);
diff_im = bwareaopen(diff_im,300);
bw = bwlabel(diff_im, 8);
stats = regionprops(bw, 'BoundingBox', 'Centroid');
% Display the image
imshow(data)
hold on
for object = 1:length(stats)
bb = stats(object).BoundingBox;
bc = stats(object).Centroid;
rectangle('Position',bb,'EdgeColor','r','LineWidth',2)
plot(bc(1),bc(2), '-m+')
a=text(bc(1)+15,bc(2), strcat('X: ', num2str(round(bc(1))), ' Y: ', num2str(round(bc(2)))));
set(a, 'FontName', 'Arial', 'FontWeight', 'bold', 'FontSize', 12, 'Color', 'yellow');
end
hold off
end
boxim=imcrop(data,bb);
figure(2)
imshow(boxim)
k=rgb2gray(boxim);
BW1 = edge(k,'sobel');%, 0.5);
imshow(BW1);
flushdata(vid);

댓글을 달려면 로그인하십시오.

답변 (1개)

Image Analyst
Image Analyst 2016년 4월 30일
Get rid of imshow where you have it and put it after getsnapshot. Then call drawnow;
data = getsnapshot(vid);
imshow(data);
drawnow;

태그

Community Treasure Hunt

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

Start Hunting!

Translated by