Skip to content

Commit

Permalink
Revise params to use vector
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-Dave committed Sep 6, 2024
1 parent b34b494 commit e814bcb
Show file tree
Hide file tree
Showing 17 changed files with 341 additions and 410 deletions.
106 changes: 53 additions & 53 deletions src/alg_sec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,72 +437,74 @@ void cls_algsec::load_dnn()

void cls_algsec::params_log()
{
p_lst *lst = &params->params_array;
p_it it;
ctx_params_item *itm;
int indx;

if (method != "none") {
for (it = lst->begin(); it != lst->end(); it++) {
for (indx=0;indx<params->params_cnt;indx++) {
itm = &params->params_array[indx];
MOTPLS_SHT(INF, TYPE_ALL, NO_ERRNO, "%-25s %s"
,it->param_name.c_str(), it->param_value.c_str());
,itm->param_name.c_str(),itm->param_value.c_str());
}
}
}

void cls_algsec::params_model()
{
p_lst *lst = &params->params_array;
p_it it;

for (it = lst->begin(); it != lst->end(); it++) {
if (it->param_name == "model_file") {
model_file = it->param_value;
} else if (it->param_name == "frame_interval") {
frame_interval = mtoi(it->param_value);
} else if (it->param_name == "image_type") {
image_type = it->param_value;
} else if (it->param_name == "threshold") {
threshold = mtof(it->param_value);
} else if (it->param_name == "scalefactor") {
scalefactor = mtof(it->param_value);
} else if (it->param_name == "rotate") {
rotate = mtoi(it->param_value);
ctx_params_item *itm;
int indx;

for (indx=0;indx<params->params_cnt;indx++) {
itm = &params->params_array[indx];
if (itm->param_name == "model_file") {
model_file = itm->param_value;
} else if (itm->param_name == "frame_interval") {
frame_interval = mtoi(itm->param_value);
} else if (itm->param_name == "image_type") {
image_type = itm->param_value;
} else if (itm->param_name == "threshold") {
threshold = mtof(itm->param_value);
} else if (itm->param_name == "scalefactor") {
scalefactor = mtof(itm->param_value);
} else if (itm->param_name == "rotate") {
rotate = mtoi(itm->param_value);
}

if (method == "hog") {
if (it->param_name =="padding") {
hog_padding = mtoi(it->param_value);
} else if (it->param_name =="threshold_model") {
hog_threshold_model = mtof(it->param_value);
} else if (it->param_name =="winstride") {
hog_winstride = mtoi(it->param_value);
if (itm->param_name =="padding") {
hog_padding = mtoi(itm->param_value);
} else if (itm->param_name =="threshold_model") {
hog_threshold_model = mtof(itm->param_value);
} else if (itm->param_name =="winstride") {
hog_winstride = mtoi(itm->param_value);
}
} else if (method == "haar") {
if (it->param_name =="flags") {
haar_flags = mtoi(it->param_value);
} else if (it->param_name =="maxsize") {
haar_maxsize = mtoi(it->param_value);
} else if (it->param_name =="minsize") {
haar_minsize = mtoi(it->param_value);
} else if (it->param_name =="minneighbors") {
haar_minneighbors = mtoi(it->param_value);
if (itm->param_name =="flags") {
haar_flags = mtoi(itm->param_value);
} else if (itm->param_name =="maxsize") {
haar_maxsize = mtoi(itm->param_value);
} else if (itm->param_name =="minsize") {
haar_minsize = mtoi(itm->param_value);
} else if (itm->param_name =="minneighbors") {
haar_minneighbors = mtoi(itm->param_value);
}
} else if (method == "dnn") {
if (it->param_name == "config") {
dnn_config = it->param_value;
} else if (it->param_name == "classes_file") {
dnn_classes_file = it->param_value;
} else if (it->param_name =="framework") {
dnn_framework = it->param_value;
} else if (it->param_name =="backend") {
dnn_backend = mtoi(it->param_value);
} else if (it->param_name =="target") {
dnn_target = mtoi(it->param_value);
} else if (it->param_name =="scale") {
dnn_scale = mtof(it->param_value);
} else if (it->param_name =="width") {
dnn_width = mtoi(it->param_value);
} else if (it->param_name =="height") {
dnn_height = mtoi(it->param_value);
if (itm->param_name == "config") {
dnn_config = itm->param_value;
} else if (itm->param_name == "classes_file") {
dnn_classes_file = itm->param_value;
} else if (itm->param_name =="framework") {
dnn_framework = itm->param_value;
} else if (itm->param_name =="backend") {
dnn_backend = mtoi(itm->param_value);
} else if (itm->param_name =="target") {
dnn_target = mtoi(itm->param_value);
} else if (itm->param_name =="scale") {
dnn_scale = mtof(itm->param_value);
} else if (itm->param_name =="width") {
dnn_width = mtoi(itm->param_value);
} else if (itm->param_name =="height") {
dnn_height = mtoi(itm->param_value);
}
}
}
Expand Down Expand Up @@ -565,9 +567,7 @@ void cls_algsec::load_params()
image_norm = (u_char*)mymalloc((size_t)cam->imgs.size_norm);

params = new ctx_params;
params->update_params = true;
util_parms_parse(params, "secondary_params"
, cam->cfg->secondary_params);
util_parms_parse(params, "secondary_params", cam->cfg->secondary_params);

params_defaults();

Expand Down
50 changes: 24 additions & 26 deletions src/libcam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,18 +211,16 @@ void cls_libcam:: log_draft()

void cls_libcam::start_params()
{
p_lst *lst;
p_it it;
ctx_params_item *itm;
int indx;

params = new ctx_params;
params->update_params = true;
util_parms_parse(params,"libcam_params", cam->cfg->libcam_params);

lst = &params->params_array;

for (it = lst->begin(); it != lst->end(); it++) {
for (indx=0;indx<params->params_cnt;indx++) {
itm = &params->params_array[indx];
MOTPLS_LOG(NTC, TYPE_VIDEO, NO_ERRNO, "%s : %s"
,it->param_name.c_str(), it->param_value.c_str());
,itm->param_name.c_str(), itm->param_value.c_str());
}
}

Expand Down Expand Up @@ -447,12 +445,12 @@ void cls_libcam::config_control_item(std::string pname, std::string pvalue)

void cls_libcam::config_controls()
{
int retcd;
p_lst *lst = &params->params_array;
p_it it;
int retcd, indx;

for (it = lst->begin(); it != lst->end(); it++) {
config_control_item(it->param_name, it->param_value);
for (indx=0;indx<params->params_cnt;indx++) {
config_control_item(
params->params_array[indx].param_name
,params->params_array[indx].param_value);
}

retcd = config->validate();
Expand All @@ -472,33 +470,33 @@ void cls_libcam::config_controls()
void cls_libcam:: config_orientation()
{
#if (LIBCAMVER >= 2000)
int retcd;
int retcd, indx;
std::string adjdesc;
p_lst *lst = &params->params_array;
p_it it;
ctx_params_item *itm;

for (it = lst->begin(); it != lst->end(); it++) {
if (it->param_name == "orientation") {
if (it->param_value == "Rotate0") {
for (indx=0;indx<params->params_cnt;indx++) {
itm = &params->params_array[indx];
if (itm->param_name == "orientation") {
if (itm->param_value == "Rotate0") {
config->orientation = Orientation::Rotate0;
} else if (it->param_value == "Rotate0Mirror") {
} else if (itm->param_value == "Rotate0Mirror") {
config->orientation = Orientation::Rotate0Mirror;
} else if (it->param_value == "Rotate180") {
} else if (itm->param_value == "Rotate180") {
config->orientation = Orientation::Rotate180;
} else if (it->param_value == "Rotate180Mirror") {
} else if (itm->param_value == "Rotate180Mirror") {
config->orientation = Orientation::Rotate180Mirror;
} else if (it->param_value == "Rotate90") {
} else if (itm->param_value == "Rotate90") {
config->orientation = Orientation::Rotate90;
} else if (it->param_value == "Rotate90Mirror") {
} else if (itm->param_value == "Rotate90Mirror") {
config->orientation = Orientation::Rotate90Mirror;
} else if (it->param_value == "Rotate270") {
} else if (itm->param_value == "Rotate270") {
config->orientation = Orientation::Rotate270;
} else if (it->param_value == "Rotate270Mirror") {
} else if (itm->param_value == "Rotate270Mirror") {
config->orientation = Orientation::Rotate270Mirror;
} else {
MOTPLS_LOG(ERR, TYPE_VIDEO, NO_ERRNO
, "Invalid Orientation option: %s."
, it->param_value.c_str());
, itm->param_value.c_str());
}
}
}
Expand Down
26 changes: 12 additions & 14 deletions src/motionplus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,7 @@ void cls_motapp::allcams_init()
bool cfg_valid, chk;
std::string cfg_row, cfg_col;
ctx_params *params_loc;
p_lst *lst;
p_it it;
ctx_params_item *itm;

all_sizes = new ctx_all_sizes;
all_sizes->height = 0;
Expand All @@ -294,32 +293,31 @@ void cls_motapp::allcams_init()
cam_list[indx]->all_loc.scale =
cam_list[indx]->cfg->stream_preview_scale;

params_loc->update_params = true;
util_parms_parse(params_loc
, "stream_preview_location"
, cam_list[indx]->cfg->stream_preview_location);
lst = &params_loc->params_array;

for (it = lst->begin(); it != lst->end(); it++) {
if (it->param_name == "row") {
cam_list[indx]->all_loc.row = mtoi(it->param_value);
for (indx1=0;indx1<params_loc->params_cnt;indx1++) {
itm = &params_loc->params_array[indx];
if (itm->param_name == "row") {
cam_list[indx]->all_loc.row = mtoi(itm->param_value);
}
if (it->param_name == "col") {
cam_list[indx]->all_loc.col = mtoi(it->param_value);
if (itm->param_name == "col") {
cam_list[indx]->all_loc.col = mtoi(itm->param_value);
}
if (it->param_name == "offset_col") {
if (itm->param_name == "offset_col") {
cam_list[indx]->all_loc.offset_user_col =
mtoi(it->param_value);
mtoi(itm->param_value);
}
if (it->param_name == "offset_row") {
if (itm->param_name == "offset_row") {
cam_list[indx]->all_loc.offset_user_row =
mtoi(it->param_value);
mtoi(itm->param_value);
}
}
params_loc->params_array.clear();
}

delete params_loc;
mydelete(params_loc);

mx_row = 0;
mx_col = 0;
Expand Down
51 changes: 23 additions & 28 deletions src/netcam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -814,8 +814,7 @@ void cls_netcam::hwdecoders()
void cls_netcam::decoder_error(int retcd, const char* fnc_nm)
{
char errstr[128];
p_lst *lst = &params->params_array;
p_it it;
int indx;

if (interrupted) {
MOTPLS_LOG(ERR, TYPE_NETCAM, NO_ERRNO
Expand All @@ -841,9 +840,9 @@ void cls_netcam::decoder_error(int retcd, const char* fnc_nm)
,_("%s:Ignoring and removing the user requested decoder %s")
,cameratype.c_str(), decoder_nm.c_str());

for (it = lst->begin(); it != lst->end(); it++) {
if (it->param_name == "decoder") {
it->param_value = "NULL";
for (indx=0;indx<params->params_cnt;indx++) {
if (params->params_array[indx].param_name == "decoder") {
params->params_array[indx].param_value = "NULL";
break;
}
}
Expand Down Expand Up @@ -1509,8 +1508,8 @@ int cls_netcam::ntc()
void cls_netcam::set_options()
{
std::string tmp;
p_lst *lst = &params->params_array;
p_it it;
int indx;
ctx_params_item *itm;

if ((service == "rtsp") ||
(service == "rtsps") ||
Expand Down Expand Up @@ -1556,15 +1555,16 @@ void cls_netcam::set_options()
, service.c_str());
}

for (it = lst->begin(); it != lst->end(); it++) {
if ((it->param_name != "decoder") &&
(it->param_name != "capture_rate")) {
for (indx=0;indx<params->params_cnt;indx++) {
itm = &params->params_array[indx];
if ((itm->param_name != "decoder") &&
(itm->param_name != "capture_rate")) {
av_dict_set(&opts
, it->param_name.c_str(), it->param_value.c_str(), 0);
, itm->param_name.c_str(), itm->param_value.c_str(), 0);
if (status == NETCAM_NOTCONNECTED) {
MOTPLS_LOG(INF, TYPE_NETCAM, NO_ERRNO,_("%s:%s = %s")
,cameratype.c_str()
,it->param_name.c_str(),it->param_value.c_str());
,itm->param_name.c_str(),itm->param_value.c_str());
}
}
}
Expand Down Expand Up @@ -1613,7 +1613,7 @@ void cls_netcam::set_path ()

void cls_netcam::set_parms ()
{
p_it it;
int indx;

params = new ctx_params;

Expand All @@ -1637,17 +1637,13 @@ void cls_netcam::set_parms ()
imgsize.height = 0;
cameratype = _("High");
cfg_params = cam->cfg->netcam_high_params;
params->update_params = true;
util_parms_parse(params
,"netcam_high_params", cfg_params);
util_parms_parse(params,"netcam_high_params", cfg_params);
} else {
imgsize.width = cfg_width;
imgsize.height = cfg_height;
cameratype = _("Norm");
cfg_params = cam->cfg->netcam_params;
params->update_params = true;
util_parms_parse(params
,"netcam_params", cfg_params);
util_parms_parse(params,"netcam_params", cfg_params);
}
camera_name = cam->cfg->device_name;

Expand Down Expand Up @@ -1686,20 +1682,19 @@ void cls_netcam::set_parms ()
filedir = "";
cfg_idur = 90;

for (it = params->params_array.begin();
it != params->params_array.end(); it++) {
if (it->param_name == "decoder") {
decoder_nm = it->param_value;
for (indx=0;indx<params->params_cnt;indx++) {
if (params->params_array[indx].param_name == "decoder") {
decoder_nm = params->params_array[indx].param_value;
}
if (it->param_name == "capture_rate") {
if (it->param_value == "pts") {
if (params->params_array[indx].param_name == "capture_rate") {
if (params->params_array[indx].param_value == "pts") {
pts_adj = true;
} else {
capture_rate = mtoi(it->param_value);
capture_rate = mtoi(params->params_array[indx].param_value);
}
}
if (it->param_name == "interrupt") {
cfg_idur = mtoi(it->param_value);
if (params->params_array[indx].param_name == "interrupt") {
cfg_idur = mtoi(params->params_array[indx].param_value);
}
}

Expand Down
Loading

0 comments on commit e814bcb

Please sign in to comment.