Jumping from one random frame to another random frame with continuity.
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
Stephen23
2018-8-7
"...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?
回答(2 个)
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
2018-8-9
1 个评论
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!