MATLAB Answers

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

9 ビュー (過去 30 日間)
Prachi Sharma
Prachi Sharma 2018 年 8 月 7 日
コメント済み: Florian Morsch 2018 年 8 月 10 日
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 件のコメント
Prachi Sharma
Prachi Sharma 2018 年 8 月 7 日
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.

サインインしてコメントする。

回答 (2 件)

Florian Morsch
Florian Morsch 2018 年 8 月 7 日
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 件のコメント
Prachi Sharma
Prachi Sharma 2018 年 8 月 9 日
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?

サインインしてコメントする。


Prachi Sharma
Prachi Sharma 2018 年 8 月 9 日
Here is the code. I am new to this, so please don't mind my mistakes.
  1 件のコメント
Florian Morsch
Florian Morsch 2018 年 8 月 10 日
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.

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by