Multimedia Programming 10: Mouse, Draw and Morphing Departments of Digital Contents Sang Il Park.

Slides:



Advertisements
Similar presentations
OpenGL Open a Win32 Console Application in Microsoft Visual C++.
Advertisements

Introduction to Programming
Class 15 - Overhead 11Object Oriented Programming Using C #define t_circle 1 #define t_rectangle 2 struct circle_shape {short type; double x,y; double.
1 Drawing C Sc 335 Object-Oriented Programming and Design Rick Mercer.
1 Computer Graphics Chapter 2 Input Devices. RM[2]-2 Input Devices Logical Input Devices  Categorized based on functional characteristics.  Each device.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 21 - “Cat and Mouse” Painter Application.
Chapter 5 Creating an Image Map.
Image Maps and Graphics Internet Basics and Far Beyond! Mrs. Wilson.
CS 4731 Lecture 2: Intro to 2D, 3D, OpenGL and GLUT (Part I) Emmanuel Agu.
Objects and Classes First Programming Concepts. 14/10/2004Lecture 1a: Introduction 2 Fundamental Concepts object class method parameter data type.
Macromedia Flash 5 Intermediate Level Course. Animation Basics Playhead In-Between Frames Keyframe Current Frame Number Framerate Current Time Frames.
1 Applets Chapter 1 To understand:  why applets are used to extend the capabilities of Web pages  how an applet is executed and know about the restrictions.
C++ Graphics Primitives April 15th. void clearscreen(int c) –clear the screen to background color c –If c = 1 screen black.
Event Handling. In this class we will cover: Keyboard Events Mouse Events Focus Events Action Interface Multicasting.
Abstraction: Polymorphism, pt. 1 Abstracting Objects.
Using Graphics Libraries Lecture 3 Mon, Sep 1, 2003.
Events and Coordinates Lecture 5 Fri, Sep 5, 2003.
Detect Candle.  Open VC++ Directories configuration: Tools > Options > Projects and Solutions > VC++ Directories  Choose "Show directories for: Include.
EzWindows API A Graphical Application Programmer Interface JPC and JWD © 2002 McGraw-Hill, Inc.
Graphics and Multimedia Part #2
Written by: Itzik Ben Shabat Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering Lab.
Multimedia Programming 02: Play with Images Departments of Digital Contents Sang Il Park.
Prepared by Fareeha Lecturer DCS IIUI 1 Windows API.
Overview of Previous Lesson(s) Over View  Visual C++ provides us with 3 basic ways of creating an interactive Windows application  Using the Windows.
Multimedia Programming 03: Point Processing Departments of Digital Contents Sang Il Park.
GRAPHICS AND MOUSE PROGRAMMING IN C. Turbo C has a good collection of graphics libraries. If you know the basics of C, you can easily learn graphics programming.
FLTK Help Session By Richard Yu Gu CS 638 -Graphics Fall, 1999.
Multimedia Programming 13: Review and term project Departments of Digital Contents Sang Il Park.
Introduction of OpenCV Alireza Shirani Researcher of Medical Image and Signal Processing M. S Electrical Engineering yahoo. com Spring.
Introduction to Java Simple Graphics. Objects and Methods Recall that a method is an action which can be performed by an object. –The action takes place.
CSCE 121: Introduction to Program Design and Concepts, Honors Dr. J. Michael Moore Spring 2015 Set 15: GUIs 1.
PowerPoint Basics Tutorial 1: Objects These tutorials will introduce you to the most basic and useful functions of Microsoft PowerPoint We’re going.
Graphic Basics in C ATS 315. The Graphics Window Will look something like this.
Using PowerPoint. HOW TO INSERT A SHAPE  Find the task bar click on insert.  Click on shapes.  Find the shape you want and click on it.  A cross should.
Some Graphics CS303E: Elements of Computers and Programming.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 21 - “Cat and Mouse” Painter Application.
The Abstract Window Toolkit (AWT) supports Graphical User Interface (GUI) programming. AWT features include: a rich set of user interface components; a.
Variables Art &Technology, 3rd Semester Aalborg University Programming David Meredith
Object Oriented Programming A new way of thinking.
Graphics Concepts CS 2302, Fall /17/20142 Drawing in Android.
Getting to Know OpenCV 主講人:虞台文. Content Basic Structures Arrays, Matrices, and Images Matrix and Image Operators Drawing Things Drawing Text Data Persistence.
1 Project designed and created by M. Shajith Kumar.
Review_6 AWT, Swing, ActionListener, and Graphics.
1 Mapping Coordinates Find the x- and y- coordinates for the images, relative to the x-axis and y-axis In a coordinate pair, the first number is the x-coordinate.
Week 8 - Friday.  What did we talk about last time?  Static methods.
From last time… Explore the blue commands from the motion menu Find at least three ways to get the sprite to move to the UPPER LEFT corner.
Multimedia Programming 04: 점, 선, 면
1 Event Driven Programs Rick Mercer. 2 So what happens next?  You can layout a real pretty GUI  You can click on buttons, enter text into a text field,
School of Computing and Information Systems RIA Animation, part I.
Multimedia Programming 10: Image Morphing
Equations of Circles. You can write an equation of a circle in a coordinate plane, if you know: Its radius The coordinates of its center.
Example: warping triangles Given two triangles: ABC and A’B’C’ in 2D (12 numbers) Need to find transform T to transfer all pixels from one to the other.
When I am embedding under, I do not close the li tag until I complete the items that are embedded. Looking at outlines.
Transparency 9 Click the mouse button or press the Space Bar to display the answers.
Chapter 14 Timers and Idle Processing Department of Digital Contents Sang Il Park.
Graphics Lab: MyPaint Dan Maselko 1. MyPaint Description  For this assignment you will be implementing a very simple paint program.  You should be able.
VG101 RECITATION 5 By TAs. CONTENTS How to read Vg101Class.h Samples about graphics About assignment 5 Array.
Multimedia Programming 12: Mouse, Draw and Morphing2 Departments of Digital Contents Sang Il Park.
10/20/2005week71 Graphics, mouse and mouse motion events, KeyEvent Agenda Classes in AWT for graphics Example java programs –Graphics –Mouse events –Mouse.
THE MOUSE Left Click THE MOUSE Right Click.
Scratch for Interactivity
Introduction to Event-Driven Programming
Java Applet.
Control structures Chapter 3.
Miscellaneous Topics #6: Polygons GUI Components and Event Handlers
The User Interface Lecture 2 Mon, Aug 27, 2007.
Drawing Two-Dimensional Shapes with Digital Technology
Lesson 17: Building an App: Canvas Painter
Getting Started with Milestone 2
Spell your name using word art from above
Presentation transcript:

