多线程使用acllite解码出现问题
收藏回复举报
多线程使用acllite解码出现问题
t('forum.solved') 已解决
发表于2024-12-26 11:44:28
0 查看
 再跑多线程的时候出现这个问题,是因为其中有一些冲突吗
[ERROR] Decode channel 0 frame 17 failed, error 1
[ERROR] Decode channel 0 frame 18 failed, error 1
[ERROR] Decode channel 0 frame 19 failed, error 1
[ERROR] Decode channel 0 frame 20 failed, error 1
[ERROR] Decode channel 0 frame 21 failed, error 1
EE1001: [PID: 1379520] 2024-12-26-03:37:49.908.844 The argument is invalid.Reason: rtGetDevMsg execute failed, reason=[context pointer null]
        Solution: 1.Check the input parameter range of the function. 2.Check the function invocation relationship.
        TraceBack (most recent call last):
        ctx is NULL![FUNC:GetDevErrMsg][FILE:api_impl.cc][LINE:5315]
        The argument is invalid.Reason: rtGetDevMsg execute failed, reason=[context pointer null]

[ERROR] acl init failed
DeviceManager InitDevices failed. ret=100002

以下是源代码的一部分

import videocapture as video
from acllite_resource import AclLiteResource
import threading

import cv2
import numpy as np

class SceneInfo(threading.Thread):

    def __init__(self,rtsp):
        super(SceneInfo, self).__init__()
        self.rtsp = rtsp

    def run(self):

        resource = AclLiteResource()
        resource.init()
        cap = video.VideoCapture(self.rtsp)
        frame_cnt = 0  # 帧计数
        while 1:
            ret, frame = cap.read()
            if frame is not None:
                frame_cnt += 1  # 帧计数+1
                print(frame_cnt)
                if frame_cnt % 2 == 0:  # 如果当前帧计数 / 图像间隔 的余数为0
                    frame_cnt = 0  # 将帧计数置零
                    print('解码成功')
                    sec_frame = frame.byte_data_to_np_array().astype(np.uint8)
                    frame = cv2.cvtColor(sec_frame.reshape((frame.height * 3 // 2, frame.width)),
                                         cv2.COLOR_YUV2RGB_NV21)

s = SceneInfo('/mnt/edge_infer/test.h264')
s.start()

我要发帖子