2023-02-28 14:50:28 +08:00

35 lines
727 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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;
};