Esempio n. 1
0
async def test_object_recognise_flower():
    """测试物体(花)识别

    让机器人识别花(需手动把花或花的照片放到机器人面前),超时10s,并等待结果

    #RecogniseObjectResponse.objects : 物体名数组[str]

    #RecogniseObjectResponse.isSuccess : 是否成功

    #RecogniseObjectResponse.resultCode : 返回码

    """
    # object_type: 支持FLOWER, FRUIT, GESTURE 三类物体
    block: ObjectRecognise = ObjectRecognise(
        object_type=ObjectRecogniseType.FLOWER, timeout=10)
    # response : RecogniseObjectResponse
    (resultType, response) = await block.execute()

    print(f'test_object_recognise_flower result: {response}')

    assert resultType == MiniApiResultType.Success, 'test_object_recognise_flower timetout'
    assert response is not None and isinstance(
        response, RecogniseObjectResponse
    ), 'test_object_recognise_flower result unavailable'
    assert response.isSuccess, 'test_object_recognise_flower failed'
    async def recognise_fruit(self, timeout=10):
        """测试物体(水果)识别
        """
        # object_type: 支持FLOWER, FRUIT, GESTURE 三类物体
        block: ObjectRecognise = ObjectRecognise(object_type=ObjectRecogniseType.FRUIT, timeout=timeout)
        # response : RecogniseObjectResponse
        (resultType, response) = await block.execute()

        logger.debug(f'test_object_recognise_fruit result: {response}')

        assert resultType == MiniApiResultType.Success, 'recognise_fruit timetout'
        assert response is not None and isinstance(response,
                                                RecogniseObjectResponse), 'recognise_fruit result unavailable'
        assert response.isSuccess, 'recognise_fruit failed'
        return response.objects