Beispiel #1
0
void LearningContext:: print(SpLearningAttributes availableAttributes) {
    int i, j, n, m;
    std::set<std::string> *values;
    std::set<ObjectType>::iterator involvedIt;
    std::set<std::string>::iterator valuesIt;
    std::map<attribute_id, SpLearningNumeric>::iterator numIt;
    std::map<attribute_id, SpLearningSymbolic>::iterator symIt;

    AppendToLog("Learning Context: " + name);
    AppendToLog("\n    Initial Tree File: " + initialHierarchyFile);
    AppendToLog("\n    Involved Objects: \n");
    n = involvedObjects.size();
    for(i = 0, involvedIt = involvedObjects.begin(); i < n; i++, involvedIt++)
        AppendToLog("        " + QString(Blob::getNameFromType(*involvedIt).c_str()) + "\n");

    AppendToLog("    Numerical Attributes: \n");
    n = numericalAttributes.size();
    for(i = 0, numIt = numericalAttributes.begin(); i < n; i++, numIt++)
        AppendToLog("        " + QString(availableAttributes->nameFromId[(*numIt).first].c_str()) + "    Acuity: " + QString::number(((*numIt).second)->acuity) + "\n");

    AppendToLog("    Symbolic Attributes: \n");
    n = symbolicAttributes.size();
    for(i = 0, symIt = symbolicAttributes.begin(); i < n; i++, symIt++) {
        AppendToLog("        " + QString(availableAttributes->nameFromId[(*numIt).first].c_str()) + "\n");
        AppendToLog("        Values: \n");
        values = availableAttributes->symbolicValuesList[(*symIt).first];
        m = values->size();
        for(j = 0, valuesIt = values->begin(); j < m; j++, valuesIt++)
            AppendToLog("                " + QString((*valuesIt).c_str()) + "\n");
    }
}
Beispiel #2
0
bool GaussianFunction::setParameters(QDomNode& config) {
    QDomNode n;

    if(config.isNull()) { //Parameter set for module not defined
        AppendToLog("GaussianFunction Error: In definition of Gaussian function model (mean, sigma, min, max). Aborting Context loading.");
        return false;
    } else {
        if( ( n = XmlCommon::getParameterNode("mean", config) ).isNull() ) {
            AppendToLog("GaussianFunction Error: In definition of Gaussian function model 'mean' parameter missing. Aborting Context loading.");
            return false;
        } else
            mean = XmlCommon::getParameterValue(n).toDouble();

        if( ( n = XmlCommon::getParameterNode("sigma", config) ).isNull() ) {
            AppendToLog("GaussianFunction Error: In definition of Gaussian function model 'sigma' parameter missing. Aborting Context loading.");
            return false;
        } else
            sigma = XmlCommon::getParameterValue(n).toDouble();

        if( ( n = XmlCommon::getParameterNode("min", config) ).isNull() ) {
            AppendToLog("GaussianFunction Error: In definition of Gaussian function model 'min' parameter missing. Aborting Context loading.");
            return false;
        } else
            min = XmlCommon::getParameterValue(n).toDouble();

        if( ( n = XmlCommon::getParameterNode("max", config) ).isNull() ) {
            AppendToLog("GaussianFunction Error: In definition of Gaussian function model 'max' parameter missing. Aborting Context loading.");
            return false;
        } else
            max = XmlCommon::getParameterValue(n).toDouble();

    }

    return true;
}
Beispiel #3
0
bool CppCheck::AppExecute(const wxString& app, const wxString& CommandLine, wxArrayString& Output, wxArrayString& Errors)
{
    wxWindowDisabler disableAll;
    wxBusyInfo running(_("Running ") + app + _T("... please wait (this may take several minutes)..."),
                       Manager::Get()->GetAppWindow());

    AppendToLog(CommandLine);
    if ( -1 == wxExecute(CommandLine, Output, Errors, wxEXEC_SYNC) )
    {
        wxString msg = _("Failed to launch ") + app + _T(".\n"
                         "Please setup the ") + app + _T(" executable accordingly in the settings\n"
                        "and make sure its also in the path so ") + app + _T(" resources are found.");
        AppendToLog(msg);
        cbMessageBox(msg, _("Error"), wxICON_ERROR | wxOK, Manager::Get()->GetAppWindow());
        if (!m_PATH.IsEmpty()) wxSetEnv(wxT("PATH"), m_PATH); // Restore
        return false;
    }

    int Count = Output.GetCount();
    for (int idxCount = 0; idxCount < Count; ++idxCount)
        AppendToLog(Output[idxCount]);

    Count = Errors.GetCount();
    for (int idxCount = 0; idxCount < Count; ++idxCount)
        AppendToLog(Errors[idxCount]);

    if (!m_PATH.IsEmpty()) wxSetEnv(wxT("PATH"), m_PATH); // Restore
    return true;
}
Beispiel #4
0
long Valgrind::DoValgrindVersion()
{
	wxString CommandLine = _("valgrind --version");
	WriteToLog(CommandLine);
	wxArrayString Output, Errors;
	wxExecute(CommandLine, Output, Errors);
	int Count = Output.GetCount();
	wxString ValgrindVersion;
	for(int idxCount = 0; idxCount < Count; ++idxCount)
	{
		ValgrindVersion = Output[0];
		AppendToLog(Output[idxCount]);
	} // end for : idx: idxCount
	Count = Errors.GetCount();
	for(int idxCount = 0; idxCount < Count; ++idxCount)
	{
		AppendToLog(Errors[idxCount]);
	} // end for : idx: idxCount
	// and clear the list
	m_ListLog->Clear();
	long VersionValue = 0;
	wxString Version;
	if(ValgrindVersion.StartsWith(_T("valgrind-"), &Version))
	{
		Version.Replace(_T("."), _T(""));
		Version.ToLong(&VersionValue);
	}
	return VersionValue;
} // end of DoValgrindVersion
bool SuperpixelModuleSLICO::setParameters(QDomNode& config){
    QDomNode n, m;
    QDomNodeList l;
    int intT;

    if(config.isNull()) { //Parameter set for module not defined
        m_superpixelnumber = 200; //Desired number of superpixels.
        m_contrast = false; //Apply Histogram Equalization prior to obtain superpixels
    } else {
        if( !( n = XmlCommon::XmlCommon::getParameterNode("SuperpixelNumber", config) ).isNull() ) {
            m_superpixelnumber = XmlCommon::getParameterValue(n).toInt();
            if(m_superpixelnumber <= 0) {
                m_superpixelnumber = 200; //Desired number of superpixels.
                AppendToLog("SuperpixelModuleSLICO: Warning: 'SuperpixelNumber' must be an integer higher than zero. Taking default: 200" );
            }
        } else { //default
            m_superpixelnumber = 200; //Desired number of superpixels.
            AppendToLog("SuperpixelModuleSLICO: Warning: 'SuperpixelNumber' not defined. Taking default: 200" );
        }

        if( !( n = XmlCommon::XmlCommon::getParameterNode("ContrastEnhancing", config) ).isNull() ) {
            m_contrast = XmlCommon::getParameterValue(n) == "true" ? true : false;
            if(XmlCommon::getParameterValue(n) != "true" && XmlCommon::getParameterValue(n) != "false")
                AppendToLog("SuperpixelModuleSLICO: Warning: 'ContrastEnhancing' must be true or false. Taking default: false" );
        } else { //default
            m_contrast = false;
            AppendToLog("SuperpixelModuleSLICO: Warning: 'ContrastEnhancing' not defined. Taking default: false" );
        }


    }

    return true;
}
Beispiel #6
0
wxString CppCheck::GetAppExecutable(const wxString& app, const wxString& app_cfg)
{
    ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("cppcheck"));
    wxString Executable = ConfigPanel::GetDefaultCppCheckExecutableName();
    if (cfg)
        Executable = cfg->Read(app_cfg, Executable);
    Manager::Get()->GetMacrosManager()->ReplaceMacros(Executable);

    AppendToLog(wxString::Format(_("Executable ") + app + _T(": '%s'."),
                                 Executable.wx_str()));

    // Make sure file is accessible, otherwise add path to cppcheck to PATH envvar
    wxFileName fn(Executable);
    if (fn.IsOk() && fn.FileExists())
    {
        wxString AppPath = fn.GetPath();
        AppendToLog(wxString::Format(_("Path to ") + app + _T(": '%s'."),
                                     AppPath.wx_str()));

        if ( AppPath.Trim().IsEmpty() )
            return Executable; // Nothing to do, lets hope it works and cppcheck is in the PATH

        bool PrependPath = true;
        wxString NewPathEnvVar = wxEmptyString;

        wxPathList PathList;
        PathList.AddEnvList(wxT("PATH"));
        for (size_t i=0; i<PathList.GetCount(); ++i)
        {
            wxString PathItem = PathList.Item(i);
            if ( PathItem.IsSameAs(AppPath, (platform::windows ? false : true)) )
            {
                AppendToLog(_("Executable of cppcheck is in the path."));
                PrependPath = false;
                break; // Exit for-loop
            }

            if ( !NewPathEnvVar.IsEmpty() )
                NewPathEnvVar << wxPATH_SEP;
            NewPathEnvVar << PathItem;
        }

        if (m_PATH.IsEmpty())
            m_PATH = NewPathEnvVar;


        if (PrependPath)
        {
            NewPathEnvVar = NewPathEnvVar.Prepend(wxPATH_SEP);
            NewPathEnvVar = NewPathEnvVar.Prepend(AppPath);
            wxSetEnv(wxT("PATH"), NewPathEnvVar); // Don't care about return value
            AppendToLog(wxString::Format(_("Updated PATH environment to include path to ") + app + _T(": '%s' ('%s')."),
                                         AppPath.wx_str(), NewPathEnvVar.wx_str()));
        }
    }

    return Executable;
}
bool BackgroundInitializationModule::setParameters(QDomNode& config)
{
	QDomNode n;
	if(config.isNull())  //Parameter set for module not defined
	{
		this->sizeBlock = 10;
		this->thresholdStill = 20;
		this->aggregationRate = 0.95;
		this->thresholdMov = 0.9 ;
		this->thresholdCorrelation = 0.7;
	}
	else
	{
		if( !( n = XmlCommon::XmlCommon::getParameterNode("sizeBlock", config) ).isNull() )
				this->sizeBlock = XmlCommon::getParameterValue(n).toInt();
		else
		{
			this->sizeBlock = 10;
            AppendToLog("BackgroundInitializationModule: Warning: 'sizeBlock' not defined. Taking defaults: \n\t\tsizeBlock = " + QString::number(this->sizeBlock) + "\n");
		}
		if( !( n = XmlCommon::XmlCommon::getParameterNode("thresholdStill", config) ).isNull() )
			this->thresholdStill = XmlCommon::getParameterValue(n).toInt();
		else
		{
			this->thresholdStill = 20;
            AppendToLog("BackgroundInitializationModule: Warning: 'thresholdStill' not defined. Taking defaults: \n\t\tthresholdStill = " + QString::number(this->thresholdStill) + "\n");
		}
		if( !( n = XmlCommon::XmlCommon::getParameterNode("aggregationRate", config) ).isNull() )
			this->aggregationRate = XmlCommon::getParameterValue(n).toFloat();
		else
		{
			this->aggregationRate = 0.95;
            AppendToLog("BackgroundInitializationModule: Warning: 'aggregationRate' not defined. Taking defaults: \n\t\taggregationRate = " + QString::number(this->aggregationRate) + "\n");
		}
		if( !( n = XmlCommon::XmlCommon::getParameterNode("thresholdMov", config) ).isNull() )
			this->thresholdMov = XmlCommon::getParameterValue(n).toFloat();
		else
		{
			this->thresholdMov = 0.9;
            AppendToLog("BackgroundInitializationModule: Warning: 'thresholdMov' not defined. Taking defaults: \n\t\tthresholdMov = " + QString::number(this->thresholdMov) + "\n");
		}
		if( !( n = XmlCommon::XmlCommon::getParameterNode("thresholdCorrelation", config) ).isNull() )
			this->thresholdCorrelation = XmlCommon::getParameterValue(n).toFloat();
		else
		{
			this->thresholdCorrelation = 0.7;
            AppendToLog("BackgroundInitializationModule: Warning: 'thresholdCorrelation' not defined. Taking defaults: \n\t\tthresholdCorrelation = " + QString::number(this->thresholdCorrelation) + "\n");
		}
	}

	//Setea la lista de parametros y la lista de tipos de parametros utilizadas en el ParameterDialog.
	addParameter("sizeBlock", QString::number(this->sizeBlock), "int");
	addParameter("thresholdStill", QString::number(this->thresholdStill), "int");
	addParameter("aggregationRate", QString::number(this->aggregationRate), "float");
	addParameter("thresholdMov", QString::number(this->thresholdMov), "float");
	addParameter("thresholdCorrelation", QString::number(this->thresholdCorrelation), "float");
	return true;
}
Beispiel #8
0
// Opens filename file and reads its header (Application marker segment,
// it starts after a FF E0).
// This header is given back as string. If something goes wrong, empty
// string is given back.
void ImageHeader::readJpegHeader(QString& filename) {

    QFile file(filename);
    if( !file.open(QIODevice::ReadOnly) ) {
        AppendToLog(   "Error opening file. The image file '"
                                       + filename
                                       + "' could not be opened for header extraction." );
        setNullHeader();
        return;
    }

    char buffer[2] = {0};    
    int  buf_size;

    do {
        buffer[0] = buffer[1];           // Shift
        if(file.read(&buffer[1], 1) <= 0) {
//            AppendToLog(   "ImageHeader: The image file '"
//                                           + filename
//                                           + "' does not contain a header with timestamp." );
            setNullHeader();
            return;
        }
    }  while (buffer[0] != '\xff' || buffer[1] != '\xe0');   // Marker bytes found

    file.read(&buffer[0], 2);            // Two bytes: header size

    // These lines are the conversion from hex (char) to int
    QString hex;
    int from_hex = (hex.sprintf("%d", buffer[0])).toInt();
    buf_size = 256 * from_hex;
    from_hex = (hex.sprintf("%d", buffer[1])).toInt();
    buf_size += from_hex;

    if(buf_size <= 0) {
        AppendToLog(   "ImageHeader: The image file '"
                                       + filename
                                       + "' does not contain a header with timestamp or an empty header." );
        setNullHeader();
        return;
    }
    char *header = new char[buf_size + 1];
    file.read(header, buf_size);
    header[buf_size] = '\0';

    jpeg_header_string = header;

    file.close();
    delete[] header;

}
bool DominantColorSegmentation::setParameters(QDomNode &config)
{
    QDomNode n;

    if(config.isNull()) { //Parameter set for module not defined
        HistogramPeakThreshold = 0.2;
        Tcolor = 2;
        upperpenalty = 0.2;
        IntensityThreshold = 50;
    } else {
        //ADD PARAMETERS FROM XML FILE
        //a_param
        if( ( n = XmlCommon::getParameterNode("HPT", config) ).isNull() ) {
            HistogramPeakThreshold = 0.2;
            addParameter("HPT", "0.2", "double");
            AppendToLog("LianSegmentation: Warning: 'HPT' not defined. Taking default: " + QString::number(HistogramPeakThreshold));
        } else {
            HistogramPeakThreshold = XmlCommon::getParameterValue(n).toDouble();
            addParameter("HPT", XmlCommon::getParameterValue(n), "double");
        }
        //b_param
        if( ( n = XmlCommon::getParameterNode("Tcolor", config) ).isNull() ) {
            Tcolor = 2;
            addParameter("Tcolor", "2", "double");
            AppendToLog("LianSegmentation: Warning: 'Tcolor' not defined. Taking default: " + QString::number(Tcolor));
        } else {
            Tcolor = XmlCommon::getParameterValue(n).toDouble();
            addParameter("Tcolor", XmlCommon::getParameterValue(n), "double");
        }
        //upperpenalty
        if( ( n = XmlCommon::getParameterNode("upperpenalty", config) ).isNull() ) {
            upperpenalty = 2;
            addParameter("upperpenalty", "2", "double");
            AppendToLog("LianSegmentation: Warning: 'upperpenalty' not defined. Taking default: " + QString::number(upperpenalty));
        } else {
            upperpenalty = XmlCommon::getParameterValue(n).toDouble();
            addParameter("upperpenalty", XmlCommon::getParameterValue(n), "double");
        }
        //IntensityThreshold
        if( ( n = XmlCommon::getParameterNode("IntensityThreshold", config) ).isNull() ) {
            IntensityThreshold = 2;
            addParameter("IntensityThreshold", "2", "double");
            AppendToLog("LianSegmentation: Warning: 'IntensityThreshold' not defined. Taking default: " + QString::number(IntensityThreshold));
        } else {
            IntensityThreshold = XmlCommon::getParameterValue(n).toDouble();
            addParameter("Tcolor", XmlCommon::getParameterValue(n), "double");
        }
    }
    return true;
}
Beispiel #10
0
int CppCheck::Execute()
{
    WriteToLog(_("Running cppcheck/vera++ analysis... please wait..."));

    if ( !CheckRequirements() )
        return -1;

    cbProject* Project = Manager::Get()->GetProjectManager()->GetActiveProject();
    if (Project->GetFilesCount() < 1)
        return 0;

    const wxString BasePath = Project->GetBasePath();
    AppendToLog(_T("Switching working directory to : ") + BasePath);
    ::wxSetWorkingDirectory(BasePath);


    ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("cppcheck"));
    int choice = cfg->ReadInt(_T("operation"), 0);

    int result_cppcheck = 0;
    int result_vera     = 0;

    if ((0==choice) || (2==choice))
      result_cppcheck = ExecuteCppCheck(Project);

    if ((1==choice) || (2==choice))
      result_vera = ExecuteVera(Project);

    return ((0==result_cppcheck) && (0==result_vera)) ? 0 : -1;
}
void MainWindow::PrintPacketInfo(packet p)
{
    QString pType;

    switch (p.PacketType)
    {
        case CONTROL_PACKET:
            pType = "Control";
            break;
        case DATA_PACKET:
            pType = "Data";
            break;
        default:
            pType = "Unknown";
            break;
    }

    QString packetInfo = QString("Packet Type: %1\n"
                                 "Sequence: %2\n"
                                 "WindowSize: %3\n"
                                 "AckNum: %4\n"
                                 "Destination addr: %5\n"
                                 "Destination port: %6\n")
            .arg(pType,
                 QString::number(p.SeqNum),
                 QString::number(p.WindowSize),
                 QString::number(p.AckNum),
                 p.dest_addr,
                 QString::number(p.dest_port));

    AppendToLog(packetInfo);
   // AppendToLog(p.data);
}
/**
 * @brief BallClasificationModule::setParameters
 * @param config
 * @return
 * m_delInForeground --> true: borrar blobs no clasificasdos
 */
