35 lines
727 B
C++
35 lines
727 B
C++
#pragma once
|
||
|
||
#include <QWidget>
|
||
#include <QLabel>
|
||
#include <QGraphicsView>
|
||
#include <QPixmap>
|
||
#include <QPainter>
|
||
|
||
#include <opencv2/opencv.hpp>
|
||
|
||
class CvImageViewWidget :public QLabel
|
||
{
|
||
Q_OBJECT
|
||
|
||
public:
|
||
CvImageViewWidget(QWidget* parent = Q_NULLPTR);
|
||
virtual ~CvImageViewWidget() {}
|
||
|
||
public:
|
||
void showImage(cv::Mat const& _himg);
|
||
|
||
static void CvImageToQPixmap(cv::Mat const& _img, QPixmap& tarImg);
|
||
static bool QImage2CvImage(QImage& from, cv::Mat& to);
|
||
static void QPixmapToCvRegion(QPixmap const& _pix, cv::Rect2d& tarImg);
|
||
|
||
protected:
|
||
void paintEvent(QPaintEvent* event) override;
|
||
|
||
private:
|
||
cv::Mat curImage;
|
||
QPixmap* curPixmap;
|
||
// 实例化画家对象,this指定的是绘图设备
|
||
QPainter painter;
|
||
};
|