This figure explains the new functionalities implemented with Qt GUI. As we can see, the new GUI provides a statusbar, a toolbar, and a control panel. The control panel can have trackbars and buttonbars attached to it.
The following code is an example used to generate the figure.
int main(int argc, char *argv[])
int value = 50;
int value2 = 0;
cvNamedWindow("main1",CV_WINDOW_NORMAL);
cvNamedWindow("main2",CV_WINDOW_AUTOSIZE | CV_GUI_NORMAL);
cvCreateTrackbar( "track1", "main1", &value, 255, NULL);//OK tested
char* nameb1 = "button1";
char* nameb2 = "button2";
cvCreateButton(nameb1,callbackButton,nameb1,CV_CHECKBOX,1);
cvCreateButton(nameb2,callbackButton,nameb2,CV_CHECKBOX,0);
cvCreateTrackbar( "track2", NULL, &value2, 255, NULL);
cvCreateButton("button5",callbackButton1,NULL,CV_RADIOBOX,0);
cvCreateButton("button6",callbackButton2,NULL,CV_RADIOBOX,1);
cvSetMouseCallback( "main2",on_mouse,NULL );
IplImage* img1 = cvLoadImage("files/flower.jpg");
IplImage* img2 = cvCreateImage(cvGetSize(img1),8,3);
CvCapture* video = cvCaptureFromFile("files/hockey.avi");
IplImage* img3 = cvCreateImage(cvGetSize(cvQueryFrame(video)),8,3);
while(cvWaitKey(33) != 27)
{
cvAddS(img1,cvScalarAll(value),img2);
cvAddS(cvQueryFrame(video),cvScalarAll(value2),img3);
cvShowImage("main1",img2);
cvShowImage("main2",img3);
}
cvDestroyAllWindows();
cvReleaseImage(&img1);
cvReleaseImage(&img2);
cvReleaseImage(&img3);
cvReleaseCapture(&video);
return 0;
}
Change the parameters of the window dynamically.
Parameters: |
|
---|
The function `` cvSetWindowProperty`` allows to change the window’s properties.
Get the parameters of the window.
Parameters: |
|
---|
See SetWindowProperty to know the meaning of the returned values.
The function `` cvGetWindowProperty`` return window’s properties.
Create the font to be used to draw text on an image (with ).
Parameters: |
|
---|
The function cvFontQt creates a CvFont object to be used with AddText . This CvFont is not compatible with cvPutText.
A basic usage of this function is:
CvFont font = cvFontQt(''Times'');
cvAddText( img1, ``Hello World !'', cvPoint(50,50), font);
Create the font to be used to draw text on an image
Parameters: |
|
---|
The function cvAddText draw text on the image img using a specific font font (see example FontQt )
Display text on the window’s image as an overlay for delay milliseconds. This is not editing the image’s data. The text is display on the top of the image.
Parameters: |
|
---|
The function cvDisplayOverlay aims at displaying useful information/tips on the window for a certain amount of time delay . This information is display on the top of the window.
Display text on the window’s statusbar as for delay milliseconds.
Parameters: |
|
---|
The function cvDisplayOverlay aims at displaying useful information/tips on the window for a certain amount of time delay . This information is displayed on the window’s statubar (the window must be created with CV_GUI_EXPANDED flags).
_
Create a callback function called to draw OpenGL on top the the image display by windowname.
Parameters: |
|
---|
The function cvCreateOpenGLCallback can be used to draw 3D data on the window. An example of callback could be:
void on_opengl(void* param)
{
//draw scene here
glLoadIdentity();
glTranslated(0.0, 0.0, -1.0);
glRotatef( 55, 1, 0, 0 );
glRotatef( 45, 0, 1, 0 );
glRotatef( 0, 0, 0, 1 );
static const int coords[6][4][3] = {
{ { +1, -1, -1 }, { -1, -1, -1 }, { -1, +1, -1 }, { +1, +1, -1 } },
{ { +1, +1, -1 }, { -1, +1, -1 }, { -1, +1, +1 }, { +1, +1, +1 } },
{ { +1, -1, +1 }, { +1, -1, -1 }, { +1, +1, -1 }, { +1, +1, +1 } },
{ { -1, -1, -1 }, { -1, -1, +1 }, { -1, +1, +1 }, { -1, +1, -1 } },
{ { +1, -1, +1 }, { -1, -1, +1 }, { -1, -1, -1 }, { +1, -1, -1 } },
{ { -1, -1, +1 }, { +1, -1, +1 }, { +1, +1, +1 }, { -1, +1, +1 } }
};
for (int i = 0; i < 6; ++i) {
glColor3ub( i*20, 100+i*10, i*42 );
glBegin(GL_QUADS);
for (int j = 0; j < 4; ++j) {
glVertex3d(0.2 * coords[i][j][0], 0.2 * coords[i][j][1], 0.2 * coords[i][j][2]);
}
glEnd();
}
}
CV_EXTERN_C_FUNCPTR( *CvOpenGLCallback)(void* userdata));
_
Save parameters of the window windowname.
Parameters: |
|
---|
The function cvSaveWindowParameters saves size, location, flags, trackbars’ value, zoom and panning location of the window window_name
_
Load parameters of the window windowname.
Parameters: |
|
---|
The function cvLoadWindowParameters load size, location, flags, trackbars’ value, zoom and panning location of the window window_name
_
Create a callback function called to draw OpenGL on top the the image display by windowname.
Parameters: |
|
---|
The button_type parameter can be : *(Optional – Will be a push button by default.)
- CV_PUSH_BUTTON The button will be a push button.
- CV_CHECKBOX The button will be a checkbox button.
- CV_RADIOBOX The button will be a radiobox button. The radiobox on the same buttonbar (same line) are exclusive; one on can be select at the time.
- initial_button_state Default state of the button. Use for checkbox and radiobox, its value could be 0 or 1. (Optional)
The function cvCreateButton attach button to the control panel. Each button is added to a buttonbar on the right of the last button. A new buttonbar is create if nothing was attached to the control panel before, or if the last element attached to the control panel was a trackbar.
Here are various example of cvCreateButton function call:
cvCreateButton(NULL,callbackButton);//create a push button "button 0", that will call callbackButton.
cvCreateButton("button2",callbackButton,NULL,CV_CHECKBOX,0);
cvCreateButton("button3",callbackButton,&value);
cvCreateButton("button5",callbackButton1,NULL,CV_RADIOBOX);
cvCreateButton("button6",callbackButton2,NULL,CV_PUSH_BUTTON,1);
CV_EXTERN_C_FUNCPTR( *CvButtonCallback)(int state, void* userdata));