RTMaps Support

Magnifying glass

MAGNIFYING GLASS

point tracking component and magnifyer effect

 

Duration : 15 min

Download pdf file

If you do not have a webcam, download and use this 30’ webcam database (zip)

 

 

OBJECTIVES

  • Manipulate RTMaps Studio
  • Use the OpenCV Library
  • Algorithms
  • Register Data

 

KEYWORDS

  • RTMaps Studio
  • Algorithms
  • Image Processing
  • Point Tracking

 

USED COMPONENT

Webcams, Viewers, Colorspace Converter, Player, Objects Viewer, Overlay Drawing, Points Tracking, Magnifying Glass, Recorder, Snapshot…

 

PREREQUISITE

Before starting this tutorial, you should have done the RTMaps Magical Tour and the RTMaps Pop’Art algorithms tutorials

 

 

THE MAGNIFYING GLASS COMPONENT

The video source

Launch RTMaps Studio, drag and drop a video source on your diagram. Like in the previous tutorial, you can use a webcam as well as a RTMaps database including an image flow (with a player component).

 

img2

 

To use a webcam component, register the rtmaps_webcam.pck package. Drag on your diagram a webcam component, edit its properties and choose the RGB Video Format (you will find more explanations about the video format in the Red Blobs Detection Tutorial).

To use a database, Drag and drop a Player component on your diagram, edit its properties and browse for a RTMaps database. For example: C:\Program Files\Intempora\RTMaps3.4\samples\databases\tutorial_video. Use an image viewer to check your video source.

Save your diagram

 

 

 

 

THE MAGNIFYING GLASS ALGORITHM

The magnifying glass component

This component performs a magnifying glass effect in an area of the video. Register the rtmaps_image_processing_miscellaneous.pck package. In the rtmaps_image_processing_miscellaneous section from the component list window, you’ll find the Magnifying Glass component. Drag and drop it on your diagram. Drag and drop an image viewer too. Connect your webcam component to the magnifying Glass and then to a new image viewer. Note that the center of the image is distorted.

 

img3

 

 

Controlling the effect position

The image viewer provides two outputs: MouseClicks and ROI. MouseClick outputs the coordinates of the mouse when you click in the display window created by the image viewer component. Edit the properties of the magnifying glass and parameterize it choosing coordinates (in pixels) in the UseSettingInput property. A second input called PixelCoords is created. Connect the MouseClick output of the viewer to this new input. Run the diagram. Now, when you click on the image, the video effect is centered at the position of the mouse click. Shutdown the diagram.

 

img4

 

Note : diagram and readability - when the diagram becomes complex, don’t forget to affect colours and breaks to your connexions in order to have a more understandable diagram (right click on the wire).

 

 

FOLLOWING THE POINT

Point Tracking

This component will follow the point you will indicate as long as it stays in the image. Register the rtmaps_image_processing_opencv.pck package and then drag and drop a point tracking component to your diagram. Connect the webcam output to the image input of the point tracking component. Disconnect the connexion between the image viewer output and the second input of the magnifying glass (right click>disconnect). Connect the mouseclick output of the image viewer to points to track in put of the point tracking component. Finally, connect the first output of the point tracking (TRackedPointsCoord) to the second input of the magnifying glass (PixelsCoords).

 

img5

 

POINTS AND OBJECTS VIEWERS

Display the tracked points

In the viewers section of the component list, drag and drop an Objects Viewer to the diagram (on the right of the point tracking component). Connect the 2nd output of the point tracking (trackedPointObject) to the object viewer. The size of the object viewer is 256x256 by default. You can parameterize it in the object viewer properties to obtain the same size as the images from your webcam (320x240 for example). Run the application and click somewhere in the viewer; a red point appears. If the object is moving, the point moves with it. Shutdown the diagram.


Note : the autoInitFunction: Instead of tracking one point, the autoInitFunction finds the N points easier to track in the image. This function is accessible with a right click on the component.

 

img6

 

 

Overlay Drawing

You can also overlay the point into the image. Use an overlay drawing component, available in the viewers section of the component list. Install this component between, the magnifying glass and the corresponding image viewer. Disconnect the wire and reconnect it with the overlay drawing inbetween. Connect the TrackedPointObjects output of the point tracking to the drawing objects input of the overlay drawing. Connect the overlay drawing to the viewer. Run the application. Shutdown the diagram.

 

img7

 

 

 

RECORDING DATABASE AND/OR Avi FILES

RTMaps Database

Place a recorder component (available in the Players - Recorders list) on the diagram. Connect the webcam output to the recorder input. Click OK in the small dialog box (leave the default options as they are). A new input is automatically created. Connect, for example, the data from the OverlayDrawing output. You can connect any data you want to the Recorder. In its properties, choose the folder where you want the database files to be created. Now, each time you will run the application, the data will be recorded. Run the application for some time. Then shutdown the diagram.

 

img8

 

 

Replaying your own Data

Remove the Recorder component from the diagram with a right Click on it (Kill component). Remove the webcam component and place a Player component instead. In the player properties, browse for the .rec file in the folder you have just chosen before. You will find as much outputs as data tracks you have recorded. If you have followed this tutorial, the Player then provides 2 videos flows, one corresponding to the webcam raw images and one with the tracked points and the magnifying glass effect. Connect two viewers to confirm that. You can also continue by connecting any component you want.

 

img9

 

 

Snapshot

To conserve an image in a jpg file, choose a Snapshot in the Image processing section of the component list and place it on the diagram. Connect its input to the Player (or to a webcam component). Connect its output to a Recorder and choose jpeg as a recording method. In the Recorder properties, browse for the folder where you want to record your snapshot. In the Sensors section, choose a Keyboard component. Connect its output to the trigger snapshot input of the Snapshot component. Each time you will press any key, a jpg file will be recorded in the folder you’ve chosen.

 

magni0010



Note: you can not use all the VCR functionalities when using a diagram containing both a Player and a Recorder.