Mastodon

Casting between Qt and OpenCV primitives

opencv_qtAs a follow-up to the previous post, I’d like to present some code which I think might be helpful for other Qt / OpenCV projects as well.

This code was written for Pastie. Pastie is a piece of software I wrote as part my image processing seminar. It makes use of the well known libraries:

  • Qt for the graphical user interface
  • OpenCV for image processing and computer vision

I wrote a C++ header file to facilitate the co-operation of those two libraries. This file enables the conversion / casting of OpenCV and Qt types e.g.:

#include <QImage>
#include <cv/core.hpp>

QImage qimg("filename.png");
cv::Mat cvimg = toCv(qimg);

The source code is available at GitHub.

The following conversions are supported:

QImage cv::Mat
QTransform cv::Mat
QPoint cv::Point2i
QPointF cv::Point2f
QRect cv::Rect2i
QRectF cv::Rect2f
QSize cv::Size

You can find some examples in the real code here and here.

Neuer Blog Header

So dazu wurde es aber auch mal wieder Zeit! Das alte Bild wurde mir mit der Zeit einfach viel zu dunkel, schwer und bedrückend. Also musste etwas neues, leichtes her. Das Bild stammt aus meiner Grönland Reise letztes Jahr. Mit meinem Versuch Natur und Technologie in einem Bild zu vereinen bin ich noch nicht ganz zufrieden. Da wird noch etwas Bastelarbeit von Nöten sein.

Aber noch ist der Header ja nicht ganz fertig. Ich freue mich über alle Anregungen, Kritiken und Kommentare :p Also los!

Wie wäre es zum Beispiel mit einem saisionalen Header?