OpenCV with C++

ashrafsmile
OpenCV2.pdf

9/19/21, 2:58 PM Isidore : 21_FA_FT_CPS_667_02 : Assignments

https://isidore.udayton.edu/portal/site/180e87a5-8de8-45da-9176-ed9a0345f68f/tool/165088f0-24a8-4265-9f55-8a09f7193a10?panel=Main 1/2

ATTENTION Visit Password Self-Service to set Challenge Questions so you can reset your own password if it is forgotten or expired.

Assignments Assignment - In progress Add attachment(s), then choose the appropriate button at the bottom.

Draft - In progress Submitted Returned Title Project 2 - 2D animation Due Sep 28, 2021 11:55 PM Number of resubmissions allowed 0 Status Not Started Grade Scale Points (max 100.00)

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 di�erent images, and synthesize a new image by putting di�erent images together, and display the �nal image sequentially to screen. 

 

Project Description:

This animation is about a dinosaur chasing a girl in the forest. To achieve this e�ect, 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 �exible, 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 di�erent images (about di�erent poses of the girl and dinosaur) and copy them into the �nal image sequentially,  meanwhile copy di�erent parts of the background image using slide window mechanism to generate the animation e�ects. All the images involved for this animation have been provided in the attachment.

 

Project Goal:

Get familiar with OpenCV by practicing di�erent 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.

 

9/19/21, 2:58 PM Isidore : 21_FA_FT_CPS_667_02 : Assignments

https://isidore.udayton.edu/portal/site/180e87a5-8de8-45da-9176-ed9a0345f68f/tool/165088f0-24a8-4265-9f55-8a09f7193a10?panel=Main 2/2

Suggested Steps:

(1) To get started, you �rst 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, di�erent 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 di�erent part of the “bg_scene.jpg” into the screen image to generate a moving e�ect. This part is talked in the class.

 

Rubrics:

(1)  Successfully generate animation for the girl and the dinosaur (20%)

use copyTo( ) and Range( ) to copy a girl (or dinosaur) image to the screen  correctly use mask image use a loop to copy di�erent posed �gure into the screen 

(2) Successfully generate rolling background (30%)

(3) Your program allows user to use 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 (25%)

(4) Your program also allows user to use mouse to drag the girl or dinosaur to a particular position (25%)

Additional resources for assignment

imgs (2).zip ( 1 MB; Sep 18, 2021 1:24 pm )

Submission Attachments No attachments yet

Select a �le from computer No �le chosenChoose File

Proceed Preview Save Draft Cancel  Don't forget to save or proceed!