大家好日子,
我正在使用wxWidgets
处理C ++程序,其中一个框架有一个名为" Calibrate Button"的按钮。用于使用轨迹栏校准HSV值。当用户选择此按钮时,实时馈送视频,包含用于调整HSV值的轨迹栏的控制面板,表示HSV值校准变化的阈值图像,以及包含名为&#34的按钮的另一帧;节省价值"出现。当用户单击“保存值”按钮时,它会将在轨迹栏中设置的值保存到文本文件中。
我的问题是,每当我点击该按钮时,它都不会执行它想要做的事情,即将HSV值保存在txtfile中。
这是主要代码,负责在用户选择Calibrate Button时创建附加框架。
void TemplateFrame::OncalibTrackerButtonClick(wxCommandEvent& event)
{
**some code for initializing the live video feed, the trackbars, etc.**
CalibrationWindow* calibWindow = new CalibrationWindow(this);
calibWindow->setHSVvalues(H_MIN,S_MIN,V_MIN,H_MAX,S_MAX,V_MAX);
calibrationModeTracker = true;
**the following code after this line would be a pseudocode of what I am doing once the button has been click already
while(calibrationModeTracker){
calibWindow->Show(); // shows the "SAVE VALUES" frame
wxYield();
read live feed video
createTrackbars();
show live feed video
show threshold image
}
}
在while循环中,用户可以点击" SAVE VALUES"按钮,它会将HSV值保存在txtfile中。
另一方面,这是在单击包含Save Values按钮的Calibrate Button后新创建的框架(CalibrationWindow.cpp)的事件处理函数
void CalibrationWindow::OnSaveClick(wxCommandEvent& event)
{
ofstream myfile;
stringstream oss(stringstream::in | stringstream::out);
string f;
f = "//home//ianlangley//Desktop//Savefiles//HSVvalues_left.txt";
f = f.append(oss.str());
myfile.open(f.c_str());
if (myfile.is_open()){
myfile<<CalibrationWindow::getlow_H()<<"\n";
myfile<<CalibrationWindow::getlow_S()<<"\n";
myfile<<CalibrationWindow::getlow_V()<<"\n";
myfile<<CalibrationWindow::gethigh_H()<<"\n";
myfile<<CalibrationWindow::gethigh_S()<<"\n";
myfile<<CalibrationWindow::gethigh_V();
myfile.close();
}
}
最后,这是头文件中的代码:CalibrationWindow.h
class CalibrationWindow: public wxFrame
{
public:
CalibrationWindow(wxWindow* parent,wxWindowID id=wxID_ANY);
virtual ~CalibrationWindow();
void setHSVvalues(int lowH,int lowS, int lowV,int highH,int highS, int highV);
int getlow_H();
int getlow_S();
int getlow_V();
int gethigh_H();
int gethigh_S();
int gethigh_V();
//(*Declarations(CalibrationWindow)
wxButton* LeftHandButton;
wxButton* RightHandButton;
//*)
protected:
//(*Identifiers(CalibrationWindow)
static const long ID_BUTTON2;
static const long ID_BUTTON1;
//*)
private:
int lowH,lowS,lowV,highH,highS,highV;
//(*Handlers(CalibrationWindow)
void OnRightHandButtonClick(wxCommandEvent& event);
void OnLeftHandButtonClick(wxCommandEvent& event);
//*)
DECLARE_EVENT_TABLE()
};
感谢那些能够帮助我解决这个问题的人。