Combining Videos, Images, and Graphics
This chapter features a family collage sketch. The critical programming concepts are playing a video clip and handling video together with images and rectangles. The rectangles represent the category of graphics. The distinct types of items are defined us
- PDF / 2,500,672 Bytes
- 22 Pages / 504 x 720 pts Page_size
- 14 Downloads / 180 Views
Combining Videos, Images, and Graphics This chapter features a family collage sketch. The critical programming concepts are playing a video clip and handling video together with images and rectangles. The rectangles represent the category of graphics. The distinct types of items are defined using classes and subclasses. In addition to introducing the use of video, this chapter and its example can be viewed as another lesson on classes. You can go back to Chapter 4 and review the bouncing things example. The code for repositioning of the pieces by mouse actions has some similarities to creating a line and then moving an image on the line example in Chapter 4. The source code material includes an extra example, a demonstration of using drawing on canvas or an image or a video for directions for an origami model. Figures are given as a teaser.
Programming Concepts This section provides general background on video and the notions of shallow vs. deep copying. I then move to the details of how video is handled in Processing and more on classes and subclasses.
Video Digital video files come in a variety of formats, just like images. It should be easy to accept that a considerable amount of data is involved, potentially a full image for every frame of the video. Some formats perform compression across frames as well as within
© Jeanine Meyer 2018 J. Meyer, Programming 101, https://doi.org/10.1007/978-1-4842-3697-0_8
221
Chapter 8
Combining Videos, Images, and Graphics
frames. The term codec is used for the software or hardware device used for encoding and decompressing video. There are trade-offs to make between quality of the video and size of the file. There also are differences in the speed of going from the stored, digital format to presentation on the screen. It also can be important to ask if the video is to be streamed or acquired all at once. Regarding quality of the image, you might need to think about whether this video is to be viewed on a small screen, like a phone; a typical computer monitor; a high-definition TV; or projected on a large screen for viewing by a big audience.
Copying a Video A general concept in computing is shallow copying vs. deep copying. It relates to the issue of whether your code is dealing with a value or a reference to a value. These issues arise in all programming languages and are not confined to working with videos or images. If your code copies the reference, it will be to the same value. In my first version of the collage, my duplicate method of the class I named MovieItem copied the reference to the Movie object. Therefore, the method produced two items in the window playing the same movie, frame by frame. I decided that I wanted the duplicate operation to produce a new, distinct copy of the video. With this approach, Annika does a round with herself. We can think of the movies being at different points in the reel. I did this by implementing a deep copy. You can examine the code in the “Program” section.
Processing Programming Features The critical Processing progra
Data Loading...