PDA

View Full Version : Displaying OpenCV Points using Qt



imagyne
12th July 2011, 15:56
Hi,

Using OpenCV, I have calculated image features, which are stored in a data structure of points. I have to display those point coordinates as circles on the image open in Qt.

I am unable to convert the coordinates of the OpenCV points to Qt.

This is how I am able to display the points in OpenCV (taken from the OpenCV codebook)


void drawOnImage(cv::Mat &image, const std::vector<cv::Point> &points, cv::Scalar color= cv::Scalar(255,255,255), int radius=1, int thickness=1) {
std::vector<cv::Point>::const_iterator it= points.begin();

// for all corners
while (it!=points.end()) {

// draw a circle at each corner location
cv::circle(image,*it,radius,color,thickness);
++it;
}
}

Now, I want to pass the const std::vector<cv::Point> &points to the mainwindow.h and then in mainwindow.cpp, using the coordinates of the points, print them on the Qt image using Qt Ecllipse tool.

Anyone can help? Thanks!

d_stranz
12th July 2011, 17:10
So what are the units of cv::Point? Pixels? Points? Fractions of image width? Megaparsecs? If a cv::Point describes a location in the image, there is certainly a conversion between that location and the corresponding location in the image after conversion to QImage or QPixmap.

You will likewise need to convert "radius" from its units in cv-space to pixels in Qt image space.

imagyne
13th July 2011, 15:01
Done, thank you.