//------------------main function------------------------------// int main(void){ try{ string filename("puz1.txt"); ifstream origfile(filename); Game g(origfile,filename); g.run(); }catch(FileNotOpen e){ e.print(cout); }catch(MalformedFile e){ e.print(cout); } return 0; }
/////////////////////// // Unhandled exception void AegisubApp::OnUnhandledException() { // Attempt to recover file wxFileName origfile(AssFile::top->filename); wxString path = Options.AsText(_T("Auto recovery path")); if (path.IsEmpty()) path = folderName; wxFileName dstpath(path); if (!dstpath.IsAbsolute()) path = AegisubApp::folderName + path; path += _T("/"); dstpath.Assign(path); if (!dstpath.DirExists()) wxMkdir(path); wxString filename = folderName + origfile.GetName() + _T(".RECOVER.ass"); AssFile::top->Save(filename,false,false); // Inform user of crash wxMessageBox(_T("Aegisub has encountered an unhandled exception error and will terminate now. The subtitles you were working on were saved to \"") + filename + _T("\", but they might be corrupt."), _T("Unhandled exception"), wxOK | wxICON_ERROR, NULL); }
void PointTracker::save(string filename, string newpoints, const IplImage *frame) { vector<CvRect> faces = FaceDetector::facedetector.detect(frame); if (faces.size() == 1) { cvSaveImage((filename + "-orig-grey.png").c_str(), orig_grey.get()); cvSaveImage((filename + "-orig-pyramid.png").c_str(), orig_pyramid.get()); ofstream origfile((filename + "-orig-points.txt").c_str()); origfile << origpoints; CvRect face = faces[0]; ofstream facefile(newpoints.c_str()); vector<Point> temppoints; convert(currentpoints, temppoints); facefile << pointbetweenrects(temppoints, face, cvRect(0, 0, 1, 1)); } else throw ios_base::failure("No face found in the image"); }
void PointTracker::load(string filename, string newpoints, const IplImage *frame) { vector<CvRect> faces = FaceDetector::facedetector.detect(frame); if (faces.size() == 1) { ifstream origfile((filename + "-orig-points.txt").c_str()); ifstream facefile(newpoints.c_str()); if (!origfile.is_open() || !facefile.is_open()) throw ios_base::failure("File not found"); // todo: memory leak here, change to scoped_ptr! orig_grey.reset(cvLoadImage((filename + "-orig-grey.png").c_str(), 0)); orig_pyramid.reset(cvLoadImage((filename + "-orig-pyramid.png").c_str(), 0)); vector<Point> temppoints; origfile >> temppoints; convert(temppoints, origpoints); facefile >> temppoints; temppoints = pointbetweenrects(temppoints, cvRect(0,0,1,1), faces[0]); convert(temppoints, currentpoints); lastpoints = currentpoints; }