Skip to content
This repository was archived by the owner on Dec 16, 2022. It is now read-only.

Commit f093aa2

Browse files
committed
Merge branch 'main' of github.com:insight-platform/SavantBoost into main
2 parents f9b0865 + c4b9152 commit f093aa2

4 files changed

Lines changed: 27 additions & 23 deletions

File tree

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.2
1+
1.0.3

pysavantboost/src/preprocessing.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,10 @@ namespace pysavantboost {
9797
)
9898
.def("restore_frame", [] (
9999
ObjectsPreprocessing &self,
100-
size_t inbuf,
101-
int batchID
100+
size_t inbuf
102101
){
103102
auto *buffer = reinterpret_cast<GstBuffer *>(inbuf);
104-
self.restore_frame(buffer, batchID);
103+
self.restore_frame(buffer);
105104
},
106105
pydsdoc::preprocessing::ObjectsPreprocessing::restore_frame)
107106
.def(

savantboost/deepstream/preprocessing.cpp

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ GstFlowReturn ObjectsPreprocessing::preprocessing(
132132
cudaCheckError()
133133
frames_map[(size_t) inbuf].insert({frame_meta->batch_id, (void *) copy_frame});
134134

135-
int left_pencil_bbox=0, top_pencil_bbox=0, row_height=0;
135+
int left=0, top=0, row_height=0;
136136
int tmp_i = 0;
137137
int tmp_j = 0;
138138
for (object_meta_list = frame_meta->obj_meta_list; object_meta_list != nullptr; object_meta_list = object_meta_list -> next)
@@ -167,7 +167,7 @@ GstFlowReturn ObjectsPreprocessing::preprocessing(
167167
NppiSize dst_image_size = {.width = rect_params.width, .height = rect_params.height};
168168

169169
cudaCrop(
170-
(Npp8u *) ref_frame,
170+
(Npp8u *) copy_frame,
171171
src_image_size,
172172
crop_rect,
173173
(Npp8u*) preproc_object->getDataPtr(),
@@ -186,30 +186,35 @@ GstFlowReturn ObjectsPreprocessing::preprocessing(
186186

187187

188188
NppiRect crop_rect = {.x =0, .y=0, .width = preproc_object->getWidth(), .height = preproc_object->getHeight()};
189-
NppiSize clc_pencil_image_size = {.width = preproc_object->getWidth(), .height = preproc_object->getHeight()};
189+
NppiSize clc_image_size = {.width = preproc_object->getWidth(), .height = preproc_object->getHeight()};
190+
191+
if (left + preproc_object->getWidth() > ref_frame_size.width)
192+
{
193+
left = 0;
194+
top += row_height;
195+
row_height = 0;
196+
if (top >= ref_frame_size.height) throw std::runtime_error("There is no place on frame to put object image.");
197+
}
198+
if (top + preproc_object->getHeight() > ref_frame_size.height)
199+
throw std::runtime_error("There is no place on frame to put object image.");
200+
if (preproc_object->getHeight() > row_height) row_height = preproc_object->getHeight();
201+
190202
cudaCrop(
191203
(Npp8u *) preproc_object->getDataPtr(),
192-
clc_pencil_image_size,
204+
clc_image_size,
193205
crop_rect,
194206
ref_frame,
195207
ref_frame_size,
196-
left_pencil_bbox,
197-
top_pencil_bbox);
208+
left,
209+
top
210+
);
198211

199-
object_meta->rect_params.left = (float) left_pencil_bbox;
200-
object_meta->rect_params.top = (float) top_pencil_bbox;
212+
object_meta->rect_params.left = (float) left;
213+
object_meta->rect_params.top = (float) top;
201214
object_meta->rect_params.width = (float) preproc_object->getWidth();
202215
object_meta->rect_params.height = (float) preproc_object->getHeight();
203216

204-
left_pencil_bbox += preproc_object->getWidth() ;
205-
if (preproc_object->getHeight() > row_height) row_height = preproc_object->getHeight();
206-
if (left_pencil_bbox >= ref_frame_size.width)
207-
{
208-
left_pencil_bbox = 0;
209-
top_pencil_bbox += row_height;
210-
row_height = 0;
211-
if (top_pencil_bbox >= ref_frame_size.height) throw std::runtime_error("There is no place on image to put pencil.");
212-
}
217+
left += preproc_object->getWidth() ;
213218
if (preproc_object!=nullptr) delete preproc_object;
214219
}
215220
}
@@ -227,7 +232,7 @@ GstFlowReturn ObjectsPreprocessing::preprocessing(
227232
}
228233
}
229234

230-
GstFlowReturn ObjectsPreprocessing::restore_frame(GstBuffer* gst_buffer, int batchID){
235+
GstFlowReturn ObjectsPreprocessing::restore_frame(GstBuffer* gst_buffer){
231236

232237
GstMapInfo in_map_info;
233238
gboolean status;

savantboost/deepstream/preprocessing.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class ObjectsPreprocessing{
6060
std::string custom_lib,
6161
std::string custom_func
6262
);
63-
GstFlowReturn restore_frame(GstBuffer* gst_buffer, int batchID);
63+
GstFlowReturn restore_frame(GstBuffer* gst_buffer);
6464
GstFlowReturn preprocessing_rect(GstBuffer * inbuf, gint model_uid, gint class_id, gint padding_width, gint padding_height);
6565
GstFlowReturn preprocessing(
6666
std::string element_name,

0 commit comments

Comments
 (0)