Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
nmsdk
rdk
Commits
da2c58ba1abc
Commit
3e393477
authored
Jun 11, 2021
by
Alexab
Browse files
Merge with StandaloneRun
--HG-- branch : MockCompsTest
parents
c9008fdc49f0
79f1efa3647d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Core/Application/Qt/UProjectDeployerQt.cpp
View file @
da2c58ba
...
...
@@ -948,9 +948,9 @@ bool UProjectDeployProcessingThread::VerifyData()
}
//====================================================================
UProjectResultsUploadingThread
::
UProjectResultsUploadingThread
(
bool
standalone
)
UProjectResultsUploadingThread
::
UProjectResultsUploadingThread
()
{
this
->
standalone
=
standalone
;
}
UProjectResultsUploadingThread
::~
UProjectResultsUploadingThread
()
...
...
@@ -1027,14 +1027,12 @@ void UProjectResultsUploadingThread::run()
return
;
}
if
(
!
standalone
)
if
(
!
CopyResultsToRemoteStorageDir
()
)
{
if
(
!
CopyResultsToRemoteStorageDir
())
{
uploadState
=
DS_Error
;
return
;
}
uploadState
=
DS_Error
;
return
;
}
/*
uploadState = DS_PackResults;
if(!ZipResults())
...
...
@@ -1250,6 +1248,7 @@ UProjectDeployerQt::UProjectDeployerQt(void):
classification
.
LibClassCountTagName
=
"NumClasses"
;
file_tags
[
"TPyUBitmapClassifier"
]
=
classification
;
component_classes
.
push_back
(
"TPyUBitmapClassifier"
);
MLlibDescr
sq_det
;
sq_det
.
LibName
=
"TPyObjectDetectorSqueezeDet"
;
sq_det
.
LibConfigFileTagName
=
"ConfigPath"
;
...
...
@@ -1258,6 +1257,7 @@ UProjectDeployerQt::UProjectDeployerQt(void):
sq_det
.
LibClassCountTagName
=
""
;
file_tags
[
"TPyObjectDetectorSqueezeDet"
]
=
sq_det
;
component_classes
.
push_back
(
"TPyObjectDetectorSqueezeDet"
);
MLlibDescr
det_yolo
;
det_yolo
.
LibName
=
"TPyObjectDetector"
;
det_yolo
.
LibConfigFileTagName
=
"ConfigPathYOLO"
;
...
...
@@ -1266,6 +1266,7 @@ UProjectDeployerQt::UProjectDeployerQt(void):
det_yolo
.
LibClassCountTagName
=
""
;
file_tags
[
"TPyObjectDetector"
]
=
det_yolo
;
component_classes
.
push_back
(
"TPyObjectDetector"
);
MLlibDescr
protobuf
;
protobuf
.
LibName
=
"TPySegmentatorProtobuf"
;
protobuf
.
LibConfigFileTagName
=
"JSONPath"
;
...
...
@@ -1274,6 +1275,7 @@ UProjectDeployerQt::UProjectDeployerQt(void):
protobuf
.
LibClassCountTagName
=
""
;
file_tags
[
"TPySegmentatorProtobuf"
]
=
protobuf
;
component_classes
.
push_back
(
"TPySegmentatorProtobuf"
);
MLlibDescr
unet
;
unet
.
LibName
=
"TPySegmentatorUNet"
;
unet
.
LibConfigFileTagName
=
""
;
...
...
@@ -1282,6 +1284,7 @@ UProjectDeployerQt::UProjectDeployerQt(void):
unet
.
LibClassCountTagName
=
""
;
file_tags
[
"TPySegmentatorUNet"
]
=
unet
;
component_classes
.
push_back
(
"TPySegmentatorUNet"
);
MLlibDescr
classifier_opencv
;
classifier_opencv
.
LibName
=
"UOpenCvClassifier"
;
classifier_opencv
.
LibConfigFileTagName
=
""
;
...
...
@@ -1290,6 +1293,7 @@ UProjectDeployerQt::UProjectDeployerQt(void):
classifier_opencv
.
LibClassCountTagName
=
"NumClasses"
;
file_tags
[
"UOpenCvClassifier"
]
=
classifier_opencv
;
component_classes
.
push_back
(
"UOpenCvClassifier"
);
MLlibDescr
detector_opencv
;
detector_opencv
.
LibName
=
"UOpenCvDetector"
;
detector_opencv
.
LibConfigFileTagName
=
"ConfigPath"
;
...
...
@@ -1297,8 +1301,8 @@ UProjectDeployerQt::UProjectDeployerQt(void):
detector_opencv
.
LibWeightFileTagName
=
"ModelPath"
;
detector_opencv
.
LibClassCountTagName
=
""
;
file_tags
[
"UOpenCvDetector"
]
=
detector_opencv
;
/*
component_classes
.
push_back
(
"UOpenCvDetector"
);
MLlibDescr
classification_tester
;
detector_opencv
.
LibName
=
"TPyPredictSort"
;
detector_opencv
.
LibConfigFileTagName
=
"ConfigPath"
;
...
...
@@ -1307,7 +1311,7 @@ UProjectDeployerQt::UProjectDeployerQt(void):
detector_opencv
.
LibClassCountTagName
=
""
;
file_tags
[
"TPyPredictSort"
]
=
classification_tester
;
component_classes
.
push_back
(
"TPyPredictSort"
);
*/
CaptureLibDescr
opencv_videocapture
;
opencv_videocapture
.
LibName
=
"TCaptureOpenCV"
;
...
...
@@ -1631,8 +1635,8 @@ int UProjectDeployerQt::StartProjectDeployment(int deploy_task_id, bool standalo
}
}
if
(
!
standalone
&&
(
task_template_download_required
||
task_weights_download_required
||
task_script_download_required
||
task_src_download_required
)
)
if
(
task_template_download_required
||
task_weights_download_required
||
task_script_download_required
||
task_src_download_required
)
{
deployProcessingThread
=
new
UProjectDeployProcessingThread
();
...
...
@@ -1698,8 +1702,7 @@ void UProjectDeployerQt::AConnectToDatabase()
delete
db
;
exit
(
1
);
}
RegisterSolverToDatabase
();
//RegisterSolverToDatabase();
}
/*
...
...
@@ -2001,6 +2004,10 @@ int UProjectDeployerQt::CopyProjectToTempFolder()
qDebug
()
<<
"abs_ttp = "
<<
abs_ttp
;
QDir
(
pdpath
).
removeRecursively
();
QDir
().
mkdir
(
pdpath
);
QFileInfo
fi
(
abs_ttp
);
QDir
src_dir
(
fi
.
absoluteDir
());
QStringList
files_dirs
=
src_dir
.
entryList
(
QDir
::
Filter
::
NoDotAndDotDot
|
QDir
::
Filter
::
Files
);
...
...
@@ -2336,6 +2343,22 @@ QString UProjectDeployerQt::GetTimeStampInPSqlFormat(const QDateTime &now)
///
int
UProjectDeployerQt
::
RunPreparedProject
()
{
RDK
::
UELockPtr
<
RDK
::
UNet
>
model
=
RDK
::
GetModelLock
<
RDK
::
UNet
>
(
0
);
if
(
!
model
)
return
1
;
// /
std
::
vector
<
std
::
string
>
predictor_names
;
predictor_names
=
model
->
GetComponentsNameByClassName
(
"TPyPredictSort"
,
predictor_names
);
if
(
!
predictor_names
.
empty
())
{
RDK
::
UEPtr
<
RDK
::
UContainer
>
predictor_container
;
predictor_container
=
model
->
GetComponentL
(
predictor_names
[
0
]);
bool
*
start_prediction
=
predictor_container
->
AccessPropertyData
<
bool
>
(
"StartPredict"
);
*
start_prediction
=
true
;
}
// ,
processing_start_datetime
=
QDateTime
::
currentDateTime
();
Application
->
StartChannel
(
-
1
);
...
...
@@ -2551,7 +2574,7 @@ bool UProjectDeployerQt::FinishCalculation()
/// ( Results) ,
///
bool
UProjectDeployerQt
::
UploadCalculationResults
(
bool
standalone
)
bool
UProjectDeployerQt
::
UploadCalculationResults
()
{
// ,
// , ...
...
...
@@ -2620,7 +2643,7 @@ bool UProjectDeployerQt::UploadCalculationResults(bool standalone)
{
delete
projectResultsUploadingThread
;
}
projectResultsUploadingThread
=
new
UProjectResultsUploadingThread
(
standalone
);
projectResultsUploadingThread
=
new
UProjectResultsUploadingThread
();
projectResultsUploadingThread
->
SetDatabasePath
(
db_path
);
projectResultsUploadingThread
->
SetRemoteFtpPath
(
QString
(
ftp_remote_path
.
c_str
()));
projectResultsUploadingThread
->
SetProjectResultsDirPath
(
results_dir_path
);
...
...
@@ -2667,6 +2690,29 @@ bool UProjectDeployerQt::UploadCalculationResults(bool standalone)
return
false
;
}
// vid_an.results
QDateTime
result_add_time
=
QDateTime
::
currentDateTime
();
QString
result_add_time_str
=
GetTimeStampInPSqlFormat
(
result_add_time
);
QSqlQuery
res_q
(
*
db
);
QString
res_query
=
"INSERT INTO vid_an.results(result_task_id, result_path, result_imseq, result_anno, result_metrics, result_add_time) "
"VALUES("
+
QString
::
number
(
task_id
)
+
","
+
"'"
+
results_deploy_end_path
+
"',"
+
QString
::
number
(
task_src_id
)
+
","
+
"0"
+
","
+
"'metrics'"
+
","
+
"'"
+
result_add_time_str
+
"');"
;
res_q
.
prepare
(
res_query
);
if
(
!
res_q
.
exec
())
{
std
::
cerr
<<
res_query
.
toUtf8
().
constData
();
lastError
=
(
QString
(
"Error add result record to database: "
)
+
res_q
.
lastError
().
text
()).
toUtf8
().
constData
();
deploymentState
=
DS_Error
;
return
false
;
}
return
true
;
}
...
...
@@ -3003,155 +3049,176 @@ void UProjectRunThread::ProjectStateDeployment()
void
UProjectRunThread
::
ProjectStateCalculation
()
{
WriteLog
(
"Calculation in progress: "
);
int
calculation_state
=-
1
;
int
capture_state
=-
1
;
static
unsigned
long
long
capture_frame_id
=
0
;
static
unsigned
long
long
capture_max_frame_id
=
0
;
unsigned
long
long
capture_frid
=
0
;
unsigned
long
long
capture_maxfrid
=
0
;
std
::
string
message
=
""
;
int
calc_state
=
Deployer
->
GetCalculationState
();
if
(
calc_state
>=
0
)
{
calculation_state
=
calc_state
;
// , :
std
::
string
log_err
=
""
;
bool
process_log_res
=
Deployer
->
ProcessCalculationLog
(
log_err
);
if
(
!
process_log_res
)
RDK
::
UELockPtr
<
RDK
::
UNet
>
model
=
RDK
::
GetModelLock
<
RDK
::
UNet
>
(
0
);
if
(
!
model
)
return
;
// /
std
::
vector
<
std
::
string
>
predictor_names
;
predictor_names
=
model
->
GetComponentsNameByClassName
(
"TPyPredictSort"
,
predictor_names
);
if
(
!
predictor_names
.
empty
())
{
RDK
::
UEPtr
<
RDK
::
UContainer
>
predictor_container
;
predictor_container
=
model
->
GetComponentL
(
predictor_names
[
0
]);
bool
*
prediction_ended
=
predictor_container
->
AccessPropertyData
<
bool
>
(
"PredictionEnded"
);
if
(
*
prediction_ended
)
{
message
=
std
::
string
(
"Log error: "
)
+
log_err
;
calculation_state
=
3
;
FinishProject
();
}
else
}
else
{
WriteLog
(
"Calculation in progress: "
);
int
calculation_state
=-
1
;
int
capture_state
=-
1
;
static
unsigned
long
long
capture_frame_id
=
0
;
static
unsigned
long
long
capture_max_frame_id
=
0
;
unsigned
long
long
capture_frid
=
0
;
unsigned
long
long
capture_maxfrid
=
0
;
std
::
string
message
=
""
;
int
calc_state
=
Deployer
->
GetCalculationState
();
if
(
calc_state
>=
0
)
{
if
(
calc_state
==
2
)
calculation_state
=
calc_state
;
// , :
std
::
string
log_err
=
""
;
bool
process_log_res
=
Deployer
->
ProcessCalculationLog
(
log_err
);
if
(
!
process_log_res
)
{
message
=
"Calculation started but not active (2)."
;
message
=
std
::
string
(
"Log error: "
)
+
log_err
;
calculation_state
=
3
;
}
else
if
(
calc_state
==
1
||
calc_state
==
0
)
else
{
int
cap_state_out
=
-
1
;
bool
res_capstate
=
Deployer
->
GetCaptureState
(
cap_state_out
,
capture_frame_id
,
capture_max_frame_id
);
if
(
!
res_capstate
)
if
(
calc_state
==
2
)
{
std
::
string
err
=
""
;
err
=
Deployer
->
GetLastError
();
message
=
"Get capture state error: "
+
err
;
message
=
"Calculation started but not active (2)."
;
}
else
if
(
calc_state
==
1
||
calc_state
==
0
)
{
int
cap_state_out
=
-
1
;
bool
res_capstate
=
Deployer
->
GetCaptureState
(
cap_state_out
,
capture_frame_id
,
capture_max_frame_id
);
if
(
!
res_capstate
)
{
std
::
string
err
=
""
;
err
=
Deployer
->
GetLastError
();
message
=
"Get capture state error: "
+
err
;
}
else
{
capture_state
=
cap_state_out
;
capture_frid
=
capture_frame_id
;
capture_maxfrid
=
capture_max_frame_id
;
message
=
"Calculation is active"
;
}
}
else
{
capture_state
=
cap_state_out
;
capture_frid
=
capture_frame_id
;
capture_maxfrid
=
capture_max_frame_id
;
message
=
"Calculation is active"
;
message
=
"Error: Wrong calculation state number"
;
}
}
else
{
message
=
"Error: Wrong calculation state number"
;
}
}
}
else
{
message
=
"GetCalculationState() error: "
+
Deployer
->
GetLastError
();;
}
std
::
stringstream
res_ss
;
res_ss
<<
calculation_state
<<
"|-|"
<<
capture_state
<<
"|-|"
<<
capture_frid
<<
"|-|"
<<
capture_maxfrid
<<
"|-|"
<<
message
.
c_str
();
message
=
res_ss
.
str
();
if
(
!
message
.
empty
())
WriteLog
(
"Capture state: "
+
message
);
///
/// 0 -
/// 1 -
/// 2 - ,
/// 3 -
std
::
string
cstate_str
=
""
;
switch
(
calculation_state
)
{
case
-
1
:
cstate_str
=
"Error get calc_state (-1)"
;
break
;
case
0
:
cstate_str
=
"Calc thread active (0)"
;
break
;
case
1
:
cstate_str
=
"Calc thread paused (1)"
;
break
;
case
2
:
cstate_str
=
"Calc thread started but inactive (2)"
;
break
;
case
3
:
WriteLog
(
"Fatal error occured during calculation: "
+
message
);
projectRunState
=
ProjectRunState
::
PS_Termination
;
break
;
default:
cstate_str
=
"Calc thread result default ("
+
std
::
to_string
(
calculation_state
)
+
")"
;
break
;
}
//
#define RDK_CAPTURE_EMPTY 0
#define RDK_CAPTURE_CREATED 64
#define RDK_CAPTURE_INITIALIZATION 1
#define RDK_CAPTURE_CONNECTED 2
#define RDK_CAPTURE_PAUSED 4
#define RDK_CAPTURE_ACTIVE 8
#define RDK_CAPTURE_DISCONNECTED 16
#define RDK_CAPTURE_RECONNECT 32
std
::
string
capstate_str
=
"Cap state: "
;
}
else
{
message
=
"GetCalculationState() error: "
+
Deployer
->
GetLastError
();;
}
if
(
capture_state
&
RDK_CAPTURE_EMPTY
)
{
capstate_str
+=
"(RDK_CAPTURE_EMPTY)"
;
}
if
(
capture_state
&
RDK_CAPTURE_CREATED
)
{
capstate_str
+=
"(RDK_CAPTURE_CREATED)"
;
}
if
(
capture_state
&
RDK_CAPTURE_INITIALIZATION
)
{
capstate_str
+=
"(RDK_CAPTURE_INITIALIZATION)"
;
}
if
(
capture_state
&
RDK_CAPTURE_CONNECTED
)
{
capstate_str
+=
"(RDK_CAPTURE_CONNECTED)"
;
}
if
(
capture_state
&
RDK_CAPTURE_PAUSED
)
{
capstate_str
+=
"(RDK_CAPTURE_PAUSED)"
;
}
if
(
capture_state
&
RDK_CAPTURE_ACTIVE
)
{
capstate_str
+=
"(RDK_CAPTURE_ACTIVE)"
;
}
if
(
capture_state
&
RDK_CAPTURE_DISCONNECTED
)
{
capstate_str
+=
"(RDK_CAPTURE_DISCONNECTED)"
;
}
if
(
capture_state
&
RDK_CAPTURE_RECONNECT
)
{
capstate_str
+=
"(RDK_CAPTURE_RECONNECT)"
;
}
std
::
stringstream
res_ss
;
res_ss
<<
calculation_state
<<
"|-|"
<<
capture_state
<<
"|-|"
<<
capture_frid
<<
"|-|"
<<
capture_maxfrid
<<
"|-|"
<<
message
.
c_str
();
message
=
res_ss
.
str
();
if
(
!
message
.
empty
())
WriteLog
(
"Capture state: "
+
message
);
///
/// 0 -
/// 1 -
/// 2 - ,
/// 3 -
std
::
string
cstate_str
=
""
;
switch
(
calculation_state
)
{
case
-
1
:
cstate_str
=
"Error get calc_state (-1)"
;
break
;
case
0
:
cstate_str
=
"Calc thread active (0)"
;
break
;
case
1
:
cstate_str
=
"Calc thread paused (1)"
;
break
;
case
2
:
cstate_str
=
"Calc thread started but inactive (2)"
;
break
;
case
3
:
WriteLog
(
"Fatal error occured during calculation: "
+
message
);
projectRunState
=
ProjectRunState
::
PS_Termination
;
break
;
default:
cstate_str
=
"Calc thread result default ("
+
std
::
to_string
(
calculation_state
)
+
")"
;
break
;
}
//
#define RDK_CAPTURE_EMPTY 0
#define RDK_CAPTURE_CREATED 64
#define RDK_CAPTURE_INITIALIZATION 1
#define RDK_CAPTURE_CONNECTED 2
#define RDK_CAPTURE_PAUSED 4
#define RDK_CAPTURE_ACTIVE 8
#define RDK_CAPTURE_DISCONNECTED 16
#define RDK_CAPTURE_RECONNECT 32
std
::
string
capstate_str
=
"Cap state: "
;
if
(
capture_state
&
RDK_CAPTURE_EMPTY
)
{
capstate_str
+=
"(RDK_CAPTURE_EMPTY)"
;
}
if
(
capture_state
&
RDK_CAPTURE_CREATED
)
{
capstate_str
+=
"(RDK_CAPTURE_CREATED)"
;
}
if
(
capture_state
&
RDK_CAPTURE_INITIALIZATION
)
{
capstate_str
+=
"(RDK_CAPTURE_INITIALIZATION)"
;
}
if
(
capture_state
&
RDK_CAPTURE_CONNECTED
)
{
capstate_str
+=
"(RDK_CAPTURE_CONNECTED)"
;
}
if
(
capture_state
&
RDK_CAPTURE_PAUSED
)
{
capstate_str
+=
"(RDK_CAPTURE_PAUSED)"
;
}
if
(
capture_state
&
RDK_CAPTURE_ACTIVE
)
{
capstate_str
+=
"(RDK_CAPTURE_ACTIVE)"
;
}
if
(
capture_state
&
RDK_CAPTURE_DISCONNECTED
)
{
capstate_str
+=
"(RDK_CAPTURE_DISCONNECTED)"
;
}
if
(
capture_state
&
RDK_CAPTURE_RECONNECT
)
{
capstate_str
+=
"(RDK_CAPTURE_RECONNECT)"
;
}
WriteLog
(
cstate_str
+
"
\n
"
+
capstate_str
);
WriteLog
(
cstate_str
+
"
\n
"
+
capstate_str
);
if
(
capture_frame_id
>
0
&&
capture_max_frame_id
>
0
)
{
message
=
std
::
string
(
"capture_frame_id="
)
+
std
::
to_string
(
capture_frame_id
)
+
std
::
string
(
" capture_max_frame_id="
)
+
std
::
to_string
(
capture_max_frame_id
);
WriteLog
(
message
);
// ,
if
(
capture_frame_id
>=
capture_max_frame_id
||
last_frame_count
>
capture_frame_id
)
if
(
capture_frame_id
>
0
&&
capture_max_frame_id
>
0
)
{
FinishProject
();
}
message
=
std
::
string
(
"capture_frame_id="
)
+
std
::
to_string
(
capture_frame_id
)
+
std
::
string
(
" capture_max_frame_id="
)
+
std
::
to_string
(
capture_max_frame_id
);
WriteLog
(
message
);
// ,
if
(
capture_frame_id
>=
capture_max_frame_id
||
last_frame_count
>
capture_frame_id
)
{
FinishProject
();
}
last_frame_count
=
capture_frame_id
;
last_frame_count
=
capture_frame_id
;
}
}
//TODO:
}
...
...
@@ -3243,7 +3310,7 @@ void UProjectRunThread::FinishProject()
void
UProjectRunThread
::
UploadResults
()
{
if
(
!
Deployer
->
UploadCalculationResults
(
true
))
if
(
!
Deployer
->
UploadCalculationResults
())
{
WriteLog
(
Deployer
->
GetLastError
());
projectRunState
=
ProjectRunState
::
PS_Termination
;
...
...
Core/Application/Qt/UProjectDeployerQt.h
View file @
da2c58ba
...
...
@@ -208,7 +208,7 @@ class RDK_LIB_TYPE UProjectResultsUploadingThread: public QThread
Q_OBJECT
public:
UProjectResultsUploadingThread
(
bool
standalone
=
false
);
UProjectResultsUploadingThread
();
~
UProjectResultsUploadingThread
();
void
run
()
override
;
...
...
@@ -246,7 +246,6 @@ private slots:
void
processReadyReadStandardOutput
();
private:
bool
standalone
;
QString
projectResultsDir
;
QString
storageResultsDir
;
QString
databasePath
;
...
...
@@ -500,7 +499,7 @@ virtual bool ProcessCalculationLog(std::string &error);
virtual
bool
FinishCalculation
();
/// ( Results) ,
///
virtual
bool
UploadCalculationResults
(
bool
standalone
);
virtual
bool
UploadCalculationResults
();
/// ,
/// , ..
virtual
bool
CloseSolver
();
...
...
Core/Application/UProjectDeployer.h
View file @
da2c58ba
...
...
@@ -106,7 +106,7 @@ virtual bool ProcessCalculationLog(std::string &error);
virtual
bool
FinishCalculation
()
{
return
false
;};
/// ( Results) ,
///
virtual
bool
UploadCalculationResults
(
bool
standalone
=
false
)
{
return
false
;};
virtual
bool
UploadCalculationResults
()
{
return
false
;};
/// ,
/// , ..
virtual
bool
CloseSolver
()
{
return
false
;};
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment