Skip to content
This repository has been archived by the owner on Dec 18, 2024. It is now read-only.

Commit

Permalink
Refactor detect_filter_properties function and EdgeYOLOONNXRuntime co…
Browse files Browse the repository at this point in the history
…nstructor
  • Loading branch information
royshil committed Mar 28, 2024
1 parent 0dd49ac commit aec5c51
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 18 deletions.
26 changes: 12 additions & 14 deletions src/detect-filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,8 @@ obs_properties_t *detect_filter_properties(void *data)

// add callback to show/hide masking options
obs_property_set_modified_callback(
masking_group_prop,
[](obs_properties_t *props, obs_property_t *p,
obs_data_t *settings) {
masking_group_prop, [](obs_properties_t *props,
obs_property_t *, obs_data_t *settings) {
const bool enabled =
obs_data_get_bool(settings, "masking_group");
obs_property_t *prop =
Expand Down Expand Up @@ -186,18 +185,17 @@ obs_properties_t *detect_filter_properties(void *data)
masking_type, obs_module_text("Transparent"), "transparent");

// add color picker for solid color masking
obs_property_t *masking_color =
obs_properties_add_color(masking_group, "masking_color",
obs_module_text("MaskingColor"));
obs_properties_add_color(masking_group, "masking_color",
obs_module_text("MaskingColor"));

// add slider for blur radius
obs_property_t *masking_blur_radius = obs_properties_add_int_slider(
masking_group, "masking_blur_radius",
obs_module_text("MaskingBlurRadius"), 1, 30, 1);
obs_properties_add_int_slider(masking_group, "masking_blur_radius",
obs_module_text("MaskingBlurRadius"), 1,
30, 1);

// add callback to show/hide blur radius and color picker
obs_property_set_modified_callback(
masking_type, [](obs_properties_t *props, obs_property_t *p,
masking_type, [](obs_properties_t *props, obs_property_t *,
obs_data_t *settings) {
const char *masking_type =
obs_data_get_string(settings, "masking_type");
Expand Down Expand Up @@ -231,7 +229,7 @@ obs_properties_t *detect_filter_properties(void *data)

// add callback to show/hide tracking options
obs_property_set_modified_callback(
tracking_group, [](obs_properties_t *props, obs_property_t *p,
tracking_group, [](obs_properties_t *props, obs_property_t *,
obs_data_t *settings) {
const bool enabled =
obs_data_get_bool(settings, "tracking_group");
Expand All @@ -244,9 +242,9 @@ obs_properties_t *detect_filter_properties(void *data)
});

// add zoom factor slider
obs_property_t *zoom_factor = obs_properties_add_float_slider(
tracking_group_props, "zoom_factor",
obs_module_text("ZoomFactor"), 1.0, 10.0, 0.1);
obs_properties_add_float_slider(tracking_group_props, "zoom_factor",
obs_module_text("ZoomFactor"), 1.0,
10.0, 0.1);

// add object selection for zoom drop down: "Single", "All"
obs_property_t *zoom_object = obs_properties_add_list(
Expand Down
6 changes: 3 additions & 3 deletions src/edgeyolo/edgeyolo_onnxruntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ EdgeYOLOONNXRuntime::EdgeYOLOONNXRuntime(
session_options.SetIntraOpNumThreads(
this->intra_op_num_threads_);

#ifdef _WIN32
if (this->use_gpu == "cuda") {
OrtCUDAProviderOptions cuda_option;
cuda_option.device_id = this->device_id_;
session_options.AppendExecutionProvider_CUDA(
cuda_option);
}
#ifdef _WIN32
if (this->use_gpu == "dml") {
auto &api = Ort::GetApi();
OrtDmlApi *dmlApi = nullptr;
Expand All @@ -53,8 +53,8 @@ EdgeYOLOONNXRuntime::EdgeYOLOONNXRuntime(
}
#endif

this->session_ = Ort::Session::Session(
this->env_, path_to_model.c_str(), session_options);
this->session_ = Ort::Session(this->env_, path_to_model.c_str(),
session_options);
} catch (std::exception &e) {
std::cerr << e.what() << std::endl;
throw e;
Expand Down
2 changes: 1 addition & 1 deletion src/edgeyolo/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ draw_objects(cv::Mat bgr, const std::vector<Object> &objects,
cv::rectangle(bgr, obj.rect, color * 255, 2);

char text[256];
sprintf(text, "%s %.1f%%", class_names[obj.label].c_str(),
snprintf(text, sizeof(text), "%s %.1f%%", class_names[obj.label].c_str(),
obj.prob * 100);

int baseLine = 0;
Expand Down

0 comments on commit aec5c51

Please sign in to comment.