GPU Deepstream6.1 draw line with opencv in deepstream n_frame = pyds.get_nvds_buf_surface(hash(gst_buffer), frame_meta.batch_id)

Please provide complete information as applicable to your setup.

RTX3090• Hardware Platform (Jetson / GPU)**
6.1• DeepStream Version**
8.2• TensorRT Version***• NVIDIA GPU Driver Version (valid for GPU only)**
draw line with opencv in deepstream failed
Segmentation fault (core dumped)

n_frame = pyds.get_nvds_buf_surface(hash(gst_buffer), frame_meta.batch_id)
n_frame = draw_bounding_boxes(n_frame, obj_meta, obj_meta.confidence)

def draw_bounding_boxes(image, obj_meta, confidence):
confidence = ‘{0:.2f}’.format(confidence)
rect_params = obj_meta.rect_params
top = int(rect_params.top)
left = int(rect_params.left)
width = int(rect_params.width)
height = int(rect_params.height)
obj_name = pgie_classes_str[obj_meta.class_id]
# image = cv2.rectangle(image, (left, top), (left + width, top + height), (0, 0, 255, 0), 2, cv2.LINE_4)
color = (0, 0, 255, 0)
w_percents = int(width * 0.05) if width > 100 else int(width * 0.1)
h_percents = int(height * 0.05) if height > 100 else int(height * 0.1)
linetop_c1 = (left + w_percents, top)
linetop_c2 = (left + width - w_percents, top)
image = cv2.line(image, linetop_c1, linetop_c2, color, 6)
linebot_c1 = (left + w_percents, top + height)
linebot_c2 = (left + width - w_percents, top + height)
image = cv2.line(image, linebot_c1, linebot_c2, color, 6)
lineleft_c1 = (left, top + h_percents)
lineleft_c2 = (left, top + height - h_percents)
image = cv2.line(image, lineleft_c1, lineleft_c2, color, 6)
lineright_c1 = (left + width, top + h_percents)
lineright_c2 = (left + width, top + height - h_percents)
image = cv2.line(image, lineright_c1, lineright_c2, color, 6)
# Note that on some systems cv2.putText erroneously draws horizontal lines across the image
image = cv2.putText(image, obj_name + ‘,C=’ + str(confidence), (left - 10, top - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.5,
(0, 0, 255, 0), 2)
return image

There is no update from you for a period, assuming this is not an issue anymore. Hence we are closing this topic. If need further support, please open a new one. Thanks

I think you can refer this topic

If you want use OpenCV to draw bbox on GPU,unified memory In CUDA is necessary

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.