Is this the proper way to make an OpenCV mat from a buffer, e.g. within a probe handing?
surface = pyds.get_nvds_buf_surface(hash(gst_buffer), frame_meta.batch_id)
frame = np.array(surface, copy=True, order='C')
frame = cv2.cvtColor(frame, cv2.COLOR_RGBA2BGRA)
Disregard please. Found this sample
#!/usr/bin/env python3
################################################################################
# SPDX-FileCopyrightText: Copyright (c) 2020-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
################################################################################
import sys
This file has been truncated. show original
Hmm. That crashes here:
My pipeline (parameters removed for clarity):
nvstreammux !
nvinfer !
nvtracker !
nvvideoconvert !
video/x-raw(memory:NVMM), format=RGBA !
nvdsosd !
nvvideoconvert !
nvv4l2h264enc !
rtspclientsink
uridecodebin !
mux.sink_0
The probe is placed at the output sink pad of nvdosd
. In the callback I’m running this once for 30 frames (taken from the sample):
n_frame = pyds.get_nvds_buf_surface(hash(gst_buffer), frame_meta.batch_id)
# convert python array into numpy array format in the copy mode.
frame_copy = np.array(n_frame, copy=True, order='C')
cv2.imwrite('./test.jpg', frame_copy)
The only line, which doesn’t crash the entire script with segmentation fault
is the first
n_frame = pyds.get_nvds_buf_surface(hash(gst_buffer), frame_meta.batch_id)
The next line crashes.
frame_copy = np.array(n_frame, copy=True, order='C')
What can I do to narrow down the problem?
The nice thing about this is: With this segfault in the Python script I am now at the same point where I stopped in my Golang script, because I could not avoid the segfault when accessing the surface…
Oh, turns out the addition of nvbuf-memory-type=3
to nvstreammux
and the two nvvideoconverts
was helpful :)
system
Closed
June 17, 2024, 12:54pm
6
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.