Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

只修改Func函数 程序直接崩溃 #20

Open
CH-Echo opened this issue Nov 28, 2024 · 1 comment
Open

只修改Func函数 程序直接崩溃 #20

CH-Echo opened this issue Nov 28, 2024 · 1 comment

Comments

@CH-Echo
Copy link

CH-Echo commented Nov 28, 2024

大佬 我想问一下 我只是修改了func函数里面的方法而已 我运行main直接崩溃 什么程序直接退出segment Fault 而且看起来也不快 而且也只开了三个线程 难道三个线程在不同的三个核上跑程序都要崩溃吗

@HRXWEB
Copy link

HRXWEB commented Dec 16, 2024

先保证能跑起来再改代码,我使用的是 2.3.0 的 API 跑起来也碰到了 segmentfault 的问题,还有一个 input dims 不对的问题

修改的代码,只贴了部分代码块:

main.py

while (cap.isOpened()):
    frames += 1
    ret, frame = cap.read()
    if not ret:
        break
    pool.put(frame)
    frame, flag = pool.get()
    if flag == False:
        break
    # cv2.imshow('test', frame)
    # if cv2.waitKey(1) & 0xFF == ord('q'):
    #     break
    if frames % 30 == 0:
        print("30帧平均帧率:\t", 30 / (time.time() - loopTime), "帧")
        loopTime = time.time()

func.py

def myFunc(rknn_lite, IMG):
    IMG = cv2.cvtColor(IMG, cv2.COLOR_BGR2RGB)
    # 等比例缩放
    # IMG = letterbox(IMG)
    # 强制放缩
    IMG = cv2.resize(IMG, (IMG_SIZE, IMG_SIZE))
    IMG = np.expand_dims(IMG, axis=0)
    outputs = rknn_lite.inference(inputs=[IMG], data_format='nhwc')
    print('inference done')

    # import pdb; pdb.set_trace()
    input0_data = outputs[0].reshape([3, -1]+list(outputs[0].shape[-2:]))
    input1_data = outputs[1].reshape([3, -1]+list(outputs[1].shape[-2:]))
    input2_data = outputs[2].reshape([3, -1]+list(outputs[2].shape[-2:]))

    input_data = list()
    input_data.append(np.transpose(input0_data, (2, 3, 0, 1)))
    input_data.append(np.transpose(input1_data, (2, 3, 0, 1)))
    input_data.append(np.transpose(input2_data, (2, 3, 0, 1)))

    boxes, classes, scores = yolov5_post_process(input_data)

    # IMG = cv2.cvtColor(IMG, cv2.COLOR_RGB2BGR)
    # if boxes is not None:
    #     draw(IMG, boxes, scores, classes)
    print('ready to return...')
    return IMG

你可以比对看看

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants