Can someone explain the logic of this codes please

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
  QStringList Para_Meters;
        std::string Secret_Code;
        QString CaptureInterval;
        QString MaximumCaptureTime;
        std::string Para_MetersInString = val.toStdString();
        std::string ifContain = ",";
        if (Para_MetersInString.find(ifContain) != std::string::npos)
        {
            Para_Meters = val.split(",");
            int parameterSize = Para_Meters.size();
            if(QString::compare(Para_Meters.at(1).toLower(),"logs") == 0){
                if(parameterSize == 3){
                    Secret_Code = Para_Meters.at(0).toStdString();
                    CaptureInterval = "111";
                    MaximumCaptureTime = Para_Meters.at(2);
                }else{
                    Secret_Code = Para_Meters.at(0).toStdString();
                    CaptureInterval = Para_Meters.at(2);
                    MaximumCaptureTime = Para_Meters.at(3);
                }
            }
            else{
                if(parameterSize == 2){
                    Secret_Code = Para_Meters.at(0).toStdString();
                    CaptureInterval = "111";
                    MaximumCaptureTime = Para_Meters.at(1);
                }else{
                    Secret_Code = Para_Meters.at(0).toStdString();
                    CaptureInterval = Para_Meters.at(1);
                    MaximumCaptureTime = Para_Meters.at(2);
                }
            }

        }

        //if(Secret_Code == "JORGE_PANGIT_DEBUG")
        if(Secret_Code == "MARQUEE")
        {
            QString capturingIntervalLog = "";
            if(CaptureInterval == "111")
            {
                capturingIntervalLog = "100";
            }
            else
            {
                capturingIntervalLog = CaptureInterval;
            }
            if(QString::compare(Para_Meters.at(1).toLower(),"logs") == 0){
                mpParent->logUpdate("Reading Marquee OCR for " + obj + " with capturing interval of  " + capturingIntervalLog + "msec" + " and Maximum Capturing time of "+MaximumCaptureTime +" msec" );
            }
            else{
                mpParent->logUpdate("Marquee OCR Reading for " + obj + " for capturing interval of  " + capturingIntervalLog + "msec" + " Maximum Capturing time of "+MaximumCaptureTime +" msec" );
            }
            mpParent->XMLUpdate("Marquee OCR Reading");
            mpParent->XMLUpdate(obj);
            mpParent->XMLUpdate(val);
        }
        else
        {
            mpParent->logUpdate("Reading " + obj + " for " + val + "msec");
            mpParent->XMLUpdate(act);
            mpParent->XMLUpdate(obj);
            mpParent->XMLUpdate(val);
       }

        if (NULL != mpScFtOcr)
        {
            int rect[4];
            rect[0] = roi.split(':').at(0).toInt();
            rect[1] = roi.split(':').at(1).toInt();
            rect[2] = roi.split(':').at(2).toInt();
            rect[3] = roi.split(':').at(3).toInt();

            mpReadData.clear();
            if (!val.isEmpty())
            {
                if(data.at(4).compare("") != 0)
                {
                    mpScFtOcr->SetModel(model.toStdString());
                }
                //if(Secret_Code == "JORGE_PANGIT_DEBUG")
                if(Secret_Code == "MARQUEE")
                {
                    mpReadData = mpScFtOcr->read(CaptureInterval.toInt(),rect,MaximumCaptureTime.toInt());
                }
                else
                {
                    mpReadData = mpScFtOcr->read(rect, val.toInt());
                }
            }
            mpParent->_result = mpReadData.size() > 0 ? true:false;
        }
        if(Secret_Code == "MARQUEE"){
            if(QString::compare(Para_Meters.at(1).toLower(),"logs") == 0){
                mpParent->_actualValue = mpParent->storeImageAsFile(mpScFtOcr->stitched_images);
            }
        }
        mpParent->logUpdate(mpParent->_result ? "DONE" : "FAIL");
        mpParent->XMLUpdate(mpParent->_result ? "DONE" : "FAIL");

        if(mpParent->_result){
            float fnxtime;
            if(Secret_Code == "MARQUEE"){
                int processTime = mpScFtOcr->getProcTime();
                fnxtime = processTime/1000.0;
            }else{
                fnxtime = (std::stoll(mpReadData[mpReadData.size()-1][0])-std::stoll(mpReadData[0][0]))/1000.0;
            }
            QString num = QString::number(fnxtime);
            mpParent->logUpdate(num);
            mpParent->XMLUpdate(num);
        }else{
            mpParent->logUpdate("-");
            mpParent->XMLUpdate("-");
        }
    }
}
Last edited on
It is a small piece of code from a large piece of code about OCR software, and a person who writes "Para_Meters". Not very well written code, I wouldn't wanna read this.

Next time use code tags http://www.cplusplus.com/articles/jEywvCM9/

I don't really wanna bump this, and nobody should, but sdaasdf123, please read the sticky on the beginners board and read how to ask a question, your post isn't comprehensible, and nobody is gonna sit you down and explain every line, line by line, because if you cannot do that yourself, I don't know what to say, read the documentation and practice more.
Last edited on
Sorry its my first time, I used the code tags now please reconsider
Please DON'T post multiple threads for the same topic. It wastes everyone's time.

http://www.cplusplus.com/forum/general/248335/
and a person who writes "Para_Meters".
WTF? Why would you do that? Did they just have no idea how to spell "parameters"? How is that possible?

PS: Also, Camel_Snake_Case is the worst thing ever.
Last edited on
Sorry, this is not my code, im just trying to understand its flow :(( pls help
It's hard to detect what the semantic of the code is. There are some variables where it's not clear what they represent:
1
2
3
4
5
6
7
8
val
act
obj
mpParent
roi
mpReadData
mpScFtOcr
model


When I had to guess, I would say that the crucial pieces are line 84 and 86. Seems that at these lines the character reading will proceed.
Topic archived. No new replies allowed.