フィルターのクリア

how to take two images from real time image processing?

4 ビュー (過去 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