bool BallClasificationModule::setParameters(QDomNode &config)
{
    QDomNode n;

    if(config.isNull()) { //Parameter set for module not defined
        AppendToLog("BallClasificationModule: Warning: Configuration '" + m_data->m_config_file + "' file does not define an entry BlobFilteringModule. Taking defaults...");
        return false;
    }
    if( ( n = XmlCommon::getParameterNode("DeleteInForeground", config) ).isNull() ) {
        AppendToLog("BallClasificationModule: Warning: Configuration '" + m_data->m_config_file + "' file does not define an entry 'DeleteInForeground' for BlobFilteringModule. Taking default value (false).");
        m_delInForeground = false;
    } else
        m_delInForeground = (XmlCommon::getParameterValue(n) == "true") ? true : false;

    return true;
}
Beispiel #13
0
bool paintView::setParameters(QDomNode &config){
    QDomNode m;
    QDomElement e;
    int i;
    size_t pos;
    std::deque<drawInterface *>::reverse_iterator it, it_end;

    m = config.firstChild();
    while(!m.isNull()) {
        e = m.toElement();
        std::string s = e.tagName().toStdString();
        if( (pos=s.find_first_not_of(" \t\r\n")) != std::string::npos ) {
            QDomNode p;
            s = s.substr(pos);
            i = s.size()-1;
            if(s[i] == '\n' || s[i] == '\r')
                s = s.substr(0, i);

            if(isValidDrawName(s)) {
                drawSequence.push_back(drawConstructor[s](m_data));
                it = drawSequence.rbegin();
                (*it)->setParameters(m);
            } else {
                QString ss = s.c_str();
                AppendToLog("paintView: setParameters: draw element '" + ss + "' not defined. Draw element will be ignored.");
            }
        }
        m = m.nextSibling();
    }
    return true;
}
Beispiel #14
0
bool GrayCodeModule::run(){

    if(m_data->currentImage == NULL || m_data->currentImage->isNull()) {
        AppendToLog("GrayCodeModule: Warning: No current image. Aborting execution...\n");
        return false;
    }

    if(first == false) {
        if(m_data->grayImage != NULL)
            delete m_data->grayImage;

        m_data->grayImage = new QImage(m_data->currentImage->width(),
                                       m_data->currentImage->height(),
                                       QImage::Format_ARGB32);
        if(m_data->grayImage->isNull()) {
            AppendToLog("GrayCodeModule: Warning: Cannot create gray image from current image.\n");
            delete m_data->grayImage;
            m_data->grayImage = NULL;
            return false;
        } else
            first = true;
    }



    if(    m_data->currentImage->width() != m_data->grayImage->width()
        || m_data->currentImage->height() != m_data->grayImage->height()) {
        delete m_data->grayImage;
        m_data->grayImage = new QImage(m_data->currentImage->width(),
                                       m_data->currentImage->height(),
                                       QImage::Format_ARGB32);
        if(m_data->grayImage->isNull()) {
            AppendToLog("GrayCodeModule: Warning: Cannot create gray image from current image.\n");
            delete m_data->grayImage;
            m_data->grayImage = NULL;
            return false;
        }
    }



    getGray(m_data->grayImage);

    return true;
}
Beispiel #15
0
void Valgrind::WriteToLog(const wxString& Text)
{
	m_ValgrindLog->Clear();
	// maybe also show event needed ??
#if 0
CodeBlocksLogEvent evtShow(cbEVT_SHOW_LOG_MANAGER);
Manager::Get()->ProcessEvent(evtShow);
#endif
	AppendToLog(Text);
} // end of WriteToLog
Beispiel #16
0
bool CppCheck::DoCppCheckParseXMLv2(TiXmlHandle& Handle)
{
    bool ErrorsPresent = false;

    const TiXmlHandle& Errors = Handle.FirstChildElement("errors");

    for (const TiXmlElement* Error = Errors.FirstChildElement("error").ToElement();
                             Error;
                             Error = Error->NextSiblingElement("error"))
    {
        wxString Id;
        if (const char* IdValue = Error->Attribute("id"))
            Id = wxString::FromAscii(IdValue);
        wxString Severity;
        if (const char* SeverityValue = Error->Attribute("severity"))
            Severity = wxString::FromAscii(SeverityValue);
        wxString Message;
        if (const char* MessageValue = Error->Attribute("msg"))
            Message = wxString::FromAscii(MessageValue);
        wxString CWE;
        if (const char* CWEValue = Error->Attribute("cwe"))
            CWE = wxString::FromAscii(CWEValue);
        wxString Verbose;
        if (const char* VerboseValue = Error->Attribute("verbose"))
            Verbose = wxString::FromAscii(VerboseValue);
        const wxString FullMessage = Id + _T(" : ") + Severity + _T(" : ") + Verbose;

        wxString File;
        wxString Line;
        const TiXmlElement* Location = Error->FirstChildElement("location");
        if (nullptr!=Location)
        {
            if (const char* FileValue = Location->Attribute("file"))
                File = wxString::FromAscii(FileValue);
            if (const char* LineValue = Location->Attribute("line"))
                Line = wxString::FromAscii(LineValue);
        }

        if (!FullMessage.IsEmpty() && !File.IsEmpty() && !Line.IsEmpty())
        {
            wxArrayString Arr;
            Arr.Add(File);
            Arr.Add(Line);
            Arr.Add(FullMessage);
            m_ListLog->Append(Arr);
            ErrorsPresent = true;
        }
        else if (!Message.IsEmpty())
            AppendToLog(Message); // might be something important like config not found...
    }

    return ErrorsPresent;
}
Beispiel #17
0
void CppCheck::DoCppCheckAnalysis(const wxString& Xml)
{
    // clear the list
    m_ListLog->Clear();

    TiXmlDocument Doc;
    Doc.Parse( Xml.ToAscii() );
    if ( Doc.Error() )
    {
        wxString msg = _("Failed to parse cppcheck XML file.\nProbably it's not produced correctly.");
        AppendToLog(msg);
        cbMessageBox(msg, _("Error"), wxICON_ERROR | wxOK, Manager::Get()->GetAppWindow());
    }
    else
    {
        TiXmlHandle Handle(&Doc);
        Handle = Handle.FirstChildElement("results");

        bool ErrorsPresent = false;
        TiXmlElement* resultNode = Handle.ToElement();
        if (nullptr!=resultNode->Attribute("version"))
        {
            wxString Version = wxString::FromAscii(resultNode->Attribute("version"));
            if ( Version.IsSameAs(wxT("2")) )
                ErrorsPresent = DoCppCheckParseXMLv2(Handle);
            else
            {
                cbMessageBox(_("Unsupported XML file version of CppCheck."),
                             _("Error"), wxICON_ERROR | wxOK, Manager::Get()->GetAppWindow());
            }
        }
        else
        {
            ErrorsPresent = DoCppCheckParseXMLv1(Handle);
        }

        if (ErrorsPresent)
        {
            if ( Manager::Get()->GetLogManager() )
            {
                CodeBlocksLogEvent evtSwitch(cbEVT_SWITCH_TO_LOG_WINDOW, m_ListLog);
                Manager::Get()->ProcessEvent(evtSwitch);
            }
        }

        if ( !Doc.SaveFile("CppCheckResults.xml") )
        {
            cbMessageBox(_("Failed to create output file 'CppCheckResults.xml' for cppcheck.\nPlease check file/folder access rights."),
                         _("Error"), wxICON_ERROR | wxOK, Manager::Get()->GetAppWindow());
        }
    }
}
bool ReliabilityHistogram::run()
{
	if(firstTime)
	{
		if(thermalARGB32.empty() || thermalARGB32.data == NULL)
		{
			this->height = m_data->reliabilityMap->height();
			this->width = m_data->reliabilityMap->width();
			this->thermalARGB32 = cv::Mat(height, width, CV_8UC4 );
		}

		QByteArray string8bit = this->fileMaskName.toLocal8Bit();
//		this->fieldMask = cv::imread(string8bit.data(), CV_LOAD_IMAGE_GRAYSCALE );
        this->fieldMask = cv::Mat();
		this->firstTime = false;
	}

	if(m_data->reliabilityMap->bits() == NULL || m_data->reliabilityMap->isNull() )
	{
		AppendToLog("ReliabilityHistogram: Warning: 'reliability map' not found.\n");
		return true;
	}

	memcpy(thermalARGB32.data, m_data->reliabilityMap->bits(), height*m_data->reliabilityMap->bytesPerLine());
#ifdef __OPENCV3__
    cv::cvtColor(thermalARGB32, currThermal, cv::COLOR_RGBA2BGR);
#else
    cv::cvtColor(thermalARGB32, currThermal, CV_RGBA2BGR);
#endif
    reliability = thermal.thermalToReliability( currThermal );

  float range[] = { 0, 255 } ;
  const float* histRange = { range };
  cv::calcHist( &reliability, 1, 0, this->fieldMask, reliabHisto, 1, &numBins, &histRange, true, true );

	if(m_data->frameNumber == this->showDataAtFrame)
	{
		cv::normalize(this->reliabHisto, histNorm, 0, 100, cv::NORM_MINMAX, -1, cv::Mat() );
		for(int i = 0; i < 256; i++)
		{
			std::cout << histNorm.at<float>(i) << " ";
		}
		std::cout<< std::endl;
	}

	if(showHistogram)
		displayHistogram(this->reliabHisto);

	return true;
}
Beispiel #19
0
bool ObjectModelReader::readObjectModels(QString fileName) {
    if(xmlObjectModels != NULL)
        delete xmlObjectModels;
    xmlObjectModels = new QDomDocument( "ObjectModels" );
    QFile file( fileName );
    if( !file.open(QIODevice::ReadOnly) ) {
        AppendToLog("ObjectModelReader: Error opening file. The object models file '" + fileName + "' could not be opened. Execution will be aborted.");
        return false;
    }

    QString error;
    int line, column;
    if( !xmlObjectModels->setContent( &file ) ) {
        AppendToLog("ObjectModelReader: Error opening file. XML content in the object models file '" + fileName + "' could not be extracted. Execution will be aborted.");
        file.close();
        return false;
    }
    file.close();

    return readParameters(fileName);

    return true;
}
Beispiel #20
0
///////////////////////////////////////////////////////////////////////
// Name: Close()
// Desc: Releases acquired memory and resources
///////////////////////////////////////////////////////////////////////
void CGame::Close()
{
	int cn = 0;

	AppendToLog( LOG_DASH );
	AppendToLog("Closing Game() class...");

	for( cn = 0; cn < NUM_BACKGROUNDS; cn++ )
		RELEASE_SURF( back[cn] );

	RELEASE_SURF( scales[0] );
	RELEASE_SURF( scales[1] );

	for ( cn = 0; cn < 5; cn++ )
		RELEASE_SURF( but_quit[cn] );

	RELEASE_SURF( but_pause );
	RELEASE_SURF( winneris );
	RELEASE_SURF( self_dest );
	// RELEASE_SURF( sprite_tire[0] );
	RELEASE_SURF( getready );

	for( cn = 0; cn < game_num_cars; cn++ )
		Auto[cn].Release();

	Mines.Release();
	Anims.Release();
	Dtoys.Release();

	// release menu
	Menu.Release();

//	Snd.Release();
	Swv.Release();
	Sdl.Close();
	Bindings.Release();
}
Beispiel #21
0
QImage ThermalColor::reliabilityToThermal(QImage &reliability)
{

    if(reliability.format() != QImage::Format_Indexed8) {
        AppendToLog("Warning: ThermalColor::reliabilityToThermal for QImage, only accepts as input the format Indexed8. Returning input image.");
        return reliability;
    }

    QImage thermalImage = reliability;
    thermalImage.setColorTable(*Datapool::thermalTable);

    return thermalImage;


}
Beispiel #22
0
/*! \brief Extract and compile documentation for the currently active project.
 */
