New functions with QT GUI:
- save/load window parameters implemented !
This commit is contained in:
@@ -67,6 +67,8 @@ CV_EXPORTS double getWindowProperty(const string& winname, int prop_id);//YV
|
|||||||
//Only for QT
|
//Only for QT
|
||||||
CV_EXPORTS void displayOverlay(const string& winname, const string& text, int delayms);
|
CV_EXPORTS void displayOverlay(const string& winname, const string& text, int delayms);
|
||||||
CV_EXPORTS void displayStatusBar(const string& winname, const string& text, int delayms);
|
CV_EXPORTS void displayStatusBar(const string& winname, const string& text, int delayms);
|
||||||
|
CV_EXPORTS void saveWindowParameters(const string& windowName);
|
||||||
|
CV_EXPORTS void loadWindowParameters(const string& windowName);
|
||||||
CV_EXPORTS int startLoop(int (*pt2Func)(int argc, char *argv[]), int argc, char* argv[]);
|
CV_EXPORTS int startLoop(int (*pt2Func)(int argc, char *argv[]), int argc, char* argv[]);
|
||||||
CV_EXPORTS void stopLoop();
|
CV_EXPORTS void stopLoop();
|
||||||
|
|
||||||
|
@@ -60,6 +60,8 @@ extern "C" {
|
|||||||
//-----------New for QT
|
//-----------New for QT
|
||||||
CVAPI(void) cvDisplayOverlay(const char* name, const char* text, int delayms);
|
CVAPI(void) cvDisplayOverlay(const char* name, const char* text, int delayms);
|
||||||
CVAPI(void) cvDisplayStatusBar(const char* name, const char* text, int delayms);
|
CVAPI(void) cvDisplayStatusBar(const char* name, const char* text, int delayms);
|
||||||
|
CVAPI(void) cvSaveWindowParameters(const char* name);
|
||||||
|
CVAPI(void) cvLoadWindowParameters(const char* name);
|
||||||
CVAPI(int) cvStartLoop(int (*pt2Func)(int argc, char *argv[]), int argc, char* argv[]);
|
CVAPI(int) cvStartLoop(int (*pt2Func)(int argc, char *argv[]), int argc, char* argv[]);
|
||||||
CVAPI(void) cvStopLoop();
|
CVAPI(void) cvStopLoop();
|
||||||
//----------------------
|
//----------------------
|
||||||
|
@@ -160,6 +160,16 @@ int waitKey(int delay)
|
|||||||
return cvWaitKey(delay);
|
return cvWaitKey(delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void saveWindowParameters(const string& windowName)
|
||||||
|
{
|
||||||
|
cvSaveWindowParameters(windowName.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
void loadWindowParameters(const string& windowName)
|
||||||
|
{
|
||||||
|
cvLoadWindowParameters(windowName.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
int createTrackbar(const string& trackbarName, const string& winName,
|
int createTrackbar(const string& trackbarName, const string& winName,
|
||||||
int* value, int count, TrackbarCallback callback,
|
int* value, int count, TrackbarCallback callback,
|
||||||
void* userdata)
|
void* userdata)
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -69,6 +69,7 @@
|
|||||||
#include <QIODevice>
|
#include <QIODevice>
|
||||||
#include <QShortcut>
|
#include <QShortcut>
|
||||||
#include <QStatusBar>
|
#include <QStatusBar>
|
||||||
|
#include <QVarLengthArray>
|
||||||
|
|
||||||
//Macro here
|
//Macro here
|
||||||
#define CV_MODE_NORMAL 0
|
#define CV_MODE_NORMAL 0
|
||||||
@@ -108,7 +109,9 @@ public slots:
|
|||||||
double getPropWindow(QString name);
|
double getPropWindow(QString name);
|
||||||
void setPropWindow(QString name, double flags );
|
void setPropWindow(QString name, double flags );
|
||||||
double getRatioWindow(QString name);
|
double getRatioWindow(QString name);
|
||||||
void setRatioWindow(QString name, double arg2 );
|
void setRatioWindow(QString name, double arg2 );
|
||||||
|
void saveWindowParameters(QString name);
|
||||||
|
void loadWindowParameters(QString name);
|
||||||
};
|
};
|
||||||
|
|
||||||
class CvTrackbar : public QHBoxLayout
|
class CvTrackbar : public QHBoxLayout
|
||||||
@@ -133,6 +136,7 @@ private:
|
|||||||
CvTrackbarCallback callback;
|
CvTrackbarCallback callback;
|
||||||
QPointer<CvWindow> parent;
|
QPointer<CvWindow> parent;
|
||||||
int* dataSlider;
|
int* dataSlider;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class CvWindow : public QWidget
|
class CvWindow : public QWidget
|
||||||
@@ -146,37 +150,39 @@ public:
|
|||||||
void updateImage(void* arr);
|
void updateImage(void* arr);
|
||||||
void displayInfo(QString text, int delayms );
|
void displayInfo(QString text, int delayms );
|
||||||
void displayStatusBar(QString text, int delayms );
|
void displayStatusBar(QString text, int delayms );
|
||||||
|
void readSettings();
|
||||||
|
void writeSettings();
|
||||||
ViewPort* getView();
|
ViewPort* getView();
|
||||||
|
|
||||||
QString name;
|
|
||||||
int flags;
|
|
||||||
QPointer<QBoxLayout> layout;
|
QPointer<QBoxLayout> layout;
|
||||||
QPointer<QStatusBar> myBar;
|
QPointer<QStatusBar> myBar;
|
||||||
QPointer<QLabel> myBar_msg;
|
QPointer<QLabel> myBar_msg;
|
||||||
//QPointer<CustomLayout> layout;
|
|
||||||
|
//parameters (will be save/load)
|
||||||
|
QString param_name;
|
||||||
|
int param_flags;
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void readSettings();
|
|
||||||
void writeSettings();
|
|
||||||
|
|
||||||
virtual void keyPressEvent(QKeyEvent *event);
|
virtual void keyPressEvent(QKeyEvent *event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPointer<ViewPort> myview;
|
QPointer<ViewPort> myview;
|
||||||
|
QPointer<QShortcut> shortcutZ;
|
||||||
|
QPointer<QShortcut> shortcutPlus;
|
||||||
|
QPointer<QShortcut> shortcutMinus;
|
||||||
|
QPointer<QShortcut> shortcutLeft;
|
||||||
|
QPointer<QShortcut> shortcutRight;
|
||||||
|
QPointer<QShortcut> shortcutUp;
|
||||||
|
QPointer<QShortcut> shortcutDown;
|
||||||
|
|
||||||
int status;//0 normal, 1 fullscreen (YV)
|
void icvLoadTrackbars(QSettings *settings);
|
||||||
QPointer<QShortcut> shortcut_r_Zoom;
|
void icvSaveTrackbars(QSettings *settings);
|
||||||
QPointer<QShortcut> shortcut_imgRegion;
|
|
||||||
QPointer<QShortcut> shortcut_Plus;
|
|
||||||
QPointer<QShortcut> shortcut_Minus;
|
|
||||||
QPointer<QShortcut> shortcut_Left;
|
|
||||||
QPointer<QShortcut> shortcut_Right;
|
|
||||||
QPointer<QShortcut> shortcut_Up;
|
|
||||||
QPointer<QShortcut> shortcut_Down;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
enum type_mouse_event {mouse_up = 0, mouse_down = 1, mouse_dbclick = 2, mouse_move = 3};
|
enum type_mouse_event {mouse_up = 0, mouse_down = 1, mouse_dbclick = 2, mouse_move = 3};
|
||||||
|
|
||||||
static const int tableMouseButtons[][3]={
|
static const int tableMouseButtons[][3]={
|
||||||
@@ -186,6 +192,7 @@ static const int tableMouseButtons[][3]={
|
|||||||
{CV_EVENT_MOUSEMOVE,CV_EVENT_MOUSEMOVE,CV_EVENT_MOUSEMOVE} //mouse_move
|
{CV_EVENT_MOUSEMOVE,CV_EVENT_MOUSEMOVE,CV_EVENT_MOUSEMOVE} //mouse_move
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class ViewPort : public QGraphicsView
|
class ViewPort : public QGraphicsView
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -195,20 +202,24 @@ public:
|
|||||||
void updateImage(void* arr);
|
void updateImage(void* arr);
|
||||||
void startDisplayInfo(QString text, int delayms);
|
void startDisplayInfo(QString text, int delayms);
|
||||||
void setMouseCallBack(CvMouseCallback m, void* param);
|
void setMouseCallBack(CvMouseCallback m, void* param);
|
||||||
|
int getRatio();
|
||||||
|
void setRatio(int arg);
|
||||||
|
|
||||||
|
//parameters (will be save/load)
|
||||||
|
QTransform param_matrixWorld;
|
||||||
|
|
||||||
|
int param_keepRatio;
|
||||||
|
|
||||||
IplImage* image2Draw_ipl;
|
IplImage* image2Draw_ipl;
|
||||||
QImage image2Draw_qt;
|
QImage image2Draw_qt;
|
||||||
|
int mode_display;//opengl or native
|
||||||
int nbChannelOriginImage;
|
int nbChannelOriginImage;
|
||||||
void setRatio(int flags);
|
|
||||||
int getRatio();
|
|
||||||
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
//reference:
|
//reference:
|
||||||
//http://www.qtcentre.org/wiki/index.php?title=QGraphicsView:_Smooth_Panning_and_Zooming
|
//http://www.qtcentre.org/wiki/index.php?title=QGraphicsView:_Smooth_Panning_and_Zooming
|
||||||
//http://doc.qt.nokia.com/4.6/gestures-imagegestures-imagewidget-cpp.html
|
//http://doc.qt.nokia.com/4.6/gestures-imagegestures-imagewidget-cpp.html
|
||||||
void scaleView(qreal scaleFactor, QPointF center, bool process1stParam);
|
void scaleView(qreal scaleFactor, QPointF center);
|
||||||
void imgRegion( );
|
|
||||||
void moveView(QPointF delta);
|
void moveView(QPointF delta);
|
||||||
void resetZoom();
|
void resetZoom();
|
||||||
void ZoomIn();
|
void ZoomIn();
|
||||||
@@ -220,21 +231,14 @@ public slots:
|
|||||||
void resizeEvent ( QResizeEvent * );
|
void resizeEvent ( QResizeEvent * );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPoint deltaOffset;
|
|
||||||
QPoint computeOffset();
|
|
||||||
QPoint mouseCoordinate;
|
QPoint mouseCoordinate;
|
||||||
QPointF positionGrabbing;
|
QPointF positionGrabbing;
|
||||||
QRect positionCorners;
|
QRect positionCorners;
|
||||||
QTransform matrixWorld;
|
|
||||||
QTransform matrixWorld_inv;
|
QTransform matrixWorld_inv;
|
||||||
float ratioX, ratioY;
|
float ratioX, ratioY;
|
||||||
|
|
||||||
CvMouseCallback on_mouse;
|
CvMouseCallback on_mouse;
|
||||||
void* on_mouse_param;
|
void* on_mouse_param;
|
||||||
|
|
||||||
int mode;
|
|
||||||
int keepRatio;
|
|
||||||
|
|
||||||
bool isSameSize(IplImage* img1,IplImage* img2);
|
bool isSameSize(IplImage* img1,IplImage* img2);
|
||||||
QSize sizeHint() const;
|
QSize sizeHint() const;
|
||||||
QPointer<CvWindow> centralWidget;
|
QPointer<CvWindow> centralWidget;
|
||||||
@@ -270,64 +274,66 @@ private slots:
|
|||||||
void stopDisplayInfo();
|
void stopDisplayInfo();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//here css for trackbar
|
//here css for trackbar
|
||||||
/* from http://thesmithfam.org/blog/2010/03/10/fancy-qslider-stylesheet */
|
/* from http://thesmithfam.org/blog/2010/03/10/fancy-qslider-stylesheet */
|
||||||
static const QString str_Trackbar_css = QString("")
|
static const QString str_Trackbar_css = QString("")
|
||||||
+ "QSlider::groove:horizontal {"
|
+ "QSlider::groove:horizontal {"
|
||||||
+ "border: 1px solid #bbb;"
|
+ "border: 1px solid #bbb;"
|
||||||
+ "background: white;"
|
+ "background: white;"
|
||||||
+ "height: 10px;"
|
+ "height: 10px;"
|
||||||
+ "border-radius: 4px;"
|
+ "border-radius: 4px;"
|
||||||
+ "}"
|
+ "}"
|
||||||
|
|
||||||
+ "QSlider::sub-page:horizontal {"
|
+ "QSlider::sub-page:horizontal {"
|
||||||
+ "background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,"
|
+ "background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,"
|
||||||
+ "stop: 0 #66e, stop: 1 #bbf);"
|
+ "stop: 0 #66e, stop: 1 #bbf);"
|
||||||
+ "background: qlineargradient(x1: 0, y1: 0.2, x2: 1, y2: 1,"
|
+ "background: qlineargradient(x1: 0, y1: 0.2, x2: 1, y2: 1,"
|
||||||
+ "stop: 0 #bbf, stop: 1 #55f);"
|
+ "stop: 0 #bbf, stop: 1 #55f);"
|
||||||
+ "border: 1px solid #777;"
|
+ "border: 1px solid #777;"
|
||||||
+ "height: 10px;"
|
+ "height: 10px;"
|
||||||
+ "border-radius: 4px;"
|
+ "border-radius: 4px;"
|
||||||
+ "}"
|
+ "}"
|
||||||
|
|
||||||
+ "QSlider::add-page:horizontal {"
|
+ "QSlider::add-page:horizontal {"
|
||||||
+ "background: #fff;"
|
+ "background: #fff;"
|
||||||
+ "border: 1px solid #777;"
|
+ "border: 1px solid #777;"
|
||||||
+ "height: 10px;"
|
+ "height: 10px;"
|
||||||
+ "border-radius: 4px;"
|
+ "border-radius: 4px;"
|
||||||
+ "}"
|
+ "}"
|
||||||
|
|
||||||
+ "QSlider::handle:horizontal {"
|
+ "QSlider::handle:horizontal {"
|
||||||
+ "background: qlineargradient(x1:0, y1:0, x2:1, y2:1,"
|
+ "background: qlineargradient(x1:0, y1:0, x2:1, y2:1,"
|
||||||
+ "stop:0 #eee, stop:1 #ccc);"
|
+ "stop:0 #eee, stop:1 #ccc);"
|
||||||
+ "border: 1px solid #777;"
|
+ "border: 1px solid #777;"
|
||||||
+ "width: 13px;"
|
+ "width: 13px;"
|
||||||
+ "margin-top: -2px;"
|
+ "margin-top: -2px;"
|
||||||
+ "margin-bottom: -2px;"
|
+ "margin-bottom: -2px;"
|
||||||
+ "border-radius: 4px;"
|
+ "border-radius: 4px;"
|
||||||
+ "}"
|
+ "}"
|
||||||
|
|
||||||
+ "QSlider::handle:horizontal:hover {"
|
+ "QSlider::handle:horizontal:hover {"
|
||||||
+ "background: qlineargradient(x1:0, y1:0, x2:1, y2:1,"
|
+ "background: qlineargradient(x1:0, y1:0, x2:1, y2:1,"
|
||||||
+ "stop:0 #fff, stop:1 #ddd);"
|
+ "stop:0 #fff, stop:1 #ddd);"
|
||||||
+ "border: 1px solid #444;"
|
+ "border: 1px solid #444;"
|
||||||
+ "border-radius: 4px;"
|
+ "border-radius: 4px;"
|
||||||
+ "}"
|
+ "}"
|
||||||
|
|
||||||
+ "QSlider::sub-page:horizontal:disabled {"
|
+ "QSlider::sub-page:horizontal:disabled {"
|
||||||
+ "background: #bbb;"
|
+ "background: #bbb;"
|
||||||
+ "border-color: #999;"
|
+ "border-color: #999;"
|
||||||
+ "}"
|
+ "}"
|
||||||
|
|
||||||
+ "QSlider::add-page:horizontal:disabled {"
|
+ "QSlider::add-page:horizontal:disabled {"
|
||||||
+ "background: #eee;"
|
+ "background: #eee;"
|
||||||
+ "border-color: #999;"
|
+ "border-color: #999;"
|
||||||
+ "}"
|
+ "}"
|
||||||
|
|
||||||
+ "QSlider::handle:horizontal:disabled {"
|
+ "QSlider::handle:horizontal:disabled {"
|
||||||
+ "background: #eee;"
|
+ "background: #eee;"
|
||||||
+ "border: 1px solid #aaa;"
|
+ "border: 1px solid #aaa;"
|
||||||
+ "border-radius: 4px;"
|
+ "border-radius: 4px;"
|
||||||
+ "}";
|
+ "}";
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user