Ejemplo n.º 1
0
    def operations_search(self, request_id, faceset_id):
        '''
        返回操作id对应的结果。结果内包含与faceset_id关联所有IPC的未成功的face_id状态信息。
        未成功状态包括pending和fail。
        已成功的face_id,不在查询结果中。
        :param request_id:
        :param faceset_id:
        :return:
        '''
        method = 'GET'
        path = self.api_version + '/operations/%s' % request_id

        params = {'faceset_id': faceset_id}

        headers = {'host': self.host}

        authorization = self.auth.get_sign(http_method=method,
                                           path=path,
                                           params=params,
                                           headers=headers)
        url = '{0}{1}?{2}'.format(self.base_url, path,
                                  au.get_canonical_querystring(params))
        print(url)
        ret, info = dohttp._get(url, auth=authorization)

        return ret, info
Ejemplo n.º 2
0
    def device_info(self, device_sn, attributes=None):
        '''
        返回指定的设备空间详细信息,主要是设备空间本身的属性信息
        :param device_sn: 空间id
        :param attributes: 用户自定义获取信息字段,如果不传则默认返回设备通用信息
        :return:
        '''

        method = 'GET'
        path = self.api_version + '/devices/%s' % device_sn

        params = {}

        if attributes:
            params.update({'attributes': 'capture_config'})
            params.update({'capture_config': attributes['capture_config']})

        headers = {'host': self.host}

        authorization = self.auth.get_sign(http_method=method,
                                           path=path,
                                           params=params,
                                           headers=headers)

        if params:
            url = '{0}{1}?{2}'.format(self.base_url, path,
                                      au.get_canonical_querystring(params))
        else:
            url = '{0}{1}'.format(self.base_url, path)
        print(url)

        ret, info = dohttp._get(url, '', authorization)

        return ret, info
    def count_search(self, device_sn, start_time, end_time, cycle=None):
        '''
        根据指定的时间和周期,查询客流量,查询粒度为设备,
        统计维度包括设备、人脸库、性别、年龄、进店、出店,统计的不同维度的进出店客流量是人次,没有去重计算
        :param device_sn:
        :param start_time:  开始时间,ISO-8601时间
        :param end_time:    结束时间,ISO-8601时间
        :param cycle:       统计周期,可选值为hour、day,不传值时只返回总数
        :return:
        '''

        method = 'GET'
        path = self.api_version + '/analysis_tools/%s/count' % device_sn

        params = {'start_time': start_time, 'end_time': end_time}

        headers = {'host': self.host}

        authorization = self.auth.get_sign(http_method=method,
                                           path=path,
                                           params=params,
                                           headers=headers)
        url = '{0}{1}?{2}'.format(self.base_url, path,
                                  au.get_canonical_querystring(params))
        print(url)
        ret, info = dohttp._get(url, authorization)

        return ret, info
Ejemplo n.º 4
0
    def list(self, current=1, per_page=20, space_id=None, attributes=None):
        '''
        获取设备空间列表
        参考:https://iotdoc.horizon.ai/busiopenapi/part1_device_space/device_space.html#part1_0
        :param current:当前页,不填时默认为1,需要和per_page同时填/不填
        :param per_page:每页数量,不填时默认值为20
        :param space_id:设备空间id,不传时返回默认设备空间下的设备列表
        :param attributes:用户自定义获取信息字段,如果不传则默认返回设备通用信息,
        attributes={name,capture_config}
            name          模块
            capture_config 配置
        :return:
            一个dict变量,类似 {"hash": "<Hash string>", "key": "<Key string>"}
            一个ResponseInfo对象
            一个EOF信息。
        '''

        method = 'GET'
        path = self.api_version + '/devices'

        #验证current 、per_page
        if (current and per_page):
            current = current
            per_page = per_page
        elif not (current == per_page):
            raise ValueError(
                'current and per_page must fill in at the same time or neither'
            )

        #生成请求参数
        params = {
            'current': current,
            'per_page': per_page,
        }
        params.update({'space_id': space_id}) if space_id else None
        if attributes:
            params.update({'attributes': 'capture_config'})
            params.update({'capture_config': attributes['capture_config']})

        headers = {'host': self.host}

        authorization = self.auth.get_sign(http_method=method,
                                           path=path,
                                           params=params,
                                           headers=headers)

        url = '{0}{1}?{2}'.format(self.base_url, path,
                                  au.get_canonical_querystring(params=params))
        print(url)

        ret, info = dohttp._get(url, '', auth=authorization)
        # 枚举列表是否完整
        eof = False
        if ret:
            if ret["pagination"]["current"] * ret["pagination"][
                    "per_page"] >= ret["pagination"]["total"]:
                eof = True

        return ret, info, eof