Multimedia Programming 10: Mouse, Draw and Morphing Departments of Digital Contents Sang Il Park

Outline Review Mouse Callback in OpenCV Draw Morphing

Review Image Morphing 1.Create an intermediate shape (by interpolation) 2.Warp both images towards it 3.Cross-dissolve the colors in the newly warped images

Mouse Callback in OpenCV Mouse Interaction with OpenCV

Mouse With OPENCV

Keyboard With OPENCV int cvWaitKey(interval)

Mouse With OPENCV cvSetMouseCallback(…)

Mouse Callback? Callback: –executable code that is passed as an argument to other code.executable codeargument Mouse Callback: –A function that is called when any change happens in your mouse –Examples) Mouse Move Left(right) Button Down(Up), Double click …

Mouse Callback Two things you have to do: –Implementation Define what you are going to do when events happen –Setting (registration) Let the OpenCV know which one is the callback function void cvSetMouseCallback(window_name, yourFunction) void yourFunction (int event, int x, int y, int flags, void *param);

Implementation You can make your own function name Example) on_mouse, myMouse, … Parameters are for the information about the incoming mouse event from OvenCV void yourFunction (int event, int x, int y, int flags, void *param);

Implementation Message from the OpenCV Telling what kind of the mouse event is coming Examples) CV_EVENT_MOUSEMOVE CV_EVENT_LBUTTONDOWN CV_EVENT_RBUTTONDOWN CV_EVENT_MBUTTONDOWN CV_EVENT_LBUTTONUP CV_EVENT_RBUTTONUP CV_EVENT_MBUTTONUP CV_EVENT_LBUTTONDBLCLK CV_EVENT_RBUTTONDBLCLK CV_EVENT_MBUTTONDBLCLK void yourFunction (int event, int x, int y, int flags, void *param);

Implementation Message from the OpenCV Mouse position (x,y) Based on the Image Coordinate System y (0,0)(8,2) x void yourFunction (int event, int x, int y, int flags, void *param);

Implementation Message from the OpenCV Telling the status of the mouse or the keyboard Examples) CV_EVENT_FLAG_LBUTTON CV_EVENT_FLAG_RBUTTON CV_EVENT_FLAG_MBUTTON CV_EVENT_FLAG_CTRLKEY CV_EVENT_FLAG_SHIFTKEY CV_EVENT_FLAG_ALTKEY void yourFunction (int event, int x, int y, int flags, void *param);

Registration Example) cvSetMouseCallback( “test”, on_mouse); void cvSetMouseCallback(window_name, yourFunction)

Coding Practice Put a point when you click your left button. void myMouse(int event, int x, int y, int flags, void * param) { if(event == CV_EVENT_LBUTTONDOWN) { cvSet2D(img, y, x, CV_RGB(0,0,0)); cvShowImage(“test”, img); } 1. Implement your function 2. Register your function in main() cvSetMouseCallback(“test”, myMouse);

Using a Palette Get color when you click your left button. void myMouse2(int event, int x, int y, int flags, void * param) { if(event == CV_EVENT_LBUTTONDOWN) { s = cvGet2D(img, y, x); } Implement your function

Draw Line void cvLine( IplImage, CvPoint pt1, CvPoint pt2, CvScalar color, int thickness=1); Draw Line from pt1 to pt2 with the given thickness CvPoint: a structure for storing 2D position –Use cvPoint(x,y) for a quick usage. struct CvPoint { int x; // x-coordinate int y; // y-coordinate } struct CvPoint { int x; // x-coordinate int y; // y-coordinate }

Draw Rectangle void cvRectangle( IplImage, CvPoint pt1, CvPoint pt2, CvScalar color, int thickness=1 ) void cvRectangle( IplImage, CvPoint pt1, CvPoint pt2, CvScalar color, int thickness=1 ) Draw a rectangle with two opposite corners pt1 and pt2 pt1 pt2 What happens if thickness is -1?

Draw Circle void cvCircle( IplImage, CvPoint center, int radius, CvScalar color, int thickness=1 ) void cvCircle( IplImage, CvPoint center, int radius, CvScalar color, int thickness=1 ) Draw a circle with given center and radius center radius

Basic Morphing with Mouse Moving one point to the other

Basic Morphing with Mouse Moving one point to the other

Basic Morphing with Mouse Moving one point to the other

Basic Morphing with Mouse Moving one point to the other

Bilinear interpolation Sampling at f(x,y): displacement at (x,y)

Basic Morphing with Mouse Moving one point to the other

? Basic Morphing with Mouse Moving one point to the other

Basic Morphing with Mouse Moving one point to the other

? Basic Morphing with Mouse Moving one point to the other