PCL Developers blog

Kripasindhu Sarkar

email:krips.from.iit.kgp@gmail.com
project:2D Image Drawing Operators from VTK
mentor:Marcus Hanwell and Pat Marion

About me

I am a 5th year Dual Degree undergraduate student of the Department of Computer Science and Engineering at Indian Institute of Technology, Kharagpur. I am done with my final semester and expecting to get my degrees in the month of August.

I am very interested in the field of Computer Vision and Graphics and wish to do higher studies after a year. Before that I will be doing a job as a Software Engineer in Ebay/Paypal Ltd., India.

Project Description

The purpose of the project is to Implement and document various drawing functions using VTK in PCL. Drawing functions include primitive drawings such as lines, circles, polygons etc. as well as alpha blended polygons and graphs, both 2D and 3D, for visualizing histograms and other functions.

Roadmap

The boldfaced bullets represent my current position.

  • Get familiar with ssh, svn, cmake, ReST and Unix.
  • Fill out this page.
  • Get familiar with ‘modern c++’.
  • Know the internal working of PCLVisualizer.
  • Finalize the design of the ‘Plotter class’ I will be developing by PCL developer community.
  • Develop PCLPlotter class - completed; ask for features if you want something to be added
  • Design the 2D drawing class (PCLPainter2D)
  • Develop PCLPainter2D class based on the design- completed; ask for features if you want something to be added
  • Improve and add additional features to PCLPlotter and PCLPainter2D
  • Write tutorials
  • Append this roadmap with next immediate goals.

Recent status updates

Tutorials, bug with pcd_viewer, PCLVisualizer and important additions
Thursday, August 16, 2012
../../_images/gsoc127.png

Wrote tutorials for the 2D classes. Got another weird bug found by Radu. Plotter not working in pcd_viewer on point picking. Still struggling in it.

Tried to make PCLVisualizer cleaner and readable. Removed some unnecessary function calls. Didn’t commit yet.

Added some important functionalities in Plotter and a seperate vtkCommand event handler.

Bugs and additional features
Tuesday, August 07, 2012
../../_images/gsoc127.png

Fixing bugs takes time. PCLPlotter was behaving weird in pcd_viewer. A window was appearing just after the creation of an object of 2D classes (Plotter and Painter2D) without even the call of plot/spin/display functions. Thus, had to move vtkRenderwindowInteractor::Initialize() and therefore vtkRenderwindowInteractor::AddObserver() to the display triggering calls (plot/spin/display).

Added other small functionalities like setTitle* in Plotter.

Additional features and spin*() functions
Tuesday, July 31, 2012
../../_images/gsoc127.png

As I posted before, my work is now to improve and add additional features to my two classes PCLPlotter and PCLPainter2D. I always had in my mind that I will add spin*() functions (spinOnce(time) and spin()), which are a part of all the existing visualization classes (like PCLVisualizer, PCLHistogramVisualizer, etc), to my classes. Frankly, I did not understand these functions much based on the documentation and the code, perhaps because of my no knowledge of vtk’s event handling (vtkCommand and all). All I knew that this functions someway start the interactor.

So, I finally understood those function after getting familiar to vtkCommand and going through their implementation. I kind of find the names confusing. spinOnce(t) runs the interactor event-loop for time t. spinOnce sounds like spinning (looping) one time which is confusing. spin() runs the interactor event-loop for indefinite time using spinOnce(t) thereby providing the ability to update the scene with time. But following is the description for spin() provided in the documentation in verbatim: “Calls the interactor and runs an internal loop.”. Either I am missing out something or the documentation is misleading!

Apart from the above, I was stuck for the most of the time figuring out the usage of RepeatingTimer. The repeating timer event is caught and the timer is destroyed- right in the first time! A SingleShotTimer very well suited this purpose. I did not understand the use of RepeatingTimer. I used SingleShotTimer in my spin* methods and it works as it should.

Other than spin*() functions, I added other features about which I will post in the next blog. I would also like to comment here on the general design of the “visualizer”s in pcl. Unfortunately, blogging takes time and I will post about them in the next few days, one by one.

PCLPainter2D
Sunday, July 22, 2012
../../_images/gsoc127.png

I added all the transform functionality in the Painter2D class now. So, one can perform transform operations like:

painter.addCircle(0,0,5);

painter.translatePen(5,0);

painter.addCircle(0,0,5);

painter.setIdentityTransform();

. . .

Since applying transform is a real time operation, it is required to keep track of when it is called. I solved this issue in similar way I tackled the underlaying vtkPen and vtkBrush. I stored a transformation matrix for each of the figure and updated it with the current transform stored in the painter class as state. Like I said before, implementation of this 2D class was not straightforward as I thought before. In fact it has been full of tricks.

Adding this functionality more or less completes the Painter2D class and my proposed work for the gsoc. For the rest of the period I will try to improve these two classes (PCLPlotter and PCLPainter2D) and add more features on request. So, if you think something should be added just email me; I will add if I think it is feasible ;-) I will also probably be assigned more work by Alex.

PCLPainter2D
Tuesday, July 17, 2012
../../_images/gsoc127.png

OK, so PCLPainter2D class is now available in the trunk. Currently it allows user to draw all the 2D primitives. The usage is same as discussed in design:

PCLPainter2D painter;

painter.addCircle(0,0,5);

. . .

painter.display();

The implementation is also exactly same as discussed in the previous blog. I’m storing drawing information in a data structure which is a vector of a class Figure2D. Later I’m using this information to re-implement paint() of the contextItem class (PCLPainter2D).