Visual studio provides tools to make forms in C++ but, starting with VS2012, they have made it difficult - they want you to make forms in C#, or VB not in C++.
A good tutorial on how to make a windows forms application using Visual C++ 2013 is given here
Basically you need your application to be a CLR application, rather than a console. You can then add GUI forms to it and call OpenCV from them. I have written several such applications and can help if you have more specific questions on interfacing OpenCV with CLR forms.
guy
Edit
Here is an example.
The form frmImaging
has a buttons called cmdLoad
and cmdSave
and a textbox txtFileName
.
In the associated cpp file I have:
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
cv::Mat image //global mat file for storing the image. It is accessible by all GUI callbacks in this file.
//callback for cmdLoad button - loads image into Mat
System::Void frmImaging::cmdLoad_Click(System::Object^ sender, System::EventArgs^ e)
{
//Get filename
if(System::String::IsNullOrEmpty(openFileDialog1->InitialDirectory))
openFileDialog1->InitialDirectory=txtDir->Text;
if( openFileDialog1->ShowDialog()!=::DialogResult::OK)
return;
txtFilename->Text=openFileDialog1->FileName;
char FileName[200];
sprintf(FileName,"%s",openFileDialog1->FileName);
//load image
image=imread(FileName,CV_LOAD_IMAGE_ANYDEPTH);
//display image
imshow("Display Window",image);
}
//callback of cmdSave button - save image
System::Void frmImaging::cmdSave_Click(System::Object^ sender, System::EventArgs^ e)
{
// get filename from GUI
char FileName[200];
sprintf(FileName,"%s",txtFilename->Text);
imwrite(FileName, image);
}
take a look at @pklab 's page