croptectd image by user using imrect() functions
이전 댓글 표시
i am capturing infinite no of images from gige vision camera .The camera gives infinite no of screenshot that i converted RGB to binary images but i am not saving these screenshots but only show it.Now i want to crop a perticular region of interest will crop by user only one time by using imrect() and applying the cropted region for multiple live images,coming from camera .How it is possible by matlab? my code is
if true
obj=videoinput('gige',1,'BayerBG8');
set(obj,'SelectedSourceName','input1');
preview(obj);
Folder1='C:\MATLABS\Arka2';
for i=1:5
frame=getsnapshot(obj);
im = rgb2gray(frame);
frame1=imbinarize(im,.4);
imshow(frame1);
end
h_rect = imrect();
pos_rect = h_rect.getPosition();
pos_rect = round(pos_rect);
for i=1:5
img_cropped = frame1(pos_rect(2) + (0:pos_rect(4)), pos_rect(1) + (0:pos_rect(3)));
imshow(img_cropped);
imwrite(img_cropped, fullfile(Folder1, sprintf('%01d.jpg', i)));
end
end
but the problem is that the cropted position of last image is selected only and it prints 5 times.
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 GigE Vision Hardware에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!