jeudi 23 avril 2015

How to creat new class in order to deploy opencv an object's methods

Assumed that i need to show an openCV image in Qt creator.

My image declared with cv::Mat type, but openCV has no member that allow we put image in to Qt application GUI.

Furthermore, i want my code can use this syntax: "image.displayinGUI()" (where image is cv::Mat type). I know how to display image in Qt but just don't know right design pattern to deploy my program reasonably!

So , what should i do to do that?

(I'm sorry because i'm c++ newbie and my english is not well)

I wrote this scenario but it not work:

class usergui : public cv::Mat {
public:
    displayinGUI( QLabel* label ) {
        cv::Mat newimg = this->clone();
        cv::cvtColor( newimg , newimg , CV_BGR2RGB );
        QImage image = QImage((const unsigned char*)newimg.data , newimg.cols , newimg.rows , QImage::Format_RGB888);
        label->setPixmap(QPixmap::fromImage(image));
        label->resize(label->pixmap()->size());
    }
}

Aucun commentaire:

Enregistrer un commentaire