Ejemplo n.º 5
0
    def ipc_list(
        self,
        type,
        current=1,
        per_page=20,
    ):
        '''
        OpenAPI获取设备列表指令,返回的设备类型支持客流识别机与识别机两种类型,客流识别机类型为2,识别机类型为3,
        返回所有IPC信息(包含IPC SN等信息),本次操作的状态码与错误信息
        :param current:
        :param per_page:
        :param type:设备类型,只能是客流识别机(2)或者识别机(3)
        :return:
        '''
        method = 'GET'
        path = self.api_version + '/devices'

        if not type in [2, 3]:
            raise ValueError('type 客流识别机(2)或者识别机(3)')

        # 验证current 、per_page
        if (current and per_page):
            current = current
            per_page = per_page
        elif not (current == per_page):
            raise ValueError(
                'current and per_page must fill in at the same time or neither'
            )

        params = {
            'type': type,
            'current': current,
            'per_page': per_page,
        }

        headers = {'host': self.host}

        authorization = self.auth.get_sign(http_method=method,
                                           path=path,
                                           params=params,
                                           headers=headers)

        url = '{0}{1}?{2}'.format(self.base_url, path,
                                  au.get_canonical_querystring(params=params))
        print(url)

        ret, info = dohttp._get(url, '', auth=authorization)
        # 枚举列表是否完整
        eof = False
        if ret:
            if ret["pagination"]["current"] * ret["pagination"][
                    "per_page"] >= ret["pagination"]["total"]:
                eof = True

        return ret, info, eof
    def visitors_search(self,
                        device_sn,
                        start_time,
                        end_time,
                        current=1,
                        per_page=20):
        '''

        :param device_sn:
        :param start_time:
        :param end_time:
        :param current:
        :param per_page:
        :return:
        '''

        method = 'GET'
        path = self.api_version + '/analysis_tools/%s/visitors' % device_sn

        # 验证current 、per_page
        if (current and per_page):
            current = current
            per_page = per_page
        elif not (current == per_page):
            raise ValueError(
                'current and per_page must fill in at the same time or neither'
            )

        params = {
            'start_time': start_time,
            'end_time': end_time,
            'current': current,
            'per_page': per_page
        }

        headers = {'host': self.host}

        authorization = self.auth.get_sign(http_method=method,
                                           path=path,
                                           params=params,
                                           headers=headers)
        url = '{0}{1}?{2}'.format(self.base_url, path,
                                  au.get_canonical_querystring(params))
        print(url)

        ret, info = dohttp._get(url, auth=authorization)
        # 枚举列表是否完整
        eof = False
        if ret:
            if ret["pagination"]["current"] * ret["pagination"][
                    "per_page"] >= ret["pagination"]["total"]:
                eof = True

        return ret, info, eof
Ejemplo n.º 7
0
    def list(self, faceset_id, current=1, per_page=20):
        '''
        用于获取指定人脸库中的用户列表,单个人脸库可注册的用户最大的数据量是100万,超过100万会报错
        参考:https://iotdoc.horizon.ai/busiopenapi/part4_api_basic/faceset_face.html#part4_1_4
        :param current:当前页,不填时默认为1,需要和per_page同时填/不填
        :param per_page:每页数量,不填时默认值为20
        :param faceset_id:设备空间id,不传时返回默认设备空间下的设备列表
        :return:
            一个dict变量,类似 {"hash": "<Hash string>", "key": "<Key string>"}
            一个ResponseInfo对象
            一个EOF信息。
        '''

        method = 'GET'
        path = self.api_version + '/facesets/%s/faces' % faceset_id

        # 验证current 、per_page
        if (current and per_page):
            current = current
            per_page = per_page
        elif not (current == per_page):
            raise ValueError(
                'current and per_page must fill in at the same time or neither'
            )

        params = {
            'current': current,
            'per_page': per_page,
        }

        headers = {'host': self.host}

        authorization = self.auth.get_sign(http_method=method,
                                           path=path,
                                           params=params,
                                           headers=headers)
        query = au.get_canonical_querystring(params=params)

        url = '{0}{1}?{2}'.format(self.base_url, path, query)
        print(url)

        ret, info = dohttp._get(url, '', auth=authorization)
        # 枚举列表是否完整
        eof = False
        if ret:
            if ret["pagination"]["current"] * ret["pagination"][
                    "per_page"] >= ret["pagination"]["total"]:
                eof = True

        return ret, info, eof
