문제

I am trying to detect potatoes on roller belt. I have created mean background from empty belt images and want to subtract it from each frame of the video and play back but not sure how to achieve this.

In other words, I would like to do something like this, but with each frame of the video:

>> Z = imread('mean.jpg');
>> X = imread('beltpotatoes_1.jpg'); 
>> C = Z - X;
>> imshow(C);

My sample data:

Mean background (mean.jpg): https://drive.google.com/file/d/0B_M7fjkKw1r3d0o3VHg1dXVFNmc/edit?usp=sharing

avi file: https://drive.google.com/file/d/0B_M7fjkKw1r3a3lhdl91bGFLSjQ/edit?usp=sharing

belt with potatoes image (beltpotatoes_1.jpg): https://drive.google.com/file/d/0B_M7fjkKw1r3SURDV19ud1VBQjQ/edit?usp=sharing

도움이 되었습니까?

해결책

Z = imread('mean.jpg');
VR=VideoReader('Video.avi');
NumInFrames=get(VR,'NumberOfFrames');

VW = VideoWriter('new.avi');
open(VW);

for (frame=1:NumInFrames)
    CDatas(:,:,:)=read(VR,frame) - Z;     
    writeVideo(VW,CDatas);   
end
close(VW)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top