|  | 
板凳
 
 楼主|
发表于 2023-2-6 17:17:35
|
只看该作者 
| 您好我的代码是这样的: 
 ret = rknn.init_runtime(core_mask=RKNNLite.NPU_CORE_0_1_2)这行代码放在while True:里边可以正常运行,就相当于没循环一次调用一次,放在while上边调用就报错。有什么好的解决方法吗?# 获取相机id
camera_id, camera = certain_camera_id()
# 设置图像分辨率640*480
camera.set(cv2.CAP_PROP_FRAME_WIDTH, 640)
camera.set(cv2.CAP_PROP_FRAME_HEIGHT, 480)
while True:
    ret = rknn.init_runtime(core_mask=RKNNLite.NPU_CORE_0_1_2)
    if ret != 0:
        print('init runtime failed!')
    print('done')
    # 读取相机图像 
    ret, img = camera.read()
    
    if not ret:
        print("not found camera")
        break
    # Set inputs
    img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
    img = cv2.resize(img, (IMG_SIZE, IMG_SIZE))
    # Inference
    # print('--> Running model')
    outputs = rknn.inference(inputs=[img])
 | 
 |