Ejemplo n.º 8
0
    def user_info_get(self, faceset_id, per_page=1, current=20, **kwargs):
        '''
        OpenAPI获取用户查询指令,内部对指定人脸库查询用户,返回本次操作的用户信息,状态码与错误信息
        :param faceset_id:
        :param face_id:
        :param kwargs:
        :return:
        '''
        method = 'GET'
        path = self.api_version + '/facesets/{0}/faces'.format(faceset_id)

        # 验证current 、per_page
        if (current and per_page):
            current = current
            per_page = per_page
        elif not (current == per_page):
            raise ValueError(
                'current and per_page must fill in at the same time or neither'
            )

        params = {
            'current': current,
            'per_page': per_page,
        }

        headers = {'host': self.host}

        for k, v in kwargs.items():
            if k in _user_face_list_feild:
                params.update({k, v})

        authorization = self.auth.get_sign(http_method=method,
                                           path=path,
                                           params=params,
                                           headers=headers)

        url = '{0}{1}?{2}'.format(self.base_url, path,
                                  au.get_canonical_querystring(params=params))
        print(url)

        ret, info = dohttp._get(url, '', auth=authorization)
        # 枚举列表是否完整
        eof = False
        if ret:
            if ret["pagination"]["current"] * ret["pagination"][
                    "per_page"] >= ret["pagination"]["total"]:
                eof = True

        return ret, info, eof
Ejemplo n.º 9
0
    def list(self, current=1, per_page=20):
        '''
        获取设备空间列表
        参考:https://iotdoc.horizon.ai/busiopenapi/part1_device_space/device_space.html#part1_0
        :param current:当前页,不填时默认为1,需要和per_page同时填/不填
        :param per_page:每页数量,不填时默认值为20
        :return:
            一个dict变量,类似 {"hash": "<Hash string>", "key": "<Key string>"}
            一个ResponseInfo对象
            一个EOF信息。
        '''

        method = 'GET'
        path = self.api_version + '/device_spaces'

        # 验证current 、per_page
        if (current and per_page):
            current = current
            per_page = per_page
        elif not (current == per_page):
            raise ValueError(
                'current and per_page must fill in at the same time or neither'
            )

        params = {'current': current, 'per_page': per_page}

        headers = {'host': self.host}

        authorization = self.auth.get_sign(http_method=method,
                                           path=path,
                                           params=params,
                                           headers=headers)

        url = '{0}{1}?{2}'.format(self.base_url, path,
                                  au.get_canonical_querystring(params))

        print(url)

        ret, info = dohttp._get(url, auth=authorization)

        # 枚举列表是否完整
        eof = False
        if ret:
            if ret["pagination"]["current"] * ret["pagination"][
                    "per_page"] >= ret["pagination"]["total"]:
                eof = True

        return ret, info, eof
Ejemplo n.º 10
0
    def facest_list(self, current=1, per_page=20):
        '''

        :param current:
        :param per_page:
        :return:
        '''
        method = 'GET'
        path = self.api_version + '/facesets'

        # 验证current 、per_page
        if (current and per_page):
            current = current
            per_page = per_page
        elif not (current == per_page):
            raise ValueError(
                'current and per_page must fill in at the same time or neither'
            )

        params = {
            'current': current,
            'per_page': per_page,
        }

        headers = {'host': self.host}

        authorization = self.auth.get_sign(http_method=method,
                                           path=path,
                                           params=params,
                                           headers=headers)

        url = '{0}{1}?{2}'.format(self.base_url, path,
                                  au.get_canonical_querystring(params=params))
        print(url)

        ret, info = dohttp._get(url, '', auth=authorization)
        # 枚举列表是否完整
        eof = False
        if ret:
            if ret["pagination"]["current"] * ret["pagination"][
                    "per_page"] >= ret["pagination"]["total"]:
                eof = True

        return ret, info, eof