void DoxyBlocks::ExtractProject()
{
    if(!IsProjectOpen()){
        return;
    }

    cbProject* prj = Manager::Get()->GetProjectManager()->GetActiveProject();
    if(!prj){
        wxString sMsg = _("Failed to get the active project!");
        AppendToLog(sMsg, LOG_ERROR);
        return;
    }

    // Check whether AutoVersioning is active for this project.
    if(m_bAutoVersioning){
        // If we're using autoversion for docs, get the value.
        if(m_pConfig->GetUseAutoVersion()){
            m_sAutoVersion = GetAutoVersion();
            m_pConfig->SetProjectNumber(m_sAutoVersion);
            // Update the config object and mark the project as modified so the new version gets saved on exit.
            SaveSettings();
            prj->SetModified();
        }
    }

    AppendToLog(wxT("----------------------------------------------------------------------------------------------------"));
    AppendToLog(_("Extracting documentation for ") + prj->GetTitle() + wxT("."));
    AppendToLog(_("DoxyBlocks is working, please wait a few moments..."));

    {
        wxBusyInfo running(_("Running doxygen. Please wait..."), Manager::Get()->GetAppWindow());
        GenerateDocuments(prj);
    } // end lifetime of wxBusyInfo.

    AppendToLog(_("\nDone.\n"));
}
bool BallClasificationModule::run()
{
//    this->dominantcolor();
    n_size = 0;
    n_ecc = 0;
    n_color = 0;
    n_grassctx = 0;
    n_ball = 0;

    destroyAllWindows();
    if(!m_data->blobs.empty()) {
        Blob *blob;
        int i = 0;
        int cont = 0;
        std::vector<Blob>::iterator iter = m_data->blobs.begin();
        while(iter != m_data->blobs.end()) {
            blob = &*iter;
            if( coarse2fine(blob,cont) ) {
                blob->id = i++;
                iter++;
            } else {
                if(m_delInForeground)
                    deleteBlobFromForeground(blob);
                iter = m_data->blobs.erase(iter);
            }
            cont++;
        }
    }
    else
        AppendToLog("NO HAY PELOTA");
    AppendToLog("Size: " + QString::number(n_size));
    AppendToLog("Ecc : " + QString::number(n_ecc));
    AppendToLog("Col : " + QString::number(n_color));
    AppendToLog("Ball: " + QString::number(n_ball));
    return true;
}
bool regionalSegmentationModule::setParameters(QDomNode& config){
    QDomNode n;

    if(config.isNull()) { //Parameter set for module not defined
        m_bins = 32;
        w_size = 11;
        m_hullOffset = 1;
        m_K = 2;
    } else {
        if( !( n = XmlCommon::getParameterNode("ColorHistogramBinSize", config) ).isNull() ) {
            m_bins = XmlCommon::getParameterValue(n).toInt();
            if(m_bins <= 0 || m_bins > 128) {
                m_bins = 32;
                AppendToLog("regionalSegmentationModule: Warning: 'ColorHistogramBinSize' must be in ]0,128]. Taking default: \n\t\tColorHistogramBinSize = " + QString::number(m_bins) );
            }
        } else { //default
            m_bins = 32;
            AppendToLog("regionalSegmentationModule: Warning: 'ColorHistogramBinSize' not defined. Taking default: \n\t\tColorHistogramBinSize = " + QString::number(m_bins) );
        }
        addParameter("ColorHistogramBinSize", QString::number(m_bins), "int");

        if( !( n = XmlCommon::getParameterNode("SearchWindowSize", config) ).isNull() ) {
            w_size = XmlCommon::getParameterValue(n).toInt();
            if(w_size <= 0) {
                w_size = 11;
                AppendToLog("regionalSegmentationModule: Warning: 'SearchWindowSize' must be higher than 0. Taking default: \n\t\tColorHistogramBinSize = " + QString::number(w_size) );
            }
        } else { //default
            w_size = 11;
            AppendToLog("regionalSegmentationModule: Warning: 'SearchWindowSize' not defined. Taking default: \n\t\tSearchWindowSize = " + QString::number(w_size) );
        }
        addParameter("SearchWindowSize", QString::number(w_size), "int");

        if( !( n = XmlCommon::getParameterNode("ConvexHullOffset", config) ).isNull() ) {
            m_hullOffset = XmlCommon::getParameterValue(n).toInt();
        } else { //default
            m_hullOffset = 1;
            AppendToLog("regionalSegmentationModule: Warning: 'ConvexHullOffset' not defined. Taking default: \n\t\tConvexHullOffset = " + QString::number(m_hullOffset) );
        }
        addParameter("ConvexHullOffset", QString::number(m_hullOffset), "int");

        if( !( n = XmlCommon::getParameterNode("PrincipalAxisStep", config) ).isNull() ) {
            m_K = XmlCommon::getParameterValue(n).toInt();
        } else { //default
            m_K = 2;
            AppendToLog("regionalSegmentationModule: Warning: 'PrincipalAxisStep' not defined. Taking default: \n\t\tPrincipalAxisStep = " + QString::number(m_K) );
        }
        addParameter("PrincipalAxisStep", QString::number(m_K), "int");

    }

    return true;
}
Beispiel #25
0
bool GrayCodeModule::init(){
    if(first == false && m_data->currentImage != NULL) {
        if(m_data->grayImage != NULL)
            delete m_data->grayImage;

        m_data->grayImage = new QImage(m_data->currentImage->width(),
                                       m_data->currentImage->height(),
                                       QImage::Format_ARGB32);
        if(m_data->grayImage->isNull()) {
            AppendToLog("GrayCodeModule: Warning: Cannot create gray image from current image.\n");
            delete m_data->grayImage;
            m_data->grayImage = NULL;
        } else
            first = true;
    }

    return true;
}
Beispiel #26
0
bool PlanarStatistics::setParameters(QDomNode& config){
    QDomNode n;
    if(config.isNull()) { //Parameter set for module not defined
        m_ofile = "planar-statistics-results.txt";
        m_osample = 1;
        m_timeForStill = 0.5;
        m_speedForStill = 5; // [cm/sec]
    } else {
        if( ( n = XmlCommon::getParameterNode("OutputFileName", config) ).isNull() ) {
            AppendToLog("PlanarStatisticsModule: Warning: Configuration '" + m_data->m_config_file + "' file does not define an entry 'OutputFileName' for PlanarStatisticsModule. Taking default value (planar-statistics-results.txt).");
            m_ofile = "planar-statistics-results.txt";
        } else
            m_ofile = XmlCommon::getParameterValue(n);

        if( ( n = XmlCommon::getParameterNode("OutputSampleRate", config) ).isNull() ) {
            AppendToLog("PlanarStatisticsModule: Warning: Configuration '" + m_data->m_config_file + "' file does not define an entry 'OutputSampleRate' for PlanarStatisticsModule. Taking default value (1).");
            m_osample = 1;
        } else
            m_osample = XmlCommon::getParameterValue(n).toInt();

        if( ( n = XmlCommon::getParameterNode("TimeForStill", config) ).isNull() ) {
            AppendToLog("PlanarStatisticsModule: Warning: Configuration '" + m_data->m_config_file + "' file does not define an entry 'TimeForStill' for PlanarStatisticsModule. Taking default value (0.5).");
            m_timeForStill = 0.5;
        } else
            m_timeForStill = XmlCommon::getParameterValue(n).toDouble();

        if( ( n = XmlCommon::getParameterNode("SpeedForStill", config) ).isNull() ) {
            AppendToLog("PlanarStatisticsModule: Warning: Configuration '" + m_data->m_config_file + "' file does not define an entry 'SpeedForStill' for PlanarStatisticsModule. Taking default value (5.0).");
            m_speedForStill = 5.0;
        } else
            m_speedForStill = XmlCommon::getParameterValue(n).toDouble();

        if( ( n = XmlCommon::getParameterNode("RateOfFramesInPerimeter", config) ).isNull() ) {
            AppendToLog("PlanarStatisticsModule: Warning: Configuration '" + m_data->m_config_file + "' file does not define an entry 'RateOfFramesInPerimeter' for PlanarStatisticsModule. Taking default value (0.5).");
            m_RateOfFramesInPerimeter = 0.5;
        } else
            m_RateOfFramesInPerimeter = XmlCommon::getParameterValue(n).toDouble();

        outZonePresent = true;
        if( ( n = XmlCommon::getParameterNode("OutZoneForPerimeter", config) ).isNull() ) {
            AppendToLog("PlanarStatisticsModule: Warning: Configuration '" + m_data->m_config_file + "' file does not define an entry 'OutZoneForPerimeter' for PlanarStatisticsModule. Statistics for perimeter deactivated.");
            outZonePresent = false;
            m_OutZone = "";
        } else
            m_OutZone = XmlCommon::getParameterValue(n);

    }

    return true;
}
void CCTestFrame::OnCCLogger(wxCommandEvent& event)
{
    wxString log(event.GetString());

    for (size_t i = 0; i < log.Len(); ++i) // Convert '\r' to "\r", '\n' to "\n"
    {
        if (log.GetChar(i) == _T('\r'))
        {
            log.SetChar(i, _T('\\'));
            log.insert(++i, 1, _T('r'));
        }
        else if (log.GetChar(i) == _T('\n'))
        {
            log.SetChar(i, _T('\\'));
            log.insert(++i, 1, _T('n'));
        }
    }

    AppendToLog(log);
}
Beispiel #28
0
void PlanarStatistics::init() {
    m_file.setFileName(m_ofile);
    lastTimeStamp.millisecond = -1;
    lastMilliSecondsDifference = 0;


    //Verify perimeter exclusion zone
    if(outZonePresent == true) {
        bool found = false;
        std::vector< QSharedPointer<world::ZoneH> >::iterator it,
                it_end = m_data->sceneModel->ZonesH.end();
        QSharedPointer<world::ZoneH> z;

        for(it=m_data->sceneModel->ZonesH.begin(); it != it_end; it++) {
            z = *it;
            if(z->name == m_OutZone) {
                found = true;
                ozone = z;
            }
        }
        if(found == false)
            outZonePresent = false;
    }

    if (!m_file.open(QIODevice::WriteOnly | QIODevice::Text)) {
        AppendToLog("PlanarStatistics Error: Unable to open file '"+ m_ofile +"' for writing.");
        return;
    }
    QTextStream statsStream(&m_file);
    if(outZonePresent) {
        statsStream << "\t\t#1\t#2\t#4\t#5\t#6\t#9\t#10" << endl;
        statsStream << "Num\tFrame\tT Mov\tT Still\tDist\tStops\tD Inter\t%D Per\t%T Per " << endl;
    } else {
        statsStream << "\t\t#1\t#2\t#4\t#5\t#6" << endl;
        statsStream << "Num\tFrame\tT Mov\tT Still\tDist\tStops\tD Inter" << endl;
    }
    m_file.close();


}
bool BlobSuperpixelModuleSEEDS::run(){

    if(m_data->currentImage == NULL || m_data->currentImage->isNull()) {
        AppendToLog("BlobSuperpixelModuleSEEDS: Warning: No current image. Aborting execution...\n");
        return false;
    }

    if(m_data->superpixel_labels != NULL)
        delete[] m_data->superpixel_labels;
    m_data->superpixel_labels = NULL;

    if(m_data->blobs.empty())
        return true;

    std::cerr << "BlobSuperpixelModuleSEEDS: Frame number: " << m_data->frameNumber << std::endl;


    int w = m_data->currentImage->width(), h = m_data->currentImage->height(), bpl = m_data->currentImage->bytesPerLine();

    int i=0;
    std::vector<Blob>::iterator it, it_end = m_data->blobs.end();
    m_data->blobSuperpixelBoundingRegion.resize(m_data->blobs.size());
    m_data->blobSuperpixelLabels.resize(m_data->blobs.size());
    m_data->blobSuperpixelNumber.resize(m_data->blobs.size());

    cv::Mat im, im2;
    im.create(h, w, CV_8UC4);
    ImageTransforms::copyPixelsQImageToMat(*m_data->currentImage, im);
    im2.create(h, w, CV_8UC3);
    cv::cvtColor(im, im2, cv::COLOR_BGRA2BGR);

    bs.initSuperpixels(m_sfactor, m_superpixelnumber, m_num_levels, m_use_prior, m_histogram_bins, m_double_step);

    for(it=m_data->blobs.begin(); it!=it_end; it++, i++) {
        m_data->blobSuperpixelNumber[i] = bs.getSuperpixelForBlob(im2, *it, m_data->blobSuperpixelLabels[i], m_data->blobSuperpixelBoundingRegion[i], m_num_iterations);
    }

    return true;
}
Beispiel #30
0
void CppCheck::DoVeraAnalysis(const wxArrayString& Result)
{
  wxRegEx reVera(_T("(.+):([0-9]+):(.+)"));

  bool ErrorsPresent = false;

  for (size_t idxCount = 0; idxCount < Result.GetCount(); ++idxCount)
  {
    wxString Res = Result[idxCount];
    if (reVera.Matches(Res))
    {
      wxString File = reVera.GetMatch(Res, 1);
      wxString Line = reVera.GetMatch(Res, 2);
      wxString Msg  = reVera.GetMatch(Res, 3);

      if (!File.IsEmpty() && !Line.IsEmpty() && !Msg.IsEmpty())
      {
          wxArrayString Arr;
          Arr.Add(File);
          Arr.Add(Line);
          Arr.Add(Msg);
          m_ListLog->Append(Arr);
          ErrorsPresent = true;
      }
      else if (!Msg.IsEmpty())
          AppendToLog(Msg); // might be something important like config not found...
    }
  }

  if (ErrorsPresent)
  {
      if ( Manager::Get()->GetLogManager() )
      {
          CodeBlocksLogEvent evtSwitch(cbEVT_SWITCH_TO_LOG_WINDOW, m_ListLog);
          Manager::Get()->ProcessEvent(evtSwitch);
      }
  }
}