Emgucv # 20: Capture a particular Frame from video in Emgu CV

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello and welcome to this new tutorial on EMG ucv sometimes we may not need to read all of the transactive frames rather we need to skip some of the frames and read a particular length by providing the frame number so how we can do that in EMG ucv let's go into the code I have already created a project and they configured it to use EMG ucv 3.3 if you are not aware of how to configure it you can check one of my previous videos right click on the project go to a and the windows phone give a name to the forum of your choice I call it for frame capture and click on 8:00 let me quickly design this form so that I can read the frames and display it in the picture box [Music] okay now I can open the video and a double click on this open and the first thing that I need to do is to it will be mg your CV in my project so I'll do that by using EMG you see me the strap also here I'm going to define some local variables that I use in the code I let's say double total frames frame and just to store information about how many total frames do we have in the video and then frames per second and also I should say teacher time frame number that the current frame that I'm interested in here's video use an open file dialog equals new open file time I created then show this dialogue to use it and if he selects a video and it clicks okay then the dialogue result should be done of result oh okay it means he selected a video now we can read it since we are capturing the video so we need to create the video captured last his capture so we will capture the video create object for the caption and here I'm going to pause the video file that has been selected by the user and what I want to do is on this picture box I want to display the first frame so to read the first frame let me press create a mate object new mate and then I can read captured dot read and read this frame first frame into an object once I read it now I can display it in picture box but not image posted and not beat me so once I open the video I just read the first frame in a displayed in the picture box once so that I should be it should confirm that the video has been read and any few more things I want here I just want to calculate the total frames that I have in the frames per second so I can also do that frame total total frame so how can we get these total number of frames in the video is using this capture object dot get capture property maybe inside this get capture property we have an enum and from here I can say total sorry frame come so get the observe property and I selected this inner that is the frame count so this one will return me the total frames that I have in this capture object and also I want to get the frames per second I've also do this similar way of getting it and here I want to pause the frames per second so using the gap and capture property of this capture object then I pass this in particular enough that I want to read and then it returns a double value into a number of frames per second until now it should be able to read the video in the display the first frame in the picture box so we can test it so let's file open open a video for example this news video so that looks pretty good I also need to set the frames per second that I want to read so to do that I will rake in a lot of numeric up/down button over here and then I will let's say current value is also one the minimum value should be one in the maximum that I want the hundred frames per second play the first thing that I want to make sure that the capture is not not if it is not the night written in to read all of the frames rest of the frames and let me create a new method here so I call it private void read all frames in this read all frames and what I need to do is to mate em here I would read these frames one by one and I need to run a while loop while frame number is less than total frames so that I'll make sure that I'm not reading any frame out of the total frames in here which frame number I want to read is plus equals to numeric a download value I want to read every nth frame and since this one is giving me a disabled variety I need to convert it into an integer to int 16 doesn't matter and now I need to tell the capture object that set the captured property in which property I want to do POS frames that is the position of the frame that I want to read now should be the frame number that's it so when now I really captured dot read so you can guess that which frame it will read it will read the frame which I have mentioned words set over here let's say if it is every tenth frame this one will increase by ten so first ten twenty thirty forty eighth frame will be read and then I can display it in the picture box under the image equals two and that is the whole logic that we have over here to read end frame in a sense you you know that this is a while move and until all of the frames are not read or graphic user interface will not be updated and to solve the issue as I have been doing this I'll use the essent in weight you know provide a delay over here so task but delay this is 1000 milliseconds divided by whatever frames per second I have innocence that is expecting an integer so I need to convert to int 16 so this will be waiting for that amount of time that's great and since I have a pause button here also I double click on the pause I need to introduce some sort of Guru code and I need to introduce some sort of logical over here oh so if it is paused I don't want to continue this loop I should be waiting for it and here I'll add some boolean is so whenever I am inside this play button I should set this one to be true and then all this read all frames and when I am in the pause I should say is read frame is equal to reading frame false and also here and I need to make sure that this is reading equals true and frame number is less than total frame numbers I should do these activities otherwise I shouldn't be doing anything else so let's run this application we have let's say a Turkish video and then play it you can see it is playing if I increase it you can see how fast it is reading and if I slow it down it is normally it is reading becomes active frame it means it is reading every tenth frame for example so that's why it is moving very very fast rather I should do one more thing I want to display which frame is being read because I'm not sure which frame is currently being shown I should say that whenever I am playing I can show that in the red frame you can say label one text equals frame number three number three was I can show that how many total we have different total frames no string and now let's run that file open let's check with any English one so this is the first frame plate it's normally plain you can see one frame per second five treats let's say ten you can see it is how fast it is so this indicates let me pause it this indicates that I'm reading a bit bent frame so that is how we read every tenth frame in a video and in some situations we may not need to read all of the consecutive frames one at a time and I hope you enjoyed the video hope to see you in the next video [Music] you
Info
Channel: AKHTAR JAMIL
Views: 13,187
Rating: undefined out of 5
Keywords: Read specific frames from a video- emgucv, Read specific frames from a video, Read video frame from video file, Read video frame data from file, Read video frame data from file emgucv, how to select specific frames from a video in emgucv, how to select specific frames from a video in emgu cv, Start video read from a particular frame emgucv, Getting specific frames from VideoCapture in emgucv, read specific frame emgu cv
Id: nfI5yy0bTRs
Channel Id: undefined
Length: 13min 27sec (807 seconds)
Published: Fri Dec 08 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.