MATLAB Answers

Image processing while video streaming

조회 수: 23(최근 30일)
Adrian Lim
Adrian Lim 27 Jun 2018
편집: flash mob 11 Dec 2019
Greeting to the community, I have a few questions for image processing while video streaming for a smart traffic light project in my diploma. The main idea is to take a picture every 10 frame or a second and calculate the number of cars.There is a problem that I'm facing which is i can't get the picture periodically. As I start the video, the image remains the same and could not change after 10 frames or a second.
The code that I'm currently trying out are
vid = videoinput('winvideo', 1)
set(vid,'FramesPerTrigger',1)
set(vid,'TriggerRepeat',Inf)
FrameGrabInterval = 10
start(vid)
img=getdata(vid)
imshow(img)
The image that is shown stucked at the first image, is there any ways to fix this or an easier way to grab image and futher process it? Thanks in advance.

  댓글 수: 0

로그인 to comment.

답변(1개)

Florian Morsch
Florian Morsch 2 Jul 2018
편집: Florian Morsch 2 Jul 2018
If this is your code then of course you will only have shown the first picture, since there is no loop to show the new image. Your code gets the video input, set different camera settings, starts the video, get the data one time and displays them.
Now if you want to show the new data you will have to repeat the process of getting the data and show them again.
Is it important to show only one image every 1 second? Because if not you could just run a loop and show a new image when your code is done.
Something like:
vid = videoinput('winvideo', 1)
set(vid,'FramesPerTrigger',1)
set(vid,'TriggerRepeat',Inf)
FrameGrabInterval = 10
start(vid)
FrameCounter = 0;
while(FrameCounter<1000)
FrameCounter=FrameCounter+1;
img=getdata(vid)
imshow(img)
end
This loop runs for 1000 frames. Now if you only want a new frame every 1 second you could just add a pause into the loop with "pause = 1;", you could design your loop with a different condition to take a picture... There are a few options to achieve this.
EDIT: Depending on your camera (webcam? wlan-cam? something else?) you could also work with a video player object. You then take a picture and step it through the video player.

  댓글 수: 1

flash mob
flash mob 9 Dec 2019
Thank you for the answer. It's useful. You might get more information about this on course hero site which you may refer by creating your free course hero account through unblur course hero

로그인 to comment.

이 질문에 답변하려면 로그인을(를) 수행하십시오.

제품


릴리스

R2017a

Translated by