/*
 * Construct the PGH for the images in a folder
 * @parameter 1: folderPath - the images folder
 * @parameter 2: angleAcc -the angle accuracy
 * @parameter 3: columns - the distance accuracy
 */
void GeometricHistogram::pairwiseHistogramDirectory(string folderPath,
		LocalHistogram::AccuracyPGH angleAcc, int distanceAcc) {
	QDir qdir;
	QString fPath(folderPath.c_str());
	qdir.setPath(fPath);
	qdir.setFilter(QDir::Files);
	QStringList filterNames;
	filterNames << "*.JPG";
	qdir.setNameFilters(QStringList("*.JPG"));
	QFileInfoList files = qdir.entryInfoList();
	for (int i = 0; i < files.size(); i++) {
		QFileInfo file = files.at(i);
		QString _name = file.absoluteFilePath();
		int index2 = _name.lastIndexOf("/");
		QString savePath = "test/pghmatrix/"
				+ _name.mid(index2 + 1, _name.length() - index2 - 5).replace(
						" ", "") + "_L"
				+ QString::number(LocalHistogram::heightOfAngleAxis(angleAcc))
				+ "_C" + QString::number(distanceAcc) + ".PGH";
		qDebug() << savePath;
		Image sceneImage(_name.toStdString());
		vector<Line> lines = sceneImage.lineSegment();
		vector<LocalHistogram> listLocalPGH;
		ShapeHistogram sceneHist = sceneImage.getShapeHistogram();
		listLocalPGH = sceneHist.constructPGH(lines);
		vector<vector<int> > matrix = sceneHist.constructMatPGH(listLocalPGH,angleAcc,
				distanceAcc);
		sceneHist.writeMatrix(matrix, savePath.toStdString());
	}
}
TailFileLogHandler::TailFileLogHandler(const std::string& filePath)
    : _private(new PrivateTailFileLogHandler)
{
    _private->_file = NULL;
    _private->_writeSize = 0;
    _private->_fileName = filePath;

    boost::filesystem::path fPath(_private->_fileName);
    // Create the directory!
    try
    {
        if (!boost::filesystem::exists(fPath.make_preferred().parent_path()))
            boost::filesystem::create_directories(fPath.make_preferred().parent_path());
    }
    catch (boost::filesystem::filesystem_error &e)
    {
        qiLogWarning("qi.log.tailfileloghandler") << e.what() << std::endl;
    }

    // Open the file.
    FILE* file = qi::os::fopen(fPath.make_preferred().string().c_str(), "w+");

    if (file)
        _private->_file = file;
    else
        qiLogWarning("qi.log.tailfileloghandler") << "Cannot open "
                << filePath << std::endl;
}
示例#3
0
BOOL CMediaFormats::IsUnPlayableFile(CString szFilename, bool bRestrict){
	CPath fPath(szFilename);
	CString szThisExtention = fPath.GetExtension();
	BOOL bDefaultRet = false;
	if(bRestrict)
		bDefaultRet = true;

	for(size_t i = 0; i < GetCount(); i++)
	{
		CMediaFormatCategory& mfc = GetAt(i);
		if( mfc.FindExt(szThisExtention) ){
			CString szLabel = mfc.GetLabel();
			if ( szLabel.Find(_T("Subtitle")) >= 0 || szLabel.Find(_T("字幕")) >= 0){
				return TRUE;
			}
			if ( szLabel.Find(_T("Image file")) >= 0 || szLabel.Find(_T("图片")) >= 0){
				return TRUE;
			}
			if ( szLabel.Find(_T("Real Script file")) >= 0 || szLabel.Find(_T("脚本")) >= 0){
				return TRUE;
			}

			return FALSE;
		}
	}
	return bDefaultRet;
}
示例#4
0
BOOL CMediaFormats::IsAudioFile(CString szFilename){
	CPath fPath(szFilename);
	CString szThisExtention = fPath.GetExtension();

	for(size_t i = 0; i < GetCount(); i++)
	{
		CMediaFormatCategory& mfc = GetAt(i);
		if(mfc.IsAudioOnly() != 1 || mfc.GetEngineType() != DirectShow) continue;
		if( mfc.FindExt(szThisExtention) ){
			return TRUE;
		}
	}
	return FALSE;
}
示例#5
0
  FileLogHandler::FileLogHandler(const std::string& filePath)
    : _p(new PrivateFileLogHandler)
  {
    _p->_file = NULL;
    boost::filesystem::path fPath(filePath);
    // Create the directory!
    try
    {
      if (!boost::filesystem::exists(fPath.make_preferred().parent_path()))
        boost::filesystem::create_directories(fPath.make_preferred().parent_path());
    }
    catch (const boost::filesystem::filesystem_error& e)
    {
      qiLogWarning() << e.what();
    }

    // Open the file.
    FILE* file = qi::os::fopen(fPath.make_preferred().string().c_str(), "w+");

    if (file)
      _p->_file = file;
    else
      qiLogWarning() << "Cannot open " << filePath;
  }
示例#6
0
int main(int argc, char* argv[])
{
	Json::Value root;
	std::ifstream jsonIn("json.txt");
	Json::Reader reader;
	if(!reader.parse(jsonIn,root))
	{
		std::cout << "reader parse wrong!";
		return 0;
	}
	jsonIn.close();

	std::string fPath(argv[0]);
	std::string fName = fPath.substr(fPath.find_last_of('/') + 1);

        std::cout << fPath << std::endl;
	std::string cmdline;
	std::cout << fName << " > ";
	bool retJudge = true;
	MethodFactory *methodFactory  = MethodFactory::instance();
	methodFactory->initJsonValue(&root);
	CmdMethod * cmdMethod = NULL;

	while(retJudge)
	{
		getline(std::cin,cmdline,'\n');
		cmdMethod = methodFactory->CreateMethod(cmdline);
		if(cmdMethod != NULL)
		{
			retJudge = cmdMethod->msgHandle(fName, cmdline);
		}
		std::cout << fName << " > ";
	}

	return 0;
}
示例#7
0
int oLaucher::AnalyzeOutput(QString pathFile, int cracker)
{

    QFile fPath(pathFile);
    QString pwd;
    oSqlite db;


    if(fPath.open(QIODevice::ReadOnly))
    {
        QByteArray byteArray = fPath.readAll();

        //Todas las strings que contiene el fichero que genero el crackeador.exe
        QString fichContents = QString::fromUtf8(byteArray.toStdString().c_str());


        if(fichContents.length()>0)
        {


		    if(cracker==2)
		    {
		    		QStringList strList = fichContents.split("\n");

	                // Si el fichero que genero %hashcat% NO contiene 2 saltos de linea
	                // Es decir no consiguio el password en el dict utilizado
	                if(strList.count()!=2)
	                {	                    

	                    db.InsertAplicado(hashFileName, hashDictName);

	                    //Return -2 significa que no lo a conseguido
	                    return -2;
	                }


	                fichContents = strList.at(0);
	                strList = fichContents.split(":");


	                if(strList.count()!=3)
	                    return -3;

	                pwd = strList.at(2);

		    }

			    




			    if(cracker==3)
			    {
			    	pwd = fichContents;
			    }			    

			    db.InsertPwd(hashFileName, pwd);

			    return 0;


        }

        else
        {
        	if(cracker==3)
        		db.InsertAplicado(hashFileName, hashDictName);
        }        
    }

    return 0;
}