Question Description
Instructions
For this project, you are expected to build a 2D based animation, which is often used in video gaming. Below is a captured frame showing what you need to achieve. The basic goal is to let you load different images, and synthesize a new image by putting different images together, and display the final image sequentially to screen.
Project Description:
This animation is about a dinosaur chasing a girl in the forest. To achieve this effect, there are three basic objects involved: a girl, a dinosaur, and a moving background. The relative positions of the dinosaur and the girl can be flexible, as long as the dinosaur is to the left of the girl, which makes sense. You can place the girl in the middle of the image. In practice, you do not need to change the positions of the girl and the dinosaur once the program starts. What you need to do is to load different images (about different poses of the girl and dinosaur) and copy them into the final image sequentially, meanwhile copy different parts of the background image using slide window mechanism to generate the animation effects. All the images involved for this animation have been provided in the attachment.
Project Goal:
- Get familiar with OpenCV by practicing different functions, including imread( ), imshow( ), create( ), waitKey( ), copyTo( ), Range( ).
- Understand the process of 2D based animation.
- Learn the role of using mask in image processing.
- Practice implementing user interactivity by programming on mouse/keyboard event.
Suggested Steps:
(1) To get started, you first create a function, say loadImages() to load all the images into the memory by using imread(). (hint: if you feel it is tedious to type each individual image name, you can use the sprintf() function from c++ and load those images by a loop)
(2) You can use the create( ) function (that is the member function of cv::Mat) to create a screen image, which is used to hold and display the background, the dinosaur, and the girl together. You can make this screen image the same height as the background image (bg_scene.jpg), but a little narrower than the width of the bg_scene.jpg. Initially, this screen image is in black color.
(3) Then you can copy one of the girl image into the screen image. There is no exact location requirement for the girl in the screen. You can put it in the middle of the image as the screenshot shows.
(4) If you succeed, then you can try to copy one dinosaur image to the screen in the same way.
(5) To animate the girl and dinosaur to run, you need to put step (3) and (4) into a loop. For each iteration, different girl or dinosaur image is copied to the screen based on the loop index.
(6) Finally, you need to manage to do the rolling background. The basic idea is to copy different part of the bg_scene.jpg into the screen image to generate a moving effect. This part is talked in the class.
Rubrics:
(1) Successfully load all the images into memory. (20%)
(2) Successfully create the screen image. (10%)
(3) Successfully generate animation for the girl and the dinosaur (40% with the three sub-parts below)
- use copyTo( ) and Range( ) to copy a girl (or dinosaur) image to the screen (15%)
- correctly use mask image (10%)
- use a loop to copy different posed figure into the screen (15%)
(4) Successfully generate rolling background (30%)
Bonus Points:
(5) Your program allows the user to use mouse or keyboard to change the location of the girl and dinosaur. For example, the key d to let the two objects move towards right; a – moves towards left; w-moves up; s-moves down (20%)
Submission:
Please submit your code through Isidore. If there are more than one files. You need to zip them and submit the “.zip” file.