Jumping from one random frame to another random frame with continuity.

2 views (last 30 days)
I have recorded a video and have split it into frames. Let's say that it has a total of 15 frames. Now, I want to go from frame 1 to a randomly chosen frame, say, frame 10 but I want to go sequentially from 1 to 10 (i.e covering frames 2,3,4,5,6,7,8,9 as well in the journey) and then I want to move from frame number 10 to frame number 5 (covering 9,8, 7,6 in the reverse journey) and then say from frame number 5 to frame number 12 ( covering 6, 7, 8,9, 10, 11 in the forward journey). How can I proceed to achieve this?
  2 Comments
Stephen23
Stephen23 on 7 Aug 2018
"...and have split it into frames"
1. How are they stored? Are these frame already in MATLAB memory (if so, in what kind of variables?), or are they saved in files on your hardrive (if so, in what kind of files?)?
2. Do you want to allow repetition, or exclude repetition?
3. Do you want to randomly select a subset of all frames? Or should all frames be processed?
Prachi Sharma
Prachi Sharma on 7 Aug 2018
Thanks for pointing out. I didn't make myself clear before. Can you please go through my question again? I have edited it for better understanding.

Sign in to comment.

Answers (2)

Florian Morsch
Florian Morsch on 7 Aug 2018
Use the video file reader https://de.mathworks.com/help/matlab/import_export/read-video-files.html to get your frames from the video, then use a random number generator https://de.mathworks.com/help/matlab/random-number-generation.html to create a random number.
Now you just have to extract that frame from the video file reader and if you want to display it, give it to a video player object( https://de.mathworks.com/help/vision/ref/vision.videoplayer-system-object.html?s_tid=doc_ta ).
  12 Comments
Stephen23
Stephen23 on 9 Aug 2018
@Prachi Sharma: please upload your code here by clicking the paperclip button.
Prachi Sharma
Prachi Sharma on 9 Aug 2018
I couldn't see the attach or attach or photo or link from my desktop, its having some issue may be. I did attach it from my phone though, is it visible now?

Sign in to comment.


Prachi Sharma
Prachi Sharma on 9 Aug 2018
Here is the code. I am new to this, so please don't mind my mistakes.
  1 Comment
Florian Morsch
Florian Morsch on 10 Aug 2018
What i gave you above was a hint in the direction you could go, not a functional code. This will never work like that (and was never intended to), it was simply a example, you will have to improve it.
First your change direction is not a fixed 1 or -1. You will have to run a loop and change that depending on when you want to change the direction of the video.
If you want to save the frames you can do that, but for the video player itself its not needed. You can just pass the frames directly to it.
The loop with while(1) will run forever, you should implement a exit routine.
Finally your Frame_No is the number of frames in vidobj. You cant pass the number to the video player, you will have to pass the vidobj frame wich you want to use. Right now you are passing the number instead of the frame.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!