MATLAB Answers

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

조회 수: 9(최근 30일)
Prachi Sharma
Prachi Sharma 7 Aug 2018
댓글: Florian Morsch 10 Aug 2018
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

Stephen Cobeldick
Stephen Cobeldick 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 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.

로그인 to comment.

답변(2개)

Florian Morsch
Florian Morsch 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

표시 이전 댓글 수: 9
Prachi Sharma
Prachi Sharma 9 Aug 2018
I think I am still confused. Here is the picture of what I have written in the code so far, can you please take a look where am I going wrong?
https://drive.google.com/file/d/1_-Dor_A1RqVYI43ggoI-A1Zhb1qf7Q3p/view?usp=sharing
Stephen Cobeldick
Stephen Cobeldick 9 Aug 2018
@Prachi Sharma: please upload your code here by clicking the paperclip button.
Prachi Sharma
Prachi Sharma 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?

로그인 to comment.


Prachi Sharma
Prachi Sharma 9 Aug 2018
Here is the code. I am new to this, so please don't mind my mistakes.

  댓글 수: 1

Florian Morsch
Florian Morsch 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.

로그인 to comment.

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


Translated by