Skip to content

Commit

Permalink
#43 benchmark cuda download/upload
Browse files Browse the repository at this point in the history
  • Loading branch information
tomskikh committed Jan 26, 2023
1 parent 128760a commit 3217fa8
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions gpumat/dsapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,31 +50,23 @@ def pad_buffer_probe(
measurements: List[float],
):
rectangles = [(random.randint(0, 1800), random.randint(0, 800)) for _ in range(20)]
width = 100
height = 200
gst_buffer: Gst.Buffer = info.get_buffer()
nvds_batch_meta = pyds.gst_buffer_get_nvds_batch_meta(hash(gst_buffer))
for nvds_frame_meta in nvds_frame_meta_iterator(nvds_batch_meta):
ts1 = time.time()
if cpu:
with get_nvds_buf_surface(gst_buffer, nvds_frame_meta) as np_frame:
for x, y in rectangles:
np_frame[y : y + 40, x : x + 30] = cv2.GaussianBlur(
np_frame[y : y + 40, x : x + 30],
(31, 31),
100,
100,
)
part = np_frame[y : y + height, x : x + width]
np_frame[y : y + height, x : x + width] = part
else:
with nvds_to_gpu_mat(gst_buffer, nvds_frame_meta) as frame_mat:
for x, y in rectangles:
roi = cv2.cuda.GpuMat(frame_mat, (x, y, 30, 40))
roi.upload(
cv2.GaussianBlur(
roi.download(),
(31, 31),
100,
100,
)
)
roi = cv2.cuda.GpuMat(frame_mat, (x, y, width, height))
part = roi.download()
roi.upload(part)
ts2 = time.time()
measurements.append((ts2 - ts1) * scale)

Expand Down

0 comments on commit 3217fa8

Please sign in